Assembly MIPS Asm-第二个操作数无效/非法
这里我要做的是计算一个偏移量,然后将它添加到数组中,在数组中的那个位置存储一个值。我见过这种情况:Assembly MIPS Asm-第二个操作数无效/非法,assembly,mips,Assembly,Mips,这里我要做的是计算一个偏移量,然后将它添加到数组中,在数组中的那个位置存储一个值。我见过这种情况: board: .space 36 move $s0, $a0 # Save our arg (cell offset) in $s0 li $t0, 6 # Store the size of the board in $t0 div $s0, $t0 # Cell Offset / Bo
board: .space 36
move $s0, $a0 # Save our arg (cell offset) in $s0
li $t0, 6 # Store the size of the board in $t0
div $s0, $t0 # Cell Offset / Board Size
mflo $s1 # $s1 is our cell row index
mfhi $s2 # $s2 is our cell col index
lb $t1, board + 0($s0) # Load current cell's value in $t1
下一行,
lb $t1, board + 0($s0) # Load current cell's value in $t1
在尝试编译时导致以下错误:
Error: Invalid/illegal second operand.
我在其他MIPS汇编程序中也看到过这种情况,所以我不确定为什么它不起作用。您只能在汇编时执行常量操作
board+0($s0)
不是一个常量操作,因为汇编程序无法知道0($s0)
将具有什么值,因为它是一个依赖于运行时的值。您只能在汇编时执行常量操作board+0($s0)
不是一个常量操作,因为汇编器无法知道0($s0)
将具有什么值,因为它是一个依赖于运行时的值。您的汇编器不够聪明,无法判断board+0
是使用wrt寄存器$s0>的置换
解决方法是计算该位移,即:
lb $t1, board($s0) # Load current cell's value in $t1
在这里,我删除了board+0
中的+0
,因为位移完全相同。您的汇编器至少应该了解该格式,即标签(寄存器)您的汇编器不够聪明,无法判断板+0
是使用wrt寄存器$s0
的替代品
解决方法是计算该位移,即:
lb $t1, board($s0) # Load current cell's value in $t1
在这里,我删除了board+0
中的+0
,因为位移完全相同。你的汇编程序应该至少理解格式、标签(寄存器)你忘了提到你使用的汇编程序。你忘了提到你使用的汇编程序。