144 views

Can anybody explain this line with example? Do it mean target address can  be 32 bit before branch address?

retagged | 144 views
+1

 JMP -32

if the current instruction is of 2 Byte, and assuming current PC value is 2000, then next PC Value will be 2002 before fetching that instruction PC value is calculated as

PC = Current PC value + Displacement Value.

PC = 2002 + (-32)

PC = 1970

Now PC will fetch the instruction from 1970 address.

0

thanks @ Shubhanshu

Branch address displacement is used by branch instructions to go back to some previous instruction after execution of current instruction.It uses PC - relative addressing mode.

Say we have following sets of instructions :

1004          MOV C , 8

1012          DEC  C

1016          JNZ LOOP

So here PC value for 1st instruction is 1004 , for 2nd one it is 1008 and so on..Now if the branch condition which is based on value of C is not zero , it branches back to label "LOOP" which has instruction 'ADD" having address 1008.

Hence PC should be updated as 1008 instead 1020 which would have been the next address otherwise.

Hence  PC   =   PC  + displacement

==>    1008  =  1020 + displacement

==>   displacement  =  -12

This way u may understand the notion of displacement in ur example as well.

by Veteran (101k points)
selected by
+2
thanks @Habib