Question: Problem 3 The following program is supposed to calculate the sum of absolute values of two numbers and stores the sum in R 1 The

Problem 3
The following program is supposed to calculate the sum of absolute values of two numbers and stores the sum in R1 The subroutine at the label "ABS" finds the absolute value of the argument. Now there is a mistake in it, can you identify the mistake?
ORIG x3000; Instructions start at x3000
AND R1, R1, #0 ; Clearing R1
LD R3, VAL1
LD R5, VAL2
q, ; Prepare argument VAL1(fill)
JSR ABS
; Call subroutine ABS
ADD R1, R2, #0 ; Add Abs(VAL1) to R1q, ; Prepare argument VAL2(fill)
JSR ABS
; Call subroutine ?ABS
ADD R1, R2, R2
; Add Abs(VAL2) to R1
HALT q,(fill)
ABS ST q,, SaveR
; Argument passed in register q,(fill)
ADbar(D)2,R2, #0
; Save register q,
BRzp NEXT
NOT R1, R2
ADD R2, R1, #2
NEXT LD q,, SaveR
; Restore register q,(fill)
; Value is returned in register q,(fill)
; Values
SaveR .FILL x0000
VAL1. FILL x0007;7
VAL2. FILL xFFF9; ;-7
.END
a. Fill in the blanks in the above program at all places indicated by "(fill)".
c. What might the error be? Indicate it in the code above.
b. What is the value in register R1 at the end of program execution?
Problem 3 The following program is supposed to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!