Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Recall that the call instruction pushes the address of the next instruction after the call onto the stack, at the same time as it loads
Recall that the call instruction pushes the address of the next instruction after the
call onto the stack, at the same time as it loads the address of the function being called into the
program counter. This problem asks about the return addresses in this code. Hint: The best way
to find the address of an instruction is to run the program under gdb set a breakpoint in main is
fine and then use the disassemble command, which lists the address of each instruction next to
the assembly instruction. You can give the name of a function as an argument to disassemble to
get list only the code for that function.
a What return address is pushed by the call recexp in main? It should be of the form
x
b What return address is pushed on the stack by the recursive call in recexp?
c What return address is pushed on the stack by call to recmul in recexp
#include
#include
compute xy with addition
uintt recmuluintt auintt b
if a b
return ;
else if a
return b;
else
return b recmulab;
compute x to the yth power using only addition
uintt recexpuintt xuintt y
if y
return ;
else if y
return x;
else
return recmulxrecexpxy;
int main
printfrecexp returned lu
recexp;
return ;
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