title: When should I use size directives in x86?
body: <p>When to use size directives in x86 seems a bit ambiguous. <a href="http://www.cs.virginia.edu/~evans/cs216/guides/x86.html" rel="noreferrer">This x86 assembly guide</a> says the following:</p>
  
  <blockquote>
    <p>In general, the intended size of the of the data item at a given memory 
        address can be inferred from the assembly code instruction in which it is 
        referenced. For example, in all of the above instructions, the size of
        the memory regions could be inferred from the size of the register 
        operand. When we were loading a 32-bit register, the assembler could 
        infer that the region of memory we were referring to was 4 bytes wide. 
        When we were storing the value of a one byte register to memory, the 
        assembler could infer that we wanted the address to refer to a single 
        byte in memory. </p>
  </blockquote>
  
  <p>The examples they give are pretty trivial, such as mov'ing an immediate value into a register.<br>
  But what about more complex situations, such as the following:</p>
  
  <pre><code>mov    QWORD PTR [rip+0x21b520], 0x1
  </code></pre>
  
  <p>In this case, isn't the QWORD PTR size directive redundant since, according to the above guide, it can be assumed that we want to move 8 bytes into the destination register due to the fact that RIP is 8 bytes? What are the definitive rules for size directives on the x86 architecture? I couldn't find an answer for this anywhere, thanks.</p>
  
  <p>Update: As Ross pointed out, the destination in the above example isn't a register. Here's a more relevant example:</p>
  
  <pre><code>mov    esi, DWORD PTR [rax*4+0x419260] 
  </code></pre>
  
  <p>In this case, can't it be assumed that we want to move 4 bytes because ESI is 4 bytes, making the DWORD PTR directive redundant? </p>