Question: Please do this problem, particular the second subroutine . orig x 3 0 0 0 LD R 6 , top _ stack _ addr ;
Please do this problem, particular the second subroutine
orig x
LD R topstackaddr ; Load the stack pointer
; Test harness
;
LD R LOADFILLVALUE ; Load the address of the first subroutine
JSRR R ; Call the first subroutine
ADD R R # ; Increment the value in R by
LD R OUTPUTASDECIMAL ; Load the address of the second subroutine
JSRR R ; Call the second subroutine
LDR R R # ; Restore R from the stack
ADD R R # ; Adjust the stack pointer
HALT
; Test harness local data
;
topstackaddr fill xFE
LOADFILLVALUEfill x
OUTPUTASDECIMALfill x
END
;
; Subroutine: LOADFILLVALUE
; Parameter: None
; Postcondition: Loads a hardcoded value x into R
; Return Value: The hardcoded value in R
;
ORIG x
; Backup registers
ADD R R #
STR R R # ; Save R to the stack
; Code
LD R FILLVALUE ; Load hardcoded value into R
; Restore registers
LDR R R # ; Restore R from the stack
ADD R R # ; Adjust the stack pointer
RET
FILLVALUE FILL x
END
;
; Subroutine: OUTPUTASDECIMAL
; Parameter: Fixme
; Postcondition: Fixme
; Return Value: Fixme
;
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
