GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
45 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?

asked in CO & Architecture by Veteran (65.1k points) 35 222 625 | 45 views

 

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.

 

thanks @ Shubhanshu

1 Answer

+3 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.

answered by Veteran (88.5k points) 15 58 294
selected by
thanks @Habib


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
Top Users Oct 2017
  1. Arjun

    23396 Points

  2. Bikram

    17078 Points

  3. Habibkhan

    8158 Points

  4. srestha

    6286 Points

  5. Debashish Deka

    5438 Points

  6. jothee

    4978 Points

  7. Sachin Mittal 1

    4772 Points

  8. joshi_nitish

    4344 Points

  9. sushmita

    3964 Points

  10. Rishi yadav

    3804 Points


Recent Badges

Great Question jothee
Notable Question Priyanka23
Great Question khushtak
Good Question Ishrat Jahan
Good Answer Arjun
Revival Arjun
Nice Question Kathleen
Nice Answer janakyMurthy
Renewal janakyMurthy
Renewal Bikram
27,316 questions
35,169 answers
84,075 comments
33,262 users