in CO and Architecture retagged by
2,929 views
2 votes
2 votes

in CO and Architecture retagged by
by
2.9k views

1 comment

@Debashish Deka @Arjun sir pls help

0
0

3 Answers

5 votes
5 votes
Best answer
The question asks for the effective address of the memory operand and so it must be the main memory address (in case virtual memory is used; the virtual address from where the operand is to be fetched)

1. LOAD 20(R1), R5

Here the first operand is using indexed addressing and EA = 20 + R1 = 20 + 1200 = 1220. From the instruction it is clear that the second operand is the destination, but that is not important in answering here.

2. MOVE #3000, R5

Immediate addressing for #3000. So, the EA is the address of the given instruction plus the opcode part size.

3. STORE R5, 30(R1,R2)

Base indexed addressing mode for second (destination) operand. EA = 30 + R1 + R2 = 30 + 1200 + 4600 = 5830.

4. ADD -(R2), R5

Decrement addressing mode. EA = R2 - 1 = 4599.

5. Subtract (R1)+, R5

Increment addressing mode. EA = R1 = 1200. (R1 changes to 1201 after this instruction).
selected by
by

4 Comments

@Arjun sir wht about ADD and SUBTRACT ?we are just performing increment and decrement operation on register content values

4. ADD -(R2), R5 why ADD  is not considering here?

5. Subtract (R1)+, R5 why Subtract is not considering here ?

pls clear this

0
0
@set

it is asking for effective address (EA) ..that's why Add and Subtract is not performed here in 4 and 5.

EA is value of register content ..in case of pre decrement [ Add]  it is first decrement by 1 then store into R2... so EA is value of register R2 after decrement .

but in case of post increment [ subtract] the value of register is EA only as it will increase later..

hope u get my point.
1
1

got it sir  :) 

Auto- 
increment
Add R1, (R2)+ R1 <- R1 +M[R2] 
R2 <- R2 + d
Auto- 
decrement
Add R1,-(R2) R2 <-R2-d 
R1 <- R1 + M[R2]

But this question is only asking about effective address that why we just showing the effective address .Add and subtract also be perform in this 

http://web.cs.iastate.edu/~prabhu/Tutorial/PIPELINE/addressMode.html

Am I right ?

1
1

Yes, this question is only asking about effective address that's why we just showing the effective address value here.

In your above  example see one is post increment  [ Add R1, (R2)+ ] and another is pre decrement [ Add R1,-(R2)] .. so in case of post R1 <- R1 +M[R2]  after that r2 is incremented.. but in case of pre , first subtract happen R2 <-R2- d   then R1 value is incremented. yes Add and subtract perform like this .

1
1
2 votes
2 votes

Registers R1 and R2 of a computer contain the decimal values 1200 and 4600, we have to find effective adress of associated memory operand in each instruction:

 Load 20(R1),R5 : This means load 20+R1 into R5 .   R1= 1200 , R1 + 20 = 1220 , so R5 have 1220 , Effective address of R5 is 1220.


 Move #3000,R5 : This means move value 3000 into R5 , so effective address is part of the instruction whose value is 3000.

Now R5 = 3000


 Store R5,30(R1,R2) : This means 30+R1+R2 and store the result into R5 . so R5 = 30+1200+4600 =  5830 , so now R5 value is 5830 , the effective address is 5830.


 Add -(R2),R5 : This means -1 from  R2 value and store the result into R5 . So R5= 4600 - 1 = 4599 , effective address of R5 is 4599 .


 Subtract (R1)+,R5 : This means effective address is contents of R1 so EA = 1200 .

Effective addresses are 

  1. 1220
  2. 3000   [ it is not EA,  it is the address of the instruction part where 3000 is stored ] 
  3. 5830
  4. 4599
  5. 1200
edited by

2 Comments

@bikram sir

for two registers ADD will like

ADD R1,R2 it will give R2<------R1+R2

i am doing the same 

ADD -(R2),R5

it will first decrement R2 content by 1 then add with R5 content and put result into R5 ,whts wrong with this ?

In your answer Add -(R2),R5 :

This means -1 from  R2 value and store the result into R5.No ADD is perform .

pls clear this 

1
1
edited by

@set2018

ADD -(R2),R5 is pre decrement addressing mode.

it will first decrement R2 content by 1 then store that value into R5 . EA is value of R5 only .

---------------

Subtract (R1)+, R5 is post increment addressing mode.

instruction Subtract (R1)+,R5  means : first subtract R5 from R1 then store that result into R1 then increase R1 value  by word length .

so M[R1] <- M[R1] - R5  ,  then we increase R1 value word by word. It is post increment.

so EA is M[R1] only , which is 1200 . 

If I say Add R1, R2 Then the register contains the operand. It simply add R1 with R2.

If I say Add  (R1), R2 : Then there is one level of indirection for R1 i.e. R1 doesn't contain operand directly but address of operand. so (R1) is same as Mem[R1] . 

This question asks what is effective address of the memory operand , that memory addres is value of R1 only which is our Effective address here .

Similarly, Add -(R2),R5 means first decrese value of R2 by 1 then store it to R5 . It is pre decrement so we store it in R5.

But Substract (R1)+,R5 is post increment hence result first store in R1 then increse word by word .

Hope everything is clear at this point !

0
0
0 votes
0 votes

R1=1200                            R2=4600

1. LOAD 20R1,R5 (copy the data from memory into a register.)

R5=1220      (20+1200)

2.MOVE #3000,R5 (COPY 3000 INTO R5)

Now,R5=3000

3.STORE R5,30(R1,R2)

it will add the contents of R1 and R2 ,also add offset 30(1200+4600+30)

Now R5=5830

ADD -(R2),R5

it will first decrement R2 content by 1 then add with R5 content 

R5=4599+5830=10429

SUBTRACT (R1)+,R5

it will first increment the content of R1 then subtract will perform

R5=9228

FINAL VALUE OF REGISTERS WILL BE 

R5=9228                       R1=1200                            R2=4600

2 Comments

@bikram sir
0
0
@set2018

I answered, your first 3 effective addressses are correct .

last 2 are wrong .
0
0

Related questions

0 votes
0 votes
0 answers
2