mips/test/masm/fncall.asm

33 lines
380 B
NASM
Raw Normal View History

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
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
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
nop