0

I am a beginner of x86 assembly. The question is why 3 will be stored at address z+8. I am so confused. Please help me if you know why. Thanks.

.DATA
var DB 64
var2 DB ?
     DB 10
X DW ?
Y DD 3000  
Z DD 1,2,3; Declare three 4-byte words of memory starting at address “Z”, and initialized to 
           ; 1, 2, and 3, respectively. E.g. 3 will be stored at address Z+8. 
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Phillip
  • 1
  • 1
  • DD means double dword that are 4 bytes of size, `1=z+0, 2=z+4, 3=z+8` – tttony Sep 11 '21 at 11:47
  • 1
    @tttony: Not "double dword". More like "Data DWord", or "Define DWord". A DWord is a double word, 2x 2 bytes. A double dword would be a qword, dq. – Peter Cordes Sep 11 '21 at 11:59

1 Answers1

2

z dd 1,2,3 stores 3 dwords of 4 bytes each.
The first starts at z+0, the second z+4 and the third at z+8.

For example, the first 4-byte dword spans bytes z+0 to z+3.

The second must start at z+4.

This is assembly language; nothing inserts gaps between data you emit. Unlike in C, you fully control the layout. (Although even in C, arrays are guaranteed to be contiguous without padding, and you can look at this line with multiple operands to a dd as being an array.)

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847