Last Updated : 19 Nov, 2018

Consider the following instruction sequence in a RISC machine :

\"Capture\"

Conditional and unconditional branch instructions use PC- relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. If the target of the branch instruction is i, then the decimal value of the Offest is __________.
(A) -16
(B) 18
(C) 1000
(D) None of the above


Answer: (A)

Explanation: Let\’s address of first instruction is 1000. Therefore,

\"333\"

Question says that the target of branch instruction is \’i\’ which is at 1000 in our example.
So, we need to go to address 1000 from address 1016 (which is currently pointed by PC)
1016 – 1000 = 16
Therefore, we have to specify Offset as -16 which would mean that 16 should be subtracted from next address instruction (1000).

Alternative way –

Instruction            Bytes
i               0-3
i+1               4-6
i+2                 7-11
i+3                 12-12
i+3            13-15
Next Instruction    16
Instruction            Bytes
i               0-3
i+1               4-6
i+2                 7-11
i+3                 12-12
i+3            13-15
Next Instruction    16

According to PC Relative Mode,

Effective PC address = next instruction address + offset
0(i) = 16 + offset
0-16 = offset

Offset = -16
Option (A) is correct.

Quiz of this Question


Share your thoughts in the comments