In MASM (and TASM in MASM compatible mode), when you type:
a dword 10000h
b dword 40000h
a
and b
are labels that represent the storage address assigned to the double words 10000h
and 40000h
respectively.
When a label is used as an operand, MASM knows that label represents a memory address, and decides that the parameter is a reference to memory. To force the memory address to be used as an immediate value, OFFSET
can be used preceding the label. Summing up:
mov eax, a ; mueve 10000h a eax
mov eax, OFFSET a ; mueve la dirección donde está 10000h a eax
mov eax, [a] ; en MASM equivale a MOV eax, a
Instead, when you type:
foo EQU 42
bar EQU 66
foo
and bar
are symbolic constants representing 42 and 66, and space is not reserved for 42 and 66. By using a symbolic constant as a parameter, MASM treats the parameter as an immediate value.
mov eax, foo ; mueve 42 a eax
The fact that the meaning of an instruction is different depending on whether its parameters are labels or constants can be confusing. Other assemblers, such as NASM (also Yasm, which uses NASM syntax), TASM in IDEAL mode, or fasm, require that brackets be used to treat a parameter as a reference to memory, and if there are no brackets they always treat the parameter as an immediate value.