Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 823
Tim Avatar asked Feb 11 '15 02:02

Tim


People also ask

What is offset in addressing mode?

Indexed addressing mode: The operand's offset is the sum of the content of an index register SI or DI and an 8 bit or 16 bit displacement. Based Indexed Addressing: The operand's offset is sum of the content of a base register BX or BP and an index register SI or DI.

What is the difference between offset and address?

In computer engineering and low-level programming (such as assembly language), an offset usually denotes the number of address locations added to a base address in order to get to a specific absolute address.

What is index addressing mode?

In the indexed addressing mode, the content of a given index register gets added to an instruction's address part so as to obtain the effective address. Here, the index register refers to a special CPU register that consists of an index value.

What is the main difference between base and index register addressing modes?

In the 8086 through the 80286, this type of addressing uses one base register (BP or BX), and one index register (DI or SI) to indirectly address memory. The base register often holds the beginning location of a memory array, while the index register holds the relative position of an element in the array.


1 Answers

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. :-)

like image 167
Moby Disk Avatar answered Sep 19 '22 20:09

Moby Disk