Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the following code is in lc3 assembly code, program should Declare X and Y at x3120 and x3121 respectively then compute the difference and store

the following code is in lc3 assembly code, program should Declare X and Y at x3120 and x3121 respectively

then compute the difference and store it at x3122

then place absolute values |X| and |Y| at locations x3123 and x3124

then determine which |X| and |Y| is larger. (Place 1 at location x3125 if |X| is , a 2 if |Y| is, or a 0 if they are equal.)<<-- I need help with this part I know i need to use branch after subtracting to absolute values BRn if the result is negative BRz if zero and BRp if positive but I couldn't execute it properly

ORIG x3000 LDI R1,X X .FILL x3120 LDI R2,Y Y .FILL x3121 NOT R4,R2 ; NOT R2 and store it in R4 ADD R4, R4, #1 ; -R2 ADD R3, R1, R4 ; R3 <- R1-R2 STI R3, ANS ; RESULT X-Y ANS .FILL x3122 ADD R5,R1,#0 ; |X| BRzp ZP NOT R5,R5 ADD R5,R5,#1 ZP STI R5,ABSX ; |X| ABSX .FILL x3123 ADD R6,R2,#0 ; |Y| BRzp ZP1 NOT R6,R6 ADD R6,R6,#1 ZP1 STI R6,ABSY ; |Y| ABSY .FILL x3124 NOT R0,R6 ; NOT R6 and store it in R0 ADD R0,R0,#1 ; -R6 ADD R0,R5,R0 ; R0 <- R5-R6 ADD R0,R0,#0 BRp ONE ADD R0,R5,R0 ; R0 <- R5-R6 ADD R0,R0,#0 BRn TWO ADD R0,R5,R0 ; R0 <- R5-R6 ADD R0,R0,#0 BRz ZERO ONE ADD R0,R7,#1 ;1 IF RESULT |X|-|Y|= + TWO ADD R7,R7,#2 ;2 IF RESULT |X|-|Y|= - ZERO AND R7,R7,#0 ;0 IF RESULT |X|-|Y|= 0 STI R7,ANS2 ; RESULT |X|-|Y| ANS2 .FILL x3125 HALT .END

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago