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
The following program is supposed to calculate the sum of absolute values of two numbers and stores the sum in R 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 ; Instructions start at
AND R R # ; Clearing R
LD R VAL
LD R VAL
; Prepare argument VALfill
JSR ABS
; Call subroutine ABS
ADD R R # ; Add AbsVAL to R ; Prepare argument VALfill
JSR ABS
; Call subroutine
ADD R R R
; Add AbsVAL to R
HALT fill
ABS ST SaveR
; Argument passed in register fill
#
; Save register
BRzp NEXT
NOT R R
ADD R R #
NEXT LD SaveR
; Restore register fill
; Value is returned in register fill
; Values
SaveR FILL
VAL FILL ;
VAL FILL xFFF; ;
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 at the end of program execution?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
