In: Computer Science
Suppose the program counter (PC) is set to 0x30002000. Is it possible to use the jump (j) MIPS assembly instruction to jump directly to the instruction at 0x50003000? If yes, write the corresponding assembly instruction(s). If not, explain why and give other MIPS instruction(s) that can jump to this target address. (For this problem, assume that the instruction memory starts from 0x00000000 and goes to 0xFFFFFFFF.)
Consider the given data.
The Program counter is set to 0x30002000.
The jump (j) instruction, is a 32-bit instruction. It uses 6 bits for “opcode” and the remaining 26 bits for the “target address”.
While executing the jump statement, the 26-bit address transforms into a 32-bit address by shifting left by two bits and taking the upper order 4 bits of the program counter.
The program counter is set to 0x30002000. The binary is equivalent to
0000
0000 0011 0000 0000 0000 0010 0000 0000 0000.
The largest possible value of jump with the highest value in the
lower 26 bits is 0x3FFFFFFF.
The 26 bits are then shifted left by two bits to form the 28-bit value 0xFFFFFFFC.
Next,
the upper order four bits of the program counter, that is 0x2 are
appended to this 28-bit value to form the 32-bit value, that is
0x2FFFFFFFC.
Since, the address 0x2FFFFFFFC is the maximum size of jump, it is
not possible to jump (j) in MIPS to the address
0x50003000.
The jump instruction cannot change the upper four bits.
Therefore, for the jump (j) instruction, it is not possible to set the PC to the address as 0x50003000.