sting of an assembly subroutine MySum written for the PIC24FJ64GA002 which recur
ID: 3184873 • Letter: S
Question
sting of an assembly subroutine MySum written for the PIC24FJ64GA002 which recursively computes the sum of the first n integers (1, 2, 3, ...n) is shown below. At the time the subroutine is called (w8) 0x0010 and (w15) = 0x800 mysum mov.uw8, [w15++1 cpo.w bra dec.w rcall add. w bra w8 LE, L3 mysum 2 L3 mov.w 2 mov.w-15], w8 return The subroutine is invoked to compute the sum 1+2+3+4 as: w0 mov. #0x4, ; argument is passed in w0 rcall MySum Assume Fosc is 32 MHz for an instruction cycle time, Tcy, of 62.5 ns. (a) Register w15 is the stack pointer. How much stack is used (number of bytes) for a single call to subroutine MySum? What is put in each location of the stack? Explain. (b) The subroutine MySum computes the sum recursively. What is the total amount of data memory (bytes) used to compute the sum of 1+2+3+4? Data Memory Used- bytes (c) How long does it take to compute the sum 1+2+3+4 with this subroutine? Execution Time- uS (d) Where is the result computed by the subroutine MySum located when it is returned?Explanation / Answer
solution:
The designing and development of the assembly subroutine for the given stack pointer and its total amount of data memory is given as
A) The first step is to register the instruction set for indicating the different locations of the given stack element on the given stack for having a good storage regions,
Example:-
EQU $2C00
ORG $810
LDS #STACK
JSR MY_SUB
SWI
LDX #$2643
RTS
B) The next step is to apply the data memory access used for the number of bytes using the subroutine "MySup" for the given validation,
Example:- The Data memory used is 10 Bytes.
C) The final step is to calculate the sum of 1+2+3+4 for the given subroutine, by comparing both the array elements of the integer type,
Example:- 100 / 8 = 200 Microseconds
D)
Subroutine calls are made by using the jump instructions to transfer control to a subroutine. When a JMP is executed to the entry point of a subroutine, the address of the instruction following the JMP is put into the J register. Thus the J register has the return address for the subroutine call .Hence it is returned to (w15) and (w8)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.