Quiz - Sept. 19, 2008

Write procedure prolog and epilog code that saves $ra, $s0, and $s1 and restores them --- using the MIPS register conventions.

Scoring:
2 points: present (paper turned in)
3 points: a serious but wrong attempt
4 points: mostly right
5 points: almost entirely correct, possibly with minor problems

Solution:

prolog:
    addiu $sp, $sp, -12
    sw    $ra, 0($sp)
    sw    $s0, 4($sp)
    sw    $s1, 8($sp)

epilog:
    lw    $s1, 8($sp)
    lw    $s0, 4($sp)
    lw    $ra, 0($sp)
    addiu $sp, $sp, 12
    jr    $ra