write in assebly language using lc3 simulator LC3 simulator-https://wchargin.com/lc3web/ Write a program that implements a for loop that adds 5 to R3 every iteration a. Increment a register by 1 in every cycle of the loop to keep track of the loop iterations b. Store the maximum amount of iterations that the loop can have in a memory location c. Your for loop should start at 0 iterations (i.e. i = 0) and stop looping once the maximum is reached Psuedo code: .ORIG x3000 ; Step 1: Clear R3 ; Step 2: Clear R0 ; Step 3: Load the value of MAX into R1 (maximum amount of iterations) ; Step 4: Take the two's compliment of R1 (2 instructions!) loop ; Step 5: Add #5 to R3 (result) ; Step 6: Increment R0 (loop iteration counter) ; Step 7: Add R1 and R0 and put the result in R2 (Since we did a 2's complement on R1, we are essentially subtracting R1 from R0) ; Step 8: Branch if negative back to loop (this means that R1 > R0 and we need to keep looping) ; Step 9: Halt CPU MAX .FILL x5 .END
write in assebly language using lc3 simulator
LC3 simulator-https://wchargin.com/lc3web/
Write a
a. Increment a register by 1 in every cycle of the loop to keep track of the loop iterations
b. Store the maximum amount of iterations that the loop can have in a memory location
c. Your for loop should start at 0 iterations (i.e. i = 0) and stop looping once the maximum is reached
Psuedo code:
-
.ORIG x3000
-
; Step 1: Clear R3
-
; Step 2: Clear R0
-
; Step 3: Load the value of MAX into R1 (maximum amount of iterations)
-
; Step 4: Take the two's compliment of R1 (2 instructions!)
-
-
loop ; Step 5: Add #5 to R3 (result)
-
; Step 6: Increment R0 (loop iteration counter)
-
; Step 7: Add R1 and R0 and put the result in R2 (Since we did a 2's complement on R1, we are essentially subtracting R1 from R0)
-
; Step 8: Branch if negative back to loop (this means that R1 > R0 and we need to keep looping)
-
; Step 9: Halt CPU
-
-
MAX .FILL x5
-
.END
LC3 (Little Computer 3) is a simulator for a simple computer architecture that is commonly used to teach assembly language programming. The LC3 simulator provides an environment for writing, testing, and executing assembly language programs.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps