Question

Say R1 = 5, R2 = 6. Push or pop the following registers to the stack...

Say R1 = 5, R2 = 6. Push or pop the following registers to the stack and see if they are equal. Specify the top and bottom of the stack.

push {r2, r1}

pop{r2, r1}

AND

push {r1, r2}

pop{r2}

pop{r1}

AND

Push {r1}

Push{r2}

Pop {r1, r2}

Are these operations equivalent?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

push {r2, r1}

So the stack contains

r2     6

r1     5

The top of the stack contains 6 and the bottomof the stack contains 5

pop{r2, r1}

First 6 is popped and then 5 is popped

2)

push {r1, r2}

So the stack contains

r1     5

r2     6

The top of the stack contains 5 and the bottom of the stack contains 6

pop{r2, r1}

r2 cannot be popped because the top of the stack contains r1

3)

push {r1}

So the stack contains

r1     5

push {r2}

So the stack contains

r2     6

r1     5

The top of the stack contains 6 and the bottom of the stack contains 5

pop{r1, r2}

r1 cannot be popped because the top of the stack contains r2

So these operations are not equivalent

Add a comment
Know the answer?
Add Answer to:
Say R1 = 5, R2 = 6. Push or pop the following registers to the stack...
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