Data-Related Operators


An operator provides a facility for changing or analyzing operands during an assembly. Operators and directives are part of assembler's syntax, but are not related to the Intel instruction set. Operators are divided into various categories: Various assemblers have different syntax for operators and directives because there is no single defined standard.


OFFSET Operator
The OFFSET operator returns the offset of a data label. The offset represents the distance, in bytes, of the label from the beginning of the data segment.

 mov ax, X+2  mov ax, [OFFSET X + 2]
 .data
 X  SDWORD  12345678h
 .code
 mov   eax, 0
 mov   ax, X+2
 call  WriteHex
 .data
 X  SDWORD  12345678h
 .code
 mov   eax, 0
 mov   ebx, OFFSET X + 2
 mov   ax, [ebx]
 call  WriteHex
 .data
 X  SDWORD  12345678h
 .code
 mov   eax, 0
 mov   ebx, OFFSET X
 mov   ax, [ebx + 2]
 call  WriteHex
 Output  Output  Output