Mips Instruction Format :
00010110001100101111111111111110
In this case the instruction is located at address 0x80000014
It's and BNE instruction with Operands : Rs = $s2 and Rt = $s1, with an offset of -2 I know it's possible to solve this question via this formulae : Pc+4-offset which in this case would yield 0x80000010. However is it because the PC is always assumed to be an instruction ahead(4bytes) hence Pc+4 and the offset is -2x8 so Pc+4-8 gives me 0x80000010. Can some kind soul explain step by step what am I supposed to do here?
The MIPS branch offset is a signed displacement (expressed in number of instructions) from the instruction following the branch.
In other words, in your case with MIPS32, the following instruction is at 0x800000018. The offset -2 is multiplied with the instruction size 4, giving -0x8.
The instruction branched to is in other words 0x80000018-0x8 = 0x80000010
.
User contributions licensed under CC BY-SA 3.0