title: NASM and a clarification on POP
body: <p>I've been learning me some Assembly lately and am writing really simple programs just to see how things work and to remember things better.</p>
  
  <p>Anyway, I decided to simply write a program that prints your input. I'm using SASM and its io macros.</p>
  
  <pre><code>%include "io.inc"
  
  section .text
  global CMAIN
  CMAIN:
  segment .data
      message db "Input a number", 0 
  segment .bss
      input resb 4
      input2 resb 4
  segment .text
  
      PRINT_STRING message ;prints message
      GET_UDEC 4, eax ;gets 4bytes of user input and puts into eax
      mov [input], eax ;moves eax into input's actual data
      PRINT_UDEC 4, input ;prints input
      NEWLINE
      PRINT_UDEC 4, esp ;Prints 2686764
      NEWLINE
      push input ;pushes input onto the stack
      PRINT_UDEC 4, esp ;Prints 2686760, we pushed a dw
      NEWLINE
  
      pop ebx ;pops (input) and puts it into ebx?
      mov [input2], ebx ;moves ebx into input2
      PRINT_UDEC 4, input2 ;prints input2. //Prints some crazy number.
  
      GET_UDEC 4, eax ;Stops program from exiting.
  
  xor eax, eax
  ret
  </code></pre>
  
  <p>I must be missing something elementary here, but I can't find it to save my life. Anyone know?</p>