我尝试执行以下操作:
# with $s6 holding i+j
andi $s7, $s6, 0x1 # (i + j) & 1 (to check if it's even)
if: bneq $s7, $zero, else
Run Code Online (Sandbox Code Playgroud)
但是它会产生错误...我做错了什么吗?
也许您的汇编器不喜欢0x1整数?
andi $s7, $s6, 1
bnez $s7, odd # branch if not-equal to Zero.
Run Code Online (Sandbox Code Playgroud)
或者,如果您的汇编器不喜欢寄存器的 ABI 名称,请使用寄存器编号?
andi $23, $22, 1 # $22=$s6 and $23=$s7
Run Code Online (Sandbox Code Playgroud)
如果您使用 MARS 或 SPIM Simulator,或者 clang 或其他普通的 MIPS 汇编器,则
andi $s7, $s6, 0x1可以很好地进行汇编。
注释andi没有添加任何内容,因此i+j注释不匹配
andi Rdest, Rsrc1, Imm
将寄存器 Rsrc1 和 Imm 中的整数进行逻辑与放入寄存器 Rdest。