The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+2 votes
144 views

branch address sign displacement -32.

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

in CO and Architecture by Veteran (116k points)
retagged by | 144 views
+1

In PC relative Addressing mode.

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

1 Answer

+5 votes
Best answer

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.

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

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,339 questions
55,763 answers
192,339 comments
90,774 users