MIPS 中的 JUMP 指令
JUMP instruction in MIPS
我们在JUMP 指令中仅用26 位表示目标地址,因此该地址依赖于当前PC+4 值。
考虑我要跳转到的指令位于我的代码
处的情况
0010&[my_target = 26 位]&00
但我们会跳转到以 0011 开头的错误地址(至 0011&[my_target = 26 位]$00),因为 PC 已经递增到更改其第 4 位的值。
这种情况真的可能吗?
如果是,如何解决?
谢谢
Is this case really possible?
是的,是的。引用自 MIPS32™ 程序员架构
第二卷:MIPS32™ 指令集:
When the jump instruction is in the last word of a 256 MB
region, it can branch only to the following 256 MB region containing the branch delay slot.
If it is, how it can be solved?
将要跳转到的地址加载到寄存器中,然后使用jr
指令。
我们在JUMP 指令中仅用26 位表示目标地址,因此该地址依赖于当前PC+4 值。 考虑我要跳转到的指令位于我的代码
处的情况0010&[my_target = 26 位]&00
但我们会跳转到以 0011 开头的错误地址(至 0011&[my_target = 26 位]$00),因为 PC 已经递增到更改其第 4 位的值。
这种情况真的可能吗?
如果是,如何解决?
谢谢
Is this case really possible?
是的,是的。引用自 MIPS32™ 程序员架构 第二卷:MIPS32™ 指令集:
When the jump instruction is in the last word of a 256 MB region, it can branch only to the following 256 MB region containing the branch delay slot.
If it is, how it can be solved?
将要跳转到的地址加载到寄存器中,然后使用jr
指令。