write in assembly language usinf LC3 simulator LC3 simulator to use: https://wchargin.com/lc3web/ Implement an if-else statement a. An if-else statement will execute one out of two blocks of code b. Your if-else statement should check if R0 = R1, then make R3 = 5, if R0 ≠ R1, then make R3 = -5 c. You can manually modify R0, R1, and R3, in the simulator (before running your program only). You do not have to program values for these registers Psuedo code: .ORIG x3000 ; Two's Complement R1 (two instructions: negate and add 1) ; Initialize R3 with #0 ; Add R0 and R1; place result into R2 (are they equal? If they are, what value is in R2?) ; Branch if non-zero to ELSE (they are not equal in this case) IF ; Place #5 in R3 ; Branch to done ELSE ; Place #-5 in R3 DONE ; Halt CPU .END
write in assembly language usinf LC3 simulator
LC3 simulator to use: https://wchargin.com/lc3web/
Implement an if-else statement
a. An if-else statement will execute one out of two blocks of code
b. Your if-else statement should check if R0 = R1, then make R3 = 5, if R0 ≠ R1, then make R3 = -5
c. You can manually modify R0, R1, and R3, in the simulator (before running your
have to program values for these registers
Psuedo code:
-
.ORIG x3000
-
; Two's Complement R1 (two instructions: negate and add 1)
-
; Initialize R3 with #0
-
; Add R0 and R1; place result into R2 (are they equal? If they are, what value is in R2?)
-
; Branch if non-zero to ELSE (they are not equal in this case)
-
IF ; Place #5 in R3
-
; Branch to done
-
-
ELSE ; Place #-5 in R3
-
-
DONE ; Halt CPU
-
.END
Here's the LC3 assembly code for the if-else statement:
.ORIG x3000
; Negate R1
NOT R1, R1
ADD R1, R1, #1
; Initialize R3 with #0
LD R3, #0
; Add R0 and R1 and store the result in R2
ADD R2, R0, R1
; Check if R2 is zero (R0 = R1)
BRZ IF
; If R0 ≠ R1, place #-5 in R3
LD R3, #-5
BR DONE
IF ; Place #5 in R3
LD R3, #5
DONE ; Halt CPU
HALT
.END
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images