The subroutine starts with a prolog.
Subroutine Prolog (done by the subroutine at its beginning)
- Push
$raonto the stack.- Push onto the stack any registers
$s0-$s7that this subroutine might alter.
Subroutine Body
- The subroutine may alter any T or A register, or any S register that it saved in the prolog (step 4).
- If the subroutine calls another subroutine, then it does so by following these rules.
The subroutine prolog must push the return address.
If the subroutine uses an S
it must push it.
But this subroutine can be written without S registers.
The body computes the maximum of the two arguments
and puts it in $v0.
## 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
According to the rules of