Assembly MIPS";未对齐地址,例外情况5“;错误
我是一个使用SPIM MIPS模拟器的noob。Assembly MIPS";未对齐地址,例外情况5“;错误,assembly,mips,spim,Assembly,Mips,Spim,我是一个使用SPIM MIPS模拟器的noob。 当我试图将26个单词的数组初始化为0时,在title X中出现了26次错误。我已将问题隔离为存储字操作sw$t0,0($s3),但不知道我做错了什么 守则: .data theArray: .space 104 theArraySz: .word 26 .text .globl main main: move $t0, $zero la $s3, theArray lw $s4, theA
当我试图将26个单词的数组初始化为0时,在title X中出现了26次错误。我已将问题隔离为存储字操作
sw$t0,0($s3)
,但不知道我做错了什么
守则:
.data
theArray: .space 104
theArraySz: .word 26
.text
.globl main
main:
move $t0, $zero
la $s3, theArray
lw $s4, theArraySz
add $t2, $zero
initLoop:
beq $t2, $s4, initEnd
sw $t0, 0($s3)
addi $s3, $s3, 4
addi $t2, $t2, 1
j initLoop
initEnd:
jr $ra
确保阵列的地址与32位字边界对齐。如果您能够单步执行程序,则可以检查地址,并在第一条
la
指令后检查$s3
的值
有关对齐的文档,请参阅,以及可用于强制对齐的
.align
指令。好的,我现在了解我的步骤,我看到在la之后,$s3保留地址268500992:“Reg 19=0x10010000(268500992)”谢谢,在“.data”之后添加“.align 2”解决了问题(请不要介意前面的注释)。