title: Segmentation Fault when using "mov" in Assembly
body: <p>I am working on a simple assembly program for a class, and am encountering an odd segmentation fault.  It's a pretty simple program to convert bytes into kilobytes.  However, within the function that does the conversion, I get a segmentation fault when I try to move the value 1024 into the <code>ebx</code> register.  I've never had this kind of problem before when working with registers.  Does someone know what could be causing this?  I imagine it is something simple that I'm overlooking.  Thank you!</p>
  
  <pre><code>asm_main:
      enter 0,0
      pusha
  
      mov eax, 0
      mov ebx, 0
      call read_int
      push eax
      call functionA
  
      popa
      mov
      leave
      ret
  functionA:
      mov eax, [esp + 4]
      call print_int
      call print_nl
      mov ebx, 1024 ;segmentation fault occurs here
      div ebx
      call print_int
      ret
  </code></pre>
  
  <p>UPDATE: One interesting discovery is that if I delete the lines interacting with the stack, <code>push eax</code> and <code>mov eax, [esp + 4]</code>, there is no longer a segmentation fault.  However, I get a crazy result in <code>eax</code> after performing <code>div ebx</code>.</p>