go to previous page   go to home page   go to next page hear noise

Answer:

lw $t5,12( $fp )

Sample Code

stack frame

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 =    

The particular registers used to temporarily hold values from the local variables are arbitrary. In another section of code, a different register might be used with variable b than is used here.


QUESTION 5:

Play compiler: translate the following statement into assembly language:

a = a + 1;

Use register $t0 to temporarily hold the value in a.