Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have no idea where to begin with this question: Write an LC-3 assembly languag

ID: 3808870 • Letter: I

Question

I have no idea where to begin with this question: Write an LC-3 assembly language program that determines the maximum and minimum values of an array. Your program should start at memory location x3000; the “max” and “min” values should be formatted (e.g., "Max = ...", etc.) and output to the console using the memory-mapped I/O registers (not the system traps).The number of elements in the array should be specified in the memory location immediately following your program, and then the values in the array should follow this number.To simplify output formatting, you may assume that all of the values in the array are unsigned and less than ten (i.e. positive single digits). Use the following array data values when you run the program for the console I/O screen shot: 1,3,7,2,5,4,8,7,0,2.

Explanation / Answer

.ORIG 0x3000

;R0 = MIN
;R1 = MAX
;R2 = ADDRESS OF DATA----INCREMENT THIS IN PLACE--TREAT AS COUNTER OF SORTS
;R3 = COUNTER current value
;R4 = COMPARATOR (-COUNT)
;R6 = - DATA VALUE
;R5 = TEST VALUE

LEA R2, DATA
LDR R0, R2, #0
LDR R1, R2, #0

AND R3, R3, #0 ; CLEAR R3


LEA R4, COUNT
LDR R4, R4, #0
NOT R4, R4
ADD R4, R4, #1

TEST ADD R7, R3, R4 ; SETS C.C NZP
BRzp QUIT
;COMPARISON TO MIN (R0)
;COMPARISON TO MAX (R1)- VALUE TO NEGATE IS DATA VALUE FROM BELOW
;
ADD R3, R3, #1
BRnzp TEST

----

QUIT RTN

LDR r6, r2, #0

negate r6

add r7, r0, r6

-
-
-
add r7, r1, r6
-----


COUNT .FILL 10
DATA .FILL 1
.FILL 2
.FILL 3
.FILL 4
.FILL 5
.FILL 6
.FILL 7
.FILL 8
.FILL 9
.FILL 10

.END