anyway, this time I only made the SPIM code, don't have time to modify it for MIPS since I have to start with my Interruption Handler now (only supposed to handle external interrupts so far), and that might take some more time.
SPIM version
Code: Select all
.data
sSize = 32
sFac = 28
sRa = 24
Sum: .word 1
Fac: .word 4
.text
.globl main
main:
la $t0, Sum
lw $s0, ($t0)
lw $t1, Fac
lw $s1, Fac
facrec:
subu $sp, $sp, sSize
sw $t1, sFac($sp)
sw $ra, sRa($sp)
beq $t1, 1, facreturn
sub $t1, $t1, 1
jal facrec
facreturn:
lw $t0, sFac($sp)
lw $ra, sRa($sp)
mul $s0, $s0, $t0
addu $sp, $sp, sSize
beq $t0, $s1, printout
j $ra
printout:
move $a0, $s0
li $v0, 1
syscall
end:
li $v0, 10
syscall