This is the assembly of the Intel 8086 Processor program, which adds numbers to the array:
.model small .stack 100h .data array dw 1,2,3,1,2 sum dw ?,", is the sum!$" .code main proc mov ax,@data mov ds,ax mov di,0 repeat: mov ax,[array+di] add sum,ax add di,2 ; Increment di with 2 since array is of 2 bytes cmp di,9 jbe repeat ; jump if di<=9 add sum,30h ; Convert to ASCII mov ah,09h mov dx,offset sum ; Printing sum int 21h mov ax,4c00h int 21h main endp end main
Above the program adds the number of arrays using the addressing mode "base + index".
The same operation can be performed, for example:
mov ax, array[di]
Now I have the following questions:
- What is the difference between
array[di] and [array+di] - What is the memory addressing mode of
array[di] ? - Which one is better to use and why?
Hquer source share