in CO and Architecture retagged by
600 views
3 votes
3 votes
An instruction is stored at location $300$ with its address field at location $301$. The address field has a value of $400$. A processor register $R1$ contains the number $200$. If relative-addressing mode is used by the instruction (with $R1$ as index register) then the effective address is _________.
in CO and Architecture retagged by
by
600 views

2 Answers

2 votes
2 votes
Best answer

In the question it is given that , an instruction is stored at memory location 300  and the memory address of that instruction is stored at memory location 301,

Think like a pointer , this will clear the  meaning of this line.

Now the  minimum size of an instruction is 2 word, we assume this value.

When this instruction was fetched by Program Counter  , program counter was assigned with 302 as memory address of the next instrudtion. Because Program counter ALWAYS STORE MEMORY ADDRESS OF THE NEXT INTRUCTION THAT IS GOING TO EXECUTE !!!

hence Program counter now have value 302 . 

the value of the address field is 400 means the memory address which store  at location 300 have memory address 400 which is store in memory location 301.

Now Effective Address is:

PC's Value + Value contained in address part = 302+400 = 702. 

selected by

4 Comments

In the question it is given that , an instruction is stored at memory location 300  and the memory address of that instruction is stored at memory location 301,

Think like a pointer , this will clear the  meaning of this line.

Now the  minimum size of an instruction is 2 word, we assume this value.

When this instruction was fetched by Program Counter  , program counter was assigned with 302 as memory address of the next instrudtion. Because Program counter ALWAYS STORE MEMORY ADDRESS OF THE NEXT INTRUCTION THAT IS GOING TO EXECUTE !!!

hence Program counter now have value 302 . 

the value of the address field is 400 means the memory address which store  at location 300 have memory address 400 which is store in memory location 301.

Now you must be clear :)

1
1
awsome :)
1
1
@bikram sir....at last line of this question,they have mentioned that relative addressing mode with index register.then why you have not added index register value in effective address?

i am getting effective address as 901...

=>302+400+200-1

=>901

=>-1 i have subtracted because displacement is start after 301..

=>can you explain where i am wrong?
0
0
2 votes
2 votes

PC relative mode is especially used for branching.

The branch address specified by the instruction is added to the contents of the PC (Program Counter).

 

An instruction is stored at location 300 with its address field at location 301.

This simply means that starting address of the instruction is at location 300, and it spans till location 301. ie, One instruction occupies two memory locations. (Some part stored at 300-301, remaining portion stored at 301-302)

 

What does PC point to?

At first PC must have pointed to 300, that's how it reached this instruction.

Now, as soon as this instruction got fetched, PC started to point at the next instruction.

Where is the next instruction stored? 301? No. Because 301 has some portion of the former instruction.

The next instruction is at 302.

So, PC points to 302.

 

Now branch address = 400. (given)

 

So, Effective memory address = 400 + 302 = 702.


R1 contains the number 200. If relative-addressing mode is used by the instruction (with R1 as index register)

This information is irrelevant here. We don't need any index registers in PC relative mode.

Index registers are used in Indexed Mode.

Answer:

Related questions