有人可以告诉我下面的递归代码有什么问题。它应该是十进制到二进制函数的递归函数。我只是看不出有什么问题。我是MIPS的新手,所以我并不完全了解所有内容,但根据我的理解,这就是我所得到的。 我硬编码了一个数字,我应该得到输出101000但它不会加载任何信息。
.data
msg1:.asciiz "Output (40) = "
.text
.globl main
la $a0,msg1 # load string as parameter
li $v0, 4 # load operation "print string"
syscall # request "print string" for msg1
addi $t0, $zero, 40
move $a0, $t0
li $t2, 2
jal d2b
add $a0, $v0, $zero # load the value of $v0 into $a0
li $v0, 1 # load operation "print integer"
syscall # request "print integer"
d2b: li $t1, 0 # t1 = 0
bgt $a0, $t1, skip # if a0 > t1 no
li $v0, 0 # load v0 as 0
jr $ra # print this shit out
skip: subu $sp, $sp, 32 # sp down 32
sw $ra 20($sp) # save $ra
sw $fp, 16($sp) # save $fp
addiu $fp, $sp, 28 # set up $ fp
sw $a0, 0($fp) # save n
divu $a0, $t2 # divide n / 2
mflo $t3 # quota
mfhi $t4 # rem
move $a1, $t4 # rem keep
move $a2, $t3 # quota keep
addi $a1, 10 # adding rem + 10
jal d2b # call recursive —> d2b(n/2)
lw $a0, 0($fp) # restore n
multu $v0, $a2 # rem+10 *d2b(n/2)
lw $ra, 20($sp) # load $ra
lw $fp, 16($sp) # load $fp
addiu $sp, $sp, 32 # pop stack
jr $ra # return