Slide 5.6: Defining BYTE and SBYTE data
Slide 5.8: Defining strings
Home

Multiple Initializers


The variable name is only a place marker which marks the offset of the data from the beginning of its enclosing segment. Therefore, multiple initializers can be used in data definitions.
  • If multiple initializers are used in the same data definition, its label refers only to the offset of the first byte. For example,
       letters  BYTE  'a', 'b', 'c', 'd'
    Assume that the letters is at offset 0. All offsets are shown in the table on the right.
Value Offset
'a' 0000
'b' 0001
'c' 0002
'd' 0003
 0 + [ X + 2 ]  0 + [ offset X + 2 ]  0 + [ offset X + 5 ]
 .data
 X   BYTE  1, 2, 3 
 .code
 mov   ebx, X + 2
 sub   eax, eax
 add   al, [ebx]
 call  DumpRegs
 .data
 X   BYTE  1, 2, 3 
 .code
 mov   ebx, OFFSET X + 2
 sub   eax, eax
 add   al, [ebx]
 call  DumpRegs
 .data
 X   BYTE  1, 2, 3
 Y   BYTE  4, 5, 6
 .code
 mov   ebx, OFFSET X + 5
 sub   eax, eax
 add   al, [ebx]
 call  DumpRegs
 Output  Output  Output
  EAX =  



  EAX =  



  EAX =