A good answer might be:

Yes. However, the stack may grow as the subroutine executes. But the frame pointer for the subroutine does not change. The stack pointer ($sp) is always equal to the top of stack.

Sample Code

Imagine that the following statement is part of the subroutine whose stack frame is at right:

a = b + i + j;

This is how a compiler might implement that statement:

lw    $t0,8($fp)     # get b
lw    $t1,4($fp)     # get i
lw    $t2,0($fp)     # get j
addu  $t3,$t0,$t1    # b + i
addu  $t3,$t3,$t2    # b + i + j
sw    $t3,12($fp)    # a =    

 

QUESTION 5:

Play compiler: translate the following statement into assembly language:

a = a + 1;