View previous topic :: View next topic
|
Author |
Message |
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
All,
This might soud pretty primitve but I need to know what exactly do we mean when we code
D2(X2,B2)???
How is this resolved???
What is the use of Index Register here ???
Thanks |
|
Back to top |
|
|
Archana_MF
New User
Joined: 21 Jul 2006 Posts: 49 Location: California
|
|
|
|
D2(X2,B2) : [D2] + X2 + B2 <== this forms a complete memory address where the Actual data is stored
In Breif,
Effective Address : an address formed using 2 registers, which will allow us to acces Virtual memory of a processor.
X2 : Index register : this are used to create memory address by adding to contents of a address register (in above ex : to the contents of D2). Few processors will have specific Index register (for ex MP 80x86[not sure] have SI/DI as Index register) whereas, few Porcessors like IBm 360/370 will use the 16 GPR registers as index registers.
D2: Addres Rgeister or BaseRegister: the contents of this registers are added to Index registers to form the complete physical address.
B2 : Displacement , some constant value I guess
For further details, go thru some manuals in forum.
guys, plz do correct me if I am wrong. |
|
Back to top |
|
|
phetu
New User
Joined: 19 Aug 2006 Posts: 13 Location: Canada
|
|
|
|
You are right except that you wrote "D2:Addres Rgeister or BaseRegister" instead of "B2:Addres Rgeister or BaseRegister" and "B2:Displacement " instead of "D2:Displacement ".
Patrick |
|
Back to top |
|
|
Archana_MF
New User
Joined: 21 Jul 2006 Posts: 49 Location: California
|
|
|
|
Thank you. |
|
Back to top |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
All,
Thanks for the reply.
But can you be more specific about Index Register here??
Why and where can I use Index register??? |
|
Back to top |
|
|
phetu
New User
Joined: 19 Aug 2006 Posts: 13 Location: Canada
|
|
|
|
Lets says that you have a table of 10 entries of 80 bytes long and you would like to scan each entry to process a certain address field that is poistionned at an offset of 40 bytes.
Then B2 (base register) could be the address of the table, the I2 (index register) could containt the offset to the current entry (entries number x 80 bytes) and D2 would be the displacement within the entry ( 40 in our case).
So, the code would be:
LA R3,TABLE ---> R3 will be our base register - Initialize to the TABLE's address
LA R4,0 ---> R4 will be the index register - Start at 0 so it will point to the very first entry
LA R5,10 ---> R5 will contain the number of TABLE's entries...in our case it's 10.
LOOP DS 0H ---> Label
L R6,40(R4,R3) ---> Take the content of bytes 40 for 4 bytes long and put it into reg R6
.....
.....
..... ---> Process the R6 register as you want
.....
LA R4,80(R4) ---> Skip to the next entry : Add 80 to the contents of R80
BCTR R5,LOOP ---> Loop until all the entries are process...
Does it answer your question?
Patrick |
|
Back to top |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Thanks Pat, yes it answers my question.
However i get one more doubt here.
Why do we use Index register here ???
I can change me displacement from my base address to get to that table entry ! Isnt it ??? Is it just another way of addressing ??
Thanks
ap |
|
Back to top |
|
|
phetu
New User
Joined: 19 Aug 2006 Posts: 13 Location: Canada
|
|
|
|
It is another way of addressing. In this case you could assume that the R3 is initialize at the beginning of the program and it is never re-initialized. So if you would need to scan the table agin, you would only have to set the Index regs....
The same example with the move instruction (MVC), you would have to use the base register to scan the table because there is no Index register supplied...
Patrick |
|
Back to top |
|
|
Bharanidharan
New User
Joined: 20 Jun 2005 Posts: 86 Location: Chennai, India
|
|
|
|
Whoa, something is nagging me. How can you 'change' your displacement from your base reg, say for a number of times in a loop? You either have to damage the base reg, which may not be desirable, or must use index reg. In the previous example:
L R6,40(R4,R3)
Can you accomplish this without using index reg or without damaging R3? I don't think we can. |
|
Back to top |
|
|
phetu
New User
Joined: 19 Aug 2006 Posts: 13 Location: Canada
|
|
|
|
No, for use we can't do that without using index reg or without damaging R. In that case I used R4 as my index register
Patrick |
|
Back to top |
|
|
|