    a = a + 1;

### A good answer might be:

    lw      $t0,12($fp)    # get a
    addiu   $t0,$t0,1      # a + 1
    sw      $t0,12($fp)    # a =

# Our Frame-based Linkage Convention

A real-world linkage convention allows many types of objects to go into a stack frame. Our rules are much simpler:

> Calling a Subroutine (done by the caller):

> > 1. Push any registers `$t0-$t9` that contain values that must be saved. Push the registers in numerical order.
> > 2. Put argument values into `$a0-$a3`.
> > 3. Call the subroutine using `jal`.

> Subroutine Prolog (done by the subroutine):

> > 4. Push `$ra` (always).
> > 5. Push the caller's frame pointer `$fp`.
> > 6. Push any of the registers `$s0-$s7` that the subroutine might alter.
> > 7. Initialize the frame pointer: `$fp = $sp - space_for_variables`. The "space for variables" is four times the number of local variables. (Remember that subtracting from $sp grows the stack).
> > 8. Initialize the stack pointer: `$sp = $fp.`

> Subroutine Body:

> > 9. At this point the stack looks like the picture at right.
> > 10. The subroutine may alter any "T" or "A" register, or any "S" register that it saved in the prolog.
> > 11. The subroutine refers to local variables as `disp($fp)`
> > .
> > 12. The subroutine may push and pop values on the stack using `$sp`.
> > 13. If the subroutine calls another subroutine, then it does so by following these rules.

> Subroutine Epilog (done at the end of the subroutine):

> > 14. Put return values in `$v0-$v1`
> > 15. `$sp = $fp + space_for_variables`.
> > 16. Pop any registers `$s0-$s7` that were previously saved in the frame.
> > 17. Pop the caller's frame pointer into `$fp`.
> > 18. Pop `$ra` (always).
> > 19. Return to the caller using `jr $ra`.

> Return from a Subroutine (done by the caller):

> > 20. Pop any registers `$t0-$t9` that the caller previously pushed.

### QUESTION 6:

When the caller gets control back, are its frame pointer and stack pointer the same as when it called the subroutine?