Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 ;
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started