i am totally confused about addressing modes in nasm x86 assembly language.
after reading nasm manual i found that [ ] is used to get the value at the memory location specified inside square brackets.
my understanding:
var db 10
mov eax , var ; address of var is copied into eax register
mov eax , [var] ; value of var 10 is copied into eax register
here the part i get confused :
here the screenshot of the below code from a book i read
MY_TABLE TIMES 10 DW 0 ; Allocates 10 words (2 bytes) each initialized to 0
MOV EBX, [MY_TABLE] ; Effective Address of MY_TABLE in EBX
MOV [EBX], 110 ; MY_TABLE[0] = 110
ADD EBX, 2 ; EBX = EBX +2
MOV [EBX], 123 ; MY_TABLE[1] = 123
( this code is taken from assembly_tutorial tutorialspoint.com )
in the second line MOV EBX, [MY_TABLE] , according to my understanding MY_TABLE points to a address that is initialized to zero. so it should move the value 0 to the ebx register. but they mentioned in comment that effective address of
MY_TABLE is copied into EBX register. my doubt is that why does it copy the address instead of the value zero.
in the third line MOV [EBX], 110 , according to their comment ebx has effective address of MY_TABLE . so according to my understanding [ EBX ] should get the value at the address , so it becomes mov value_at_effective_address , 110 . so what is the point of copying a constant into a value?
MOV EBX, [MY_TABLE] ;a value copied into ebx or a address copied into ebx?
MOV [EBX], 110 ; moving 110 to a memory loation or to a value at a memory address.
MOV [EBX], 123 ; moving 123 to a memory location or to a value at a momory address.