942 views
1 votes
1 votes

If someone mentioned "index value" in indexed addressing mode then which value is it referring; the value of index register or the constant value?


It should be value of index register, isn't it?


But from the given snippet it seems that they are referring constant value

Please clarify

Thank You

1 Answer

0 votes
0 votes
index value is the offset provided to the base address . the basic kind of indexed addressing as explained in Carl hamacher book is the X(Ri) which is used in the code snippet.

X is a fixed offset that is R0 + 4 bytes , this offset cant be changed

Whereas the R0 is base address which can be changed either at beginning of program or as in the loop shown in the snippet by adding #16 to Ro .

The other mode you are talking about is the register offset variation which provides (Ri , Rj)  option to even change the offset . so we dont need 3 instructions for addition we can create one ADD instruction like

 L1 : MOV #4,R4 ; set offset of R4

ADD R4,R0;

then increase the offset counter R4  

ADD #4,R4

Now Branch to L1 with a counter to set the no of times to add 4 to the original offset

This type of code is like working with 2d matrix with (Ri , Rj) being equivalent to rows and columns.

Related questions

3 votes
3 votes
3 answers
2
Himanshu1 asked Dec 4, 2015
2,401 views
0 votes
0 votes
1 answer
4
twin_123 asked Dec 12, 2018
611 views
Solution please