Question

1. Based on the following code segment what values are in the runtime stack immediately after the fourth time the instruction
can someone explain how you get the answer to this question?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE :- Final answer is in BOLD format

Explanation :-
Whenever a function call statement is called; the stack pointer is decreased and values are stored such as return address and arguement values.So,accordingly stack is decreased. While returning back to the caller; the stack pointer is increased and return value address is retrieved and control jumps back to the caller.

So, for first time when jal Fact is called from .text

STACK :-
2000 (return address)
7 ($a0) - stack pointer is here now

1st time when beq $t0,$zer0,Rec
Again,Fact is called;
so,now
STACK :-
2000 (return address)
7 ($a0)
5000 (return address)
6 (new $a0) - stack pointer is here now

2nd time when beq $t0,$zer0,Rec
Again,Fact is called;
so,now
STACK :-
2000 (return address)
7 ($a0)
5000 (return address)
6 ($a0) -
5000 (return address)
5 (new $a0) - stack pointer is here now

3rd time when beq $t0,$zer0,Rec
Again,Fact is called;
so,now
STACK :-
2000 (return address)
7 ($a0)
5000 (return address)
6 ($a0) -
5000 (return address)
5 ($a0)
5000 (return address)
4 (new $a0) - stack pointer is here now

4th time when beq $t0,$zer0,Rec
Again,Fact is called;
so,now
STACK :-
2000 (return address)
7 ($a0)
5000 (return address)
6 ($a0) -
5000 (return address)
5 ($a0)
5000 (return address)
4 ($a0)
5000 (return address)
3 (new $a0) - stack pointer is here now

Add a comment
Know the answer?
Add Answer to:
can someone explain how you get the answer to this question? 1. Based on the following code segment what values are in the runtime stack immediately after the fourth time the instruction labeled...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT