title: Assembly variable assignment
body: <p>I'm reading Assembly Language Step by Step Programming with Linux by Jeff Duntemann.</p>
  
  <p>In the book he mentioned that the code</p>
  
  <pre><code>EatMsg: db "Eat at Joe's",10
  mov ecx,EatMsg
  </code></pre>
  
  <p>Copies not the content of EatMsg but the memory where the content is stored at. This is understood and I have confirmed it via edb. But the statement:</p>
  
  <pre><code>EatMsg: dw "Eat at Joe's",10
  </code></pre>
  
  <p>When I checked this code in the debugger its the same memory address when using the db directive, that's understood as well however I know that dw, refers to "define word" (2 bytes).</p>
  
  <p>But can someone tell me what actually happens during execution does the CPU reads a word at a time, because of the dw directive? I'm trying to visualize it.</p>
  
  <p>The book confuses me because he mention that the general purpose registers would hold the address of the define string then I read the below excerpt and got confuse:</p>
  
  <pre><code>WordString: dw 'CQ'
  DoubleString: dd 'Stop'
  </code></pre>
  
  <blockquote>
    <p>The DW directive defines a word-length variable, and a word (16 bits) may
    hold two 8-bit characters. Similarly, the DD directive defines a double word
    (32-bit) variable, which may hold four 8-bit characters. The different handling
    comes in when you load these named strings into registers. Consider these
    two instructions:</p>
  </blockquote>
  
  <pre><code>mov ax,WordString
  mov edx,DoubleString
  </code></pre>
  
  <blockquote>
    <p>In the first MOV instruction, the characters ‘‘CQ’’ are placed into register AX,
    with the ‘‘C’’ in AL and the ‘‘Q’’ in AH. In the second MOV instruction, the four
    characters ‘‘Stop’’ are loaded into EDX in little-endian order, with the ‘‘S’’ in
    the lowest-order byte of EDX, the ‘‘t’’ in the second-lowest byte, and so on.
    This sort of thing is a lot less common (and less useful) than using DB to define
    character strings, and you won’t find yourself doing it very often.
    Because eatsyscall.asm does not incorporate any uninitialized data, I’ll hold
    off discussing such definitions until we look at the next example program.</p>
  </blockquote>
  
  <p>How the CPU executes this and whats the benefit of using the db directive against the dw directive?</p>
  
  <p>Thanks in advance</p>