MIPS while循环错误

时间:2011-11-21 09:18:09

标签: loops mips spim

我在使用以下mips代码时遇到了一些问题:

    li $t0, -1
    li $t5, 0
    countNumberofVariables:
        addi $t0, $t0, 1
        beq $t0, $t8, endCount
        add $t1, $t0, $t9
        lb $t1, ($t1)
        li $t2, 10
        beq $t1, $t2, endCount
        li $t2, 13
        beq $t1, $t2, endCount
        li $t2, 97
        blt $t1, $t2, countNumberofVariables
        li $t2, 122
        bgt $t1, $t2, countNumberofVariables
        li $t2, -1
        stackScan:
            addi $t2, $t2, 2
            add $t3, $sp, $t2
            lb $t3, ($t3)
            beq $t3, $t1, countNumberOfVariables
            li $t4, 64
            bne $t4, $t3, stackScan
            addi $sp, $sp, -2
            sb $t1, ($sp)
            li $t1, 0
            sb $t1, 1($sp)
            addi $t5,$t5,1
            j countNumberofVariables

    endCount:
    move $a0, $t5
    li $v0, 1
    syscall

    j main

我要做的是计算字符串中唯一的小写字母数($ t9中的地址,$ t8中的长度)。我遇到的问题是,当在SPIM 7.3下运行时,我得到了这个错误:

Instruction references undefined symbol at 0x00400108
[0x00400108]    0x11180000  beq $8, $24, 0 [endCount-0x00400108]; 87: beq $t0, $t8, endCount

变量是:

$t0, outer loop counter
$t5, number of unique lowercase letters in string
$t1, the character at the current location in the string
$t2, random variable in outer loop, loop counter in inner loop
$t3, the character at the current location on the stack in the inner loop
$t4, random variable

请注意,魔术常量64是堆栈顶部的标记值。

编辑:已解决。我将标签名称更改为更短,这似乎满足了spim。不太确定底层问题是什么,但是如果你遇到的问题似乎不应该有问题,那就改成更短的标签

0 个答案:

没有答案
相关问题