#----------------------------------------------------------------------------# # example10.a # # Joe Schmoe # Purpose: show how procedures work, version 1 # Input: none # Output: 5+10 = 15 #----------------------------------------------------------------------------# .data hello: .asciiz "\nProcedure example\n\n" ansis: .asciiz "Sum is: " endl: .asciiz "\n" #----------------------------------------------------------------------------# .text .globl main main: li $v0, 4 la $a0, hello syscall # Set up actual arguments li $a0, 5 li $a1, 10 # Here is the procedure call (adder) jal adder # Print out answer move $t0, $v0 # store result temporarily ("result") li $v0, 4 # because $v0 is needed for output la $a0, ansis syscall move $a0, $t0 li $v0, 1 syscall # Print out endl (twice) li $v0, 4 la $a0, endl syscall la $a0, endl syscall done: li $v0, 10 syscall #----------------------------------------------------------------------------# # Procedure adder .data inpro: .asciiz "In procedure\n" .text adder: add $v0, $a0, $a1 j $ra # jump back to main's address