Base-Plus-Index Addressing
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 holds the beginning location of a memory array, while the index register holds the relative position of an element in the array.
Example. Size of array elements=double word.
.data
arrayZero DWORD 10 DUP(?)
.code
xor eax, eax ; eax=0
mov ebx, offset array ; ebx = base address of arrayZero
mov edi, 0 ; edi = index
mov [ebx+edi], eax ; write 0 to arrayZero[0]
add edi, 4 ; next item of arrayZero
mov [ebx+edi], eax ; write 0 to arrayZero[1]
Comments
Leave a comment