retagged by
610 views
2 votes
2 votes

branch address sign displacement -32.

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

retagged by

1 Answer

Best answer
5 votes
5 votes

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 :

                Address       Instruction

               1000          LOAD A,50

               1004          MOV C , 8

LOOP :    1008          ADD B

               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.

selected by

Related questions

0 votes
0 votes
1 answer
1
lea asked Jun 12, 2023
290 views
0 votes
0 votes
1 answer
3
Aaryan_Sharma asked Dec 30, 2022
369 views
When we write MOV #1000 , it means we are writing the value 1000 into the accumulator. But when we write MOV 1000 here 1000 refers to address of what ? register or MM ? (...
2 votes
2 votes
1 answer
4
Subbu. asked Jul 14, 2022
495 views
Could you please explain How we can implement indirect addressing mode using Index addressing mode.. and vice versa..??