Assembly 无法在MIPS中存储对内存的应答

Assembly 无法在MIPS中存储对内存的应答,assembly,mips,mips32,Assembly,Mips,Mips32,我试图在MIPS中编写一个函数,它将接收字符串并返回字符串中的字符数。这就是我目前所拥有的 # Program to calculate string length of any given string .data mystring: .asciiz "Hello, World!" answer: .word 0 .text .globl main main: la $a0, myst

我试图在MIPS中编写一个函数,它将接收字符串并返回字符串中的字符数。这就是我目前所拥有的

# Program to calculate string length of any given string

            .data
mystring:   .asciiz "Hello, World!"
answer:     .word 0

            .text
            .globl main
main:       la      $a0, mystring   # Load base adress of the string into function argument

            jal     strlen          # jump to strlen and save position to $ra

            sw      $vo, answer     # Store the answer to memory

            li      $v0, 10         #exit
            syscall


strlen:     li      $v0, 0          # Initialize counter = 0

stringLoop: lb      $t0, 0($a0)     # Load first word of the string

            beq     $t0, $zero, end # if $t0 == '\0' then exit the loop

            addi    $a0, $a0, 1     # Increment the address (go to the next character)

            addi    $v0, $v0, 1     # Increment the counter

            b       stringLoop

end:        jr      $ra             # Return to main program

每次我尝试使用QtSpim运行它时,它都会在“sw$vo,answer”行中给我一个语法错误。有人能告诉我我的程序有什么问题吗?谢谢

语法错误通常是由打字错误引起的,就像您的情况一样。您意外地编写了
vo
而不是
v0

,可能QTspim汇编程序不愿意将其视为伪指令,并将其转换为
lui
+
sw
,其中包含32位绝对地址的两部分。使用
la
。如果将它放在
mystring
之前,则可以相对于先前加载到
$a0
中的指针对其进行寻址,但由于将它放在隐式对齐填充之后。(如果你愿意,你可以硬编码它的大小,例如,
addiu$s0,$a0,如果你的汇编程序允许,回答mystring
,在你的
strlen
销毁它的$a0输入之前保存一个指针)没有
vo
寄存器这样的东西,但是
v0
。也许是打字错误?哦,哈哈,或者那样就可以了。天哪,谢谢你,这是一个打字错误,解决了我的问题。也许有个男孩可以写一个答案。谢谢你,我花了将近30分钟就为了这个问题。我可能需要找到一个好的文本编辑器,它可以为MIPS程序集进行语法高亮显示。