I need help with the following MIPS machine assembly question: Consider the jump
ID: 3585665 • Letter: I
Question
I need help with the following MIPS machine assembly question:
Consider the jump instruction ' j ' destination_address
a) How many bits are allocated for the “destination_address”?
b) What range of addresses that we can reach using the number of bits you specified in Part (a). Before the jump, next instruction to be executed is PC+4.
c) Where do we derive the other bits to form a 32-bit word as a valid program counter (PC)?
d) If we need to jump to an address that is beyond the range specified in Part (b), how would we jump to that destination?
Explanation / Answer
a)
In mips,for 'j' destination_address ; 26 bits are allocated for target address
b)
As we can see ,26 bits are the target offset.So accordingly , we might think we can jump to address
in range of (PC-2^26) to (PC+2^26 - 1).But,this is not the case;as the instructions are 32 bit long,in MIPS 4 byte quantities are stored in word alligned address due to which 00 are appended to the target address.So,we can jump to address in range (PC-2^28) to (PC+2^28 - 4) but the address should be divisible by 4
c)In other to make a proper PC address;it formed by jump instruction in such format:-
4 higher bits from current PC address + 26 bit target address + 2 zeros appended to the right
= 32 bit new PC address
d)
Use two or more jump instructions ; form a consecutive jump chain ;while storing the return address in stack .Use consecutive sequence of push and pop instructions for jumping to farther location then the specified range