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 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 ]


 INCLUDE Irvine32.inc
 .data
  X   BYTE  1, 2, 3 
 .code
 main PROC
  mov   ebx, X + 2
  sub   eax, eax
  add   al, [ebx]
  call  DumpRegs
  exit
 main ENDP
 END main
     

 INCLUDE Irvine32.inc
 .data
  X   BYTE  1, 2, 3 
 .code
 main PROC
  mov   ebx, OFFSET X + 2
  sub   eax, eax
  add   al, [ebx]
  call  DumpRegs
  exit
 main ENDP
 END main
     

 INCLUDE Irvine32.inc
 .data
  X   BYTE  1, 2, 3
  Y   BYTE  4, 5, 6
 .code
 main PROC
  mov   ebx, OFFSET X + 5
  sub   eax, eax
  add   al, [ebx]
  call  DumpRegs
  exit
 main ENDP
 END main
     

Output


Output


Output


EAX =  

 


EAX =  

 


EAX =  

 





      “Doing nothing is very hard to do.    
      You never know when you’re finished.”    
      — Leslie Nielsen