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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

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:

  1. .ORIG x3000
  2. ; Two's Complement R1 (two instructions: negate and add 1)
  3. ; Initialize R3 with #0
  4. ; Add R0 and R1; place result into R2 (are they equal? If they are, what value is in R2?)
  5. ; Branch if non-zero to ELSE (they are not equal in this case)
  6. IF ; Place #5 in R3
  7. ; Branch to done
  8.  
  9. ELSE ; Place #-5 in R3
  10.  
  11. DONE ; Halt CPU
  12. .END
Expert Solution
Step 1

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

 

Computer Science homework question answer, step 1, image 1

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr