在MIPS中,为什么跳转指令可以将程序计数器设置为28位目标地址 [英] In MIPS, why can a jump instruction set the program counter to a 28-bit target address
问题描述
在 MIPS 中,32 位跳转指令由 6 位操作码和 26 位目标(目标)地址组成,我们希望将程序计数器设置为目标(目的)地址.
In MIPS, a 32-bit jump instruction consists of 6-bits for the opcode and 26-bits for the target (destination) address that we want to set the program counter to.
但是,可以将程序计数器设置为 28 位目标地址.如果跳转指令只能容纳 26 位,这怎么可能?
However, it is possible to set the program counter to a 28-bit target address. How is this possible if we can only fit 26-bits in the jump instruction?
推荐答案
MIPS 上的指令总是 4 字节对齐的,因此任何有效目标地址的低 2 位只能为零.因此,跳转指令中指定的 26 位总是隐式左移 2 个位置,从而设置 PC 的低 28 位.
Instructions on MIPS are always 4-byte aligned, so the low 2 bits of any valid target address can only be zero. Thus, the 26 bits specified in jump instructions are always implicitly left shifted of 2 positions, hence setting the low 28 bits of the PC.
这篇关于在MIPS中,为什么跳转指令可以将程序计数器设置为28位目标地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!