From 6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 Mon Sep 17 00:00:00 2001 From: Elizabeth Alexander Hunt Date: Thu, 2 Jul 2026 11:55:17 -0700 Subject: Init --- Homework/cs5300/hw-MIPS/code/fee.asm | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Homework/cs5300/hw-MIPS/code/fee.asm (limited to 'Homework/cs5300/hw-MIPS/code/fee.asm') diff --git a/Homework/cs5300/hw-MIPS/code/fee.asm b/Homework/cs5300/hw-MIPS/code/fee.asm new file mode 100644 index 0000000..c38b5d6 --- /dev/null +++ b/Homework/cs5300/hw-MIPS/code/fee.asm @@ -0,0 +1,44 @@ +.text + +.globl main +main: + # put 3 and 4 on the stack using the register $sp + subi $sp, $sp, 8 + li $s0, 3 + li $s1, 4 + + sw $s0, 0($sp) + sw $s1, 4($sp) + + # call fee. You'll probably want to use the jal instruction to + # store the current address in $ra + + jal fee + + # load results from stack to registers + lw $a0, 0($sp) + addi $sp, $sp, 4 + # print result + li $v0, 1 + syscall + + # exit + li $v0, 10 + syscall +fee: + # copy a and b from stack to local registers + lw $s1, 4($sp) + lw $s0, 0($sp) + + # add a and b + add $t0, $s1, $s0 + + # place result on stack + addi $sp, $sp, 4 # No need to keep $sp allocated for two words when we're just returning a result + sw $t0, 0($sp) + + # return using jr instruction + jr $ra + +# Start .data segment (data!) +.data -- cgit v1.3