1.简单的打印函数
.data
msg:.asciiz "Good morning!\n"
.text
main:
jal displayMsg
# tell system the program is done
li $v0,10 #return 0
syscall
displayMsg:
li $v0,4
la $a0,msg
syscall
jr $ra #return
2.带有输入参数和返回值的函数
.data
.text
main:
addi $a1,$zero,20
addi $a2,$zero,30
jal addNum
li $v0,1
move $a0,$v1
syscall
#return
li $v0,10
syscall
addNum:
add $v1,$a1,$a2
jr $ra