I'm using Computer Organization and Design, 3rd ed (David Patterson and John Hennessy) for an electrical engineering course (that I have to take to graduate) in computer systems architecture. Assigned as homework, from the For More Practice section, is problem 2.28:
Here is some stylized MIPS code associated with procedure call:
r:... # R/W $s0,$v0,$t0,$a0,$sp,$ra,mem
... ### PUSH REGISTER(S) TO STACK?
jal e # Call e
... # R/W $s0,$v0,$t0,$a0,$sp,$ra,mem
jr $ra # Retur to call of r?
e:... # R/W $s0,$v0,$t0,$a0,$sp,$ra,mem
jr $ra # Return to r
What does r have to push on the stack before jal e?
A: Nothing
B: 1 of ($s0,$sp,$v0,$t0,$a0,$ra)
C: 2 of ($s0,$sp,$v0,$t0,$a0,$ra)
D: 3 of ($s0,$sp,$v0,$t0,$a0,$ra)
E: 4 of ($s0,$sp,$v0,$t0,$a0,$ra)
F: 5 of ($s0,$sp,$v0,$t0,$a0,$ra)It took me a good solid hour of thinking to understand this question. It's asking, of the list given in the options, how many of those registers should be saved?
Talk about horrible question.
If you want the answer, by convention, you'd need to save $s0, $v0, $a0, and $ra. Four registers, so the correct answer is E.
This book has a ridiculous amount of errors... Were their proofreaders doing anything? It's useful to have the publisher's list of errata handy as a bookmark.
These other articles I've written may be interesting to you as well:
Recent comments
3 weeks 2 days ago
8 weeks 10 hours ago
8 weeks 12 hours ago
9 weeks 4 days ago
9 weeks 6 days ago
11 weeks 5 days ago
11 weeks 6 days ago
12 weeks 8 hours ago
12 weeks 1 day ago
12 weeks 2 days ago