A3 The Instruction Set 15 14 13 12 11 10 9 8 7 6 5 4 3 210 A
A.3 The Instruction Set 15 14 13 12 11 10 9 8 7 6 5 4 3 210 ADD ADD AND AND BR JMP JSR JSRR 0001 DR SR1 000 SR1 SR1 0 SR1 DR DR 0101 DR 1100 0100 PCoffset11 0100 0 00BaseR 0010 DR LDI 1010 DR I PCoffset9 LDR 0110 DR 1110 DR NOT RET RTI ST STI STR 1001 DR 1100 0011 1011 0111 1101 Flgure A.2 Format of the entire LC-3 instruction set. Note: indicates instructions that modify condition codes
Solution
BEQ $R1, $R2, else # if $R1 == $R2 then branch to else (beq is branch if equal)
ADD $R0, $R1, 0 #R0 = $R1+0 =>$R0 = $R1
exit
else:
ADD $R0, 0, 0 #R0 = 0+0 =>R0 =0
exit:
I hope it clarifies.
