title: Little endian and push in nasm
body: <p>I don't understand why the output of the code is <strong>Ole</strong>. Shouldn't little endianness affect the <strong>push</strong> command? </p>
  
  <pre><code>global _start
  
    section .data
  x: dd 3
  
  section .text
  _start:
    mov eax, 4
    mov ebx, 1
    mov dword[x], 0x0a656c4f
    push dword[x]
    mov ecx, esp
    mov edx, 4
    int 0x80
    mov eax,1 
    mov ebx, 0
    int 0x80
  </code></pre>
  
  <p>If I got it right after <strong>mov dword[x], 0x0a656c4f</strong> the memory layout is :</p>
  
  <pre><code>  0a (higher) 
    65 
    6c 
    4f (lower)
  </code></pre>
  
  <p>because of little endianness of x86 and x points to byte whose value is <strong>4f</strong>.
  After <strong>push dword[x]</strong>, there's the same picture of stack (reversed as it grows downwards) where <strong>esp</strong> points to <strong>0a</strong></p>
  
  <p>The same question is relevant to the code when </p>
  
  <pre><code>  mov dword[x], 0x0a656c4f
    push dword[x]
  </code></pre>
  
  <p>is replaced with:</p>
  
  <pre><code>push dword 0x0a656c4f
  </code></pre>
  
  <p>Thanks.</p>