The point
Draw the activation record you expect, then hold the generated assembly against it. This is the activity that makes function calls stop being magic.
Do this
- Draw the frame you expect for
Label every slot with its offset and give the total size. Compare your drawing against the general activation record in the notes: which of Dragon's fields does yours have, and which does it omit? For each omission, say why this language does not need it.int addUp(int a, int b) { int t; t = a + b; return t; } - Compile it without
-q, find the reported frame size and symbol table, and reconcile. - Read the prologue and epilogue and account for every instruction. There should be no line you cannot explain.
- Sabotage the epilogue. Comment out the
lw $rarestore. Predict where control goes, then run it. - Sabotage differently. Restore that, and make
returnfall through instead of jumping to the epilogue. Test with a function having areturnin the middle. Explain the result. - Draw the stack at maximum depth for
fact(3). How many frames? What is in each$raslot? Confirm against the activation tree idea from the notes.
Deliverable
Your predicted frame beside the compiler's, with the omitted-field analysis; an annotated prologue and epilogue; a paragraph for each sabotage; and the fact(3) stack diagram.