go to previous page   go to home page   go to next page

Answer:

A prolog is required to push $ra


Prolog

If the subroutine uses an S it must push it. But this subroutine can be written without S registers.

## maxInt -- compute the maximum of two integer arguments
##
## Input:
## $a0 -- a signed integer
## $a1 -- a signed integer
##
## Returns:
## $v0 -- maximum

         .text
         .globl maxInt

maxInt:
          # save return address
          sub    $sp,$sp,4    # push $ra
          sw     $ra,($sp)

          # body
          move   $v0,$a0          # max = $a0
          bgt    $a0,$a1,endif    # if $a1 > $a0  
          nop
          move   $v0,$a1          #    max = $a1
endif:                            # endif 
          # epilog
           
  

The body computes the maximum of the two arguments and puts it in $v0.


QUESTION 13:

According to the rules of Stack-based Linkage ConventionStack-based Linkage, what should the epilog of this subroutine do?


go to previous page   go to home page   go to next page