As the web-resources on this is sparse, I will, for the benefit of future searches, begin by listing the address modes for IA-32 Assembly Language (NASM) and then follow up
In NASM syntax, that instruction should be MOV EBX, MY_TABLE
. What MOV EBX, [MY_TABLE]
would do is load the first 4 bytes located at MY_TABLE
into EBX
. Another alternative would be to use LEA, as in LEA EBX, [MY_TABLE]
.
In this case the tutorial is right. MY_TABLE
is defined as an array of words. A word on the x86 is 2 bytes, so the second element of MY_TABLE
is indeed located at MY_TABLE + 2
.
That tutorial is not even valid NASM code. For links to x86 guides / resources / manuals that don't suck, see the x86 tag wiki here on SO.
MOV [EBX], 110
won't assemble because neither operand implies an operand-size. (I think even MASM won't assemble it, but some bad assemblers like emu8086 have a default operand size for instructions like this.) mov word [ebx], 110
would do a 16-bit store.
MOV EBX, [MY_TABLE]
will assemble but it loads the first 2 words from the table. mov ebx, MY_TABLE
will put the address into a register.