Assembly 尝试分配变量时出现MIPS程序集分析错误

Assembly 尝试分配变量时出现MIPS程序集分析错误,assembly,syntax-error,mips,spim,Assembly,Syntax Error,Mips,Spim,我的MIPS汇编代码有问题。 它在li$t4、$0行(实际代码的第四行)中显示了一个语法错误。 你能帮我解决吗 .data .globl funcall1 .globl funcall2 .text funcall1: lw $t1, 0($a0) # load the 1st argument - shows how many there are addiu $t2, $t1, -1 #t2 stores how m

我的MIPS汇编代码有问题。 它在li$t4、$0行(实际代码的第四行)中显示了一个语法错误。 你能帮我解决吗

    .data

    .globl funcall1
    .globl funcall2


    .text

funcall1:   
        lw $t1, 0($a0) # load the 1st argument - shows how many there are
        addiu $t2, $t1, -1 #t2 stores how many args
        addiu $t3, $t2, -4 #t3 stores how many args there will be apart from 4 main
        li $t4, $zero
        addiu $sp, $sp, -24 # make stack frame
        bgezal $t3, SETSTACK 
        addiu $sp, $sp, $t4 # make stack frame
        sw $ra, 16($sp) # save where to return

        # 3:0xAAAA:0:12:0:7 format of FET


        lw $v0, 4($a0) # load the op-comand or value into the return value
        lw $s0, $a0 # save FET for future reference
        jal EXPRESSION
        bgezal $t3, ADDMOREARGS

        lw $a0, $s1 # return the first value to a0

        jal $t0

        lw $ra, 16($sp) # restore $ra
        addiu $sp, $sp, 24  # restore $sp

        jr $ra # return

funcall2:                   # main function in file
                        # Arguments $a0 is address of input FET

        jr $ra           # return

SETSTACK:   
        addiu $sp, $sp, -24 # make stack 
        sw $ra, 16($sp) # save where to return
        mul $t4, $t3, 4 # this is how many extra bytes wil be needed
        div $t4, 8
        bne $hi, 0, ADDFOUR # if size not divisible by 8, add 4.
        mul $t4, $t4, -1

        lw $ra, 16($sp) # restore $ra
        addiu $sp,$sp,24  # restore $sp

        jr $ra # return

ADDFOUR:
        addiu $sp, $sp, -24 # make stack 
        sw $ra, 16($sp) # save where to return
        addiu $t4, $t4, 4 # t4 += 4
        lw $ra, 16($sp) # restore $ra
        addiu $sp,$sp,24  # restore $sp

        jr $ra # return 

EXPRESSION: 
        addiu $sp, $sp, -24 # make stack 
        sw $ra, 16($sp) # save where to return

        lw $t0,  4($s0) # save the operand
        lw $s1, 12($s0) # free a0 for addmoreargs, save the first value in s1 as well
        lw $a0, 12($s0) # save first value in a0
        lw $a1, 20($s0) # second value
        lw $a2, 28($s0) # third value
        lw $a3, 32($s0) # fourth value

        la $s9, 40($s0) # save the rest of address
        lw $s8, 40($s0) # save the rest of data
        la $s7, $a3     # save the next place for an argument
        addiu $s7, $s7, -8

        lw $ra, 16($sp) # restore $ra
        addiu $sp,$sp,24  # restore $sp

        jr $ra # return


ADDMOREARGS:

        sw $s7, 4($s8)
        lw $s8, 8($s8) # jump thorugh the data
        addiu $t3, $t3, -1
        bgezal $t3, ADDMOREARGS

另外,我知道代码可能还有一些问题,我只是开始调试…

$zero
是一个寄存器,您不能将它与
li
一起使用,后者是
立即加载
。使用
li$t4,0
move$t4,$zero
伪指令。

li的目的是立即加载<代码>$zero是一个寄存器,不是立即数。您要查找的可能是
move$t4,$zero


代码中还有其他类似的问题。例如,
addiu$sp,$sp,$t4
(这似乎没有必要,因为你应该在
$t4
中加零)。

谢谢迈克尔和杰斯特!Michael,$t4可能会在SETSTACK中更改,因此根据情况,我会在SETSTACK中添加0或存储在该点的其他内容。