所以我必須爲我的大學編寫一個代碼,用MIPS比較A [i] [j]和B [i] [j](A和B是4x4陣列),並將最大的數字放在A [i] [j]中,最小的放在B [i] [j]中。這是我已經寫的代碼:MIPS SPIM-CACHE模擬器lw異常
.data
Ann: .word 4, 6, 10, 5, 4, 7, 10, 8, 3, 6 ,7, 12, 3, 2, 15, 6
Ban: .word 3, 7, 5, 6, 5, 12, 18, 9, 7, 6, 12, 4, 2, 7, 8, 4
.text
.globl main
main: la $t0, Ann # $t0 represents start address of A[i][j]
la $t1, Ban # $t1 represents start address of B[i][j]
lw $s2,0($t0)
lw $s1,0($t1)
addi $s5, $zero, 4 # set maximum iteration to be 4
addi $s6, $zero, 0 # set i = 0
loopi: addi $s7, $zero, 0 # set j = 0
jal loopj # starts inner loopj
addi $s6, $s6, 1 # i++
bne $s5, $s6, loopi # continue loopi if i < 4
j finish
loopj: sll $t7, $s6, 2
add $t7, $t7, $s7
sll $t7, $t7, 2 # 4 * ((i * 4) + j)
add $t9, $t7, $s2 # address of A[i][j]
lw $t6, 0($t9) # value of A[i][j]
add $t4, $t7, $s1 # address of B[i][j]
lw $t5, 0($t4) # value of B[i][j]
slt $t8,$t6,$t5
beqz $t8,cont
add $t2,$zero,$t6
add $t6,$zero,$t5
add $t5,$zero,$t2
sw $t6,0($t4)
sw $t5,0($t9)
cont: addi $s7, $s7, 1 # j++
bne $s5, $s7, loopj # continue loopj if j < 4
jr $ra
finish: li $v0, 1
add $a0,$s5, $zero
syscall
當我嘗試運行它SPIM緩存中,我得到的指令「LW $ T6,O($ T9)#A的值異常[I] [j]「....什麼可能是錯誤的,我不知道:\