I am trying to write a code in LC-3 for finding the minimum and maximum values entered. So far I have completed what is below but am missing some major parts and I can't figure out what to do. ---- the lines like this is where I know something is needed. Is there ANYONE CAN HELP ME?????? please please please

.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

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
;
BRnzp TEST

----

QUIT RTN

LDR r6, r2, #0

negate 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

First, a short rant. Professors love to use stuff like this because it doesn't exist in real life and nobody will know how to help you (or help you cheat... but I won't do that). I had to go download all the stuff off of your textbook's website to learn about PC-3 (which, IMAO, is one of the most underpowered assembly languages I've ever seen). If they want to teach MIPS assembly, why not just use actual MIPS assembly?!!!
/end rant

The trick with assembly language is to think in fairly large terms, then for each term write a small series of instructions. You have already got a fairly good start. I'm not sure what you are doing after you RTN, but here are some thoughts on the min and max functions you are having trouble with. I will focus on R0 (min).

You've already got the current min in R0.
Each time through the loop you need to increment R2 by one, and load R5 with the value at R2. `ADD R2, R2, 1` `LDR R5, R2, 0` Now, copy R5 to R6 and negate R6 like you did for the comparitor.
Add it to R0, and check the result to see whether you are greater-than-or-equal-to R0. If so, you can safely jump to the next part where you will test the max (R1). Otherwise, make R0 equal to R5.
When testing for max, do the same sort of thing: if you test less-than-or-equal-to R1, jump to the part that does the loop (where you add one to R3 and branch if necessary).

Beware, since you started out with min and max both equal to the first DATA element, you are only comparing nine numbers, not ten. So your counter and comparator need to have the correct value.

Also, if you are required to print the results, remember that TRAP OUT prints the ASCII value in R0.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.