Write the following pseudocode in assembly language code that can be outed into a simulate like Lc3 simulat
Write the following pseudocode in assembly language code that can be outed into a simulate like Lc3 simulator! Thank you!
.FILL i
.FILL max
for (i = 0; i < max; i++) {
R3 = R3 + 5
}
.END
The assembly code:
i .FILL
max .javascript:;FILL
AND R0, R0, #0 ; AND with 0 yields zero
ST R0, i ; store 0 in i
TEST LD R0, i ; get i
LD R1, max ; get max
NOT R1, R1 ; two's complement
ADD R1, R1, #1
ADD R0, R0, R1 ; compute i - max
BRzp END ; done when (i - max) >= 0
LD R0, R3 ; load from memory to a register
ADD R0, R0, #1 ; increment value
ST R0, R3 ; store from register to memory
INCR LD R0, i ; get i
ADD R0, R0, #1 ; increment it
ST R0, i ; save the new value
BR TEST ; go back and test again
END ; code after loop completes
Trending now
This is a popular solution!
Step by step
Solved in 2 steps