Tim
Tim

Reputation: 99428

Diference between offset and Index in addressing modes?

In http://en.wikipedia.org/wiki/Addressing_mode

Indexed absolute

   +------+-----+-----+--------------------------------+
   | load | reg |index|         address                |
   +------+-----+-----+--------------------------------+

(Effective address = address + contents of specified index register)

Note that this is more or less the same as base-plus-offset addressing mode, except that the offset in this case is large enough to address any memory location.

I still don't understand what differences are between offset and index? And differences between base-plus-offset addressing mode and Indexed absolute addressing mode?

Thanks.

Upvotes: 6

Views: 6179

Answers (1)

Moby Disk
Moby Disk

Reputation: 3861

Offset is an absolute number of bytes. So if address = 0x1000 and offset = 0x100 then the effective address = 0x1000 + 0x100 = 0x1100.

Index is an offset that is multiplied by a constant. So if address = 0x1000 and index = 0x100 and size of element = 4 then address = 0x1000 + 0x100*4 = 0x1400. You would use this when indexing into an array of 32-bit values.

To me, the address+index example sounds like the x86 LEA instruction: http://www.cs.virginia.edu/~evans/cs216/guides/x86.html#instructions

With that said, when I read the Wikipedia article, I can't see a difference between "Indexed absolute" "Base plus index" and "Scaled." It looks like the exact same thing, except the term "address" and "base" are interchanged. This looks to me like too many authors writing the same thing over again. If this response gets enough upvotes, I'm editing the article. :-)

Upvotes: 8

Related Questions