3

次の 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 は、スタックの一番上にあるセンチネル値であることに注意してください。

編集:解決しました。スピムを満足させるようにラベル名を短くしました。根本的な問題が何であったかはよくわかりませんが、あるべきではないと思われる問題が発生している場合は、短いラベルに変更してください

4

0 に答える 0