的方案與預期的輸出,但具有以下哪些錯誤與此MIPS/QtSPIM While循環代碼
代碼
.data
.text
.globl main
main:
addi $t0, $t0, 0 # i = 0
addi $t2, $0, 10 # n = 10
j WhileCond # goto WhileCond
WhileLoop:
li $v0, 1 # print_int
move $a0, $t0 # $a0 = i (print i)
addi $t0, $t0, 1
syscall
WhileCond:
blt $t0, $t2, WhileLoop # if i < 10 goto WhileLoop
j $ra
用戶文本段
[00400000] 21080000 addi $8, $8, 0 ; 10: addi $t0, $t0, 0 # i = 0
[00400004] 200a000a addi $10, $0, 10 ; 11: addi $t2, $0, 10 # n = 10
[00400008] 08100007 j 0x0040001c [WhileCond] ; 12: j WhileCond # goto WhileCond
[0040000c] 34020001 ori $2, $0, 1 ; 15: li $v0, 1 # print_int
[00400010] 00082021 addu $4, $0, $8 ; 16: move $a0, $t0 # $a0 = i (print i)
[00400014] 21080001 addi $8, $8, 1 ; 17: addi $t0, $t0, 1
[00400018] 0000000c syscall ; 18: syscall
[0040001c] 010a082a slt $1, $8, $10 ; 21: blt $t0, $t2, WhileLoop # if i
[00400020] 1420fffb bne $1, $0, -20 [WhileLoop-0x00400020]
[00400024] 03e00008 jr $31 ; 23: j $ra
錯誤運行錯誤
Exception occurred at PC=0x00000000
Bad address in text read: 0x00000000
Instruction references undefined symbol at 0x800001dc
[0x800001dc] 0x143a0000 bne $1, $26, 0 [ok_pc-0x800001d8]
甚至不會安裝。 * j $ ra *不是有效的MIPS指令。你的意思是* jr $ ra *。 – m0skit0
@ m0skit0,你是對的... –
帶*號的JR $ RA *它運行在MARS模擬器罰款(除了跳躍到$ RA時$ RA沒有分配的價值和崩潰)。這是我想你得到這個錯誤的原因是:在異常PC = 00000000地址錯誤發生在文本閱讀:00000000 – m0skit0