2024-09-30 22:50:22 +00:00
|
|
|
# Copyright (c) 2024 Freya Murphy
|
|
|
|
|
|
|
|
# file: fncall.asm
|
|
|
|
# test: should return value from function call
|
|
|
|
|
|
|
|
.text
|
|
|
|
.align 2
|
|
|
|
.globl main
|
|
|
|
|
|
|
|
result:
|
|
|
|
move $t0, $a0
|
|
|
|
move $v0, $t0
|
|
|
|
jr $ra
|
2024-10-01 22:22:10 +00:00
|
|
|
nop
|
2024-09-30 22:50:22 +00:00
|
|
|
|
|
|
|
main:
|
|
|
|
# save ra on stack
|
|
|
|
addi $sp, $sp, -4
|
|
|
|
sw $ra, 0($sp)
|
|
|
|
|
|
|
|
# set return to 17
|
|
|
|
li $a0, 17
|
|
|
|
jal result
|
2024-10-01 22:22:10 +00:00
|
|
|
nop
|
2024-09-30 22:50:22 +00:00
|
|
|
|
|
|
|
# pop ra from stack
|
|
|
|
lw $ra, 0($sp)
|
|
|
|
addi $sp, $sp, 4
|
|
|
|
|
|
|
|
# return result
|
|
|
|
jr $ra
|
2024-10-01 22:22:10 +00:00
|
|
|
nop
|