# subroutine call: b = fact( a )
# 7. No T registers to push
lw $a0,0($fp) # 8. Put argument into $a0
jal fact # 9. Jump and link to subroutine
# return from subroutine
# 10. No T registers to restore
sw $v0,4($fp) # b = fact( a )
main()
Next
main() does some routine things:
# print( b )
lw $a0,4($fp) # load b into $a0
li $v0,1 # print integer service
syscall
# end the print line
li $v0,4 # print string service
la $a0,lf # address of line feed
syscall
Finally, main() ends with a subroutine epilog.
# epilog
li $v0,10 # 11. return to QTSPIM
syscall
The data for the prompts is not stored on the stack.
.data
prompt1: .asciiz "enter an int:"
prompt2: .asciiz "factorial is:"
lf: .asciiz "\n"
How do the variables a and b differ
from the data prompt1 and prompt2?