Code: Select all
Summing a list of numbers
The following example shows how register indirect and based addressing modes may be used to access individual elements of an array. We add a list of numbers together and store the result in a variable called sum:
mov bx,offset list ; Get offset of list
mov ax,0
mov al,[bx] ; Get first number
add al,[bx+1] ; Add second number
add al,[bx+2] ; Add third number
add al,[bx+3] ; Add fourth number
add al,[bx+4] ; Add fifth number
mov sum,ax ; Store the sum
list db 10h, 20h, 40h, 2h, 5h
sum dw 0
What do they mean by the offset of the list? Could someone explain this to me. Is there a way around this problem? Is it even needed?
Thanks for the help in advance!