Answer to Question #150844 in Assembler for Rakibul

Question #150844
Show how array data can be located using base-plus-index addressing.
1
Expert's answer
2020-12-15T12:37:39-0500

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]

 


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS