Question: Suppose the stack pointer SP is initialized to 0 x 2 0 0 0 0 6 0 0 . A recursive function A recursive assembly
Suppose the stack pointer SP is initialized to x
A recursive function A recursive assembly code
int factorialint n;
int mainvoid
factorial;
return ;
int factorialint n
int f;
ifn
return ;
else
f nfactorialn;
return f;
x
x
x
x
xA
xC
xE
x
x
x
x
xC
AREA main, CODE, READONLY
EXPORT main
ENTRY
main PROC
MOV r #x
BL factorial
stop B stop
ENDP
factorial
PUSH r lr
MOV r r
CMP r #x
BNE NZ
MOVS r #x
loop POP r pc
NZ SUBS r r #
BL factorial
MUL r r r
B loop
END
Show the stack content when factorial is returned.
x
x
x
xC
x
x
x
xFC
xF
xF
xF
xEC
xE
xE
xE
xDC
xD
xD
xD
xCC
xC
xC
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
