我正在尝试遍历数组并找到最大值(int)然后打印出该值。使用下面的代码我得到一个运行时错误,说
"在pc = 0x00400034
时发生异常inst / data fetch中的未对齐地址:0x10010001
尝试在0x80000180"
执行非指令.globl __start
.data
purchases: .word 5,10,15,20,25,7
.text
__start:
li $t1, 0 # the "i" variable
li $t2, 6 # amount of elements in the array
lw $t0 , purchases+0 #Read the value of the element [0] into $t0
j For_loop
print_int:
li $v0, 1
syscall
li $v0, 10
syscall
For_loop:
blt $t2,$t1,End_loop
lw $t4, purchases($t1)
ble $t0 , $t4, True
add $t1, $t1, 1 #Increment
j For_loop
True:
lw $t0 , purchases($t1)
add $t1, $t1, 1 #Increment
j For_loop #loop
End_loop:
move $a0, $t0
j print_int
li $v0, 10
syscall
感谢所有反馈!