title: Division in assembly - MASM
body: <p>The following program works perfectly fine, but I need to understand one step that I don't understand so far. </p>
  
  <p>Look at the code first: I'll indicate the problem as comment right beside where my question is about.</p>
  
  <pre><code>.data  
    mesg byte "How many miles did you fill:", 0dh, 0ah, 0
    mesg1 byte "How many gallons did you drive:", 0dh, 0ah, 0
    mesg2 byte "Your car goes miles per gallon:", 0dh, 0ah, 0
    miles DWORD ?
    gallons DWORD ?
  
  .code
    main proc
  
      mov EDX, OFFSET mesg
      call writestring
  
      call readint
      mov miles, EAX
  
      mov EDX, OFFSET mesg1
      call writestring
  
      call readint
      mov gallons, EAX
  
      mov EDX, OFFSET mesg2
      call writestring
  
      mov eax, miles
      mov ebx, gallons
      SUB EDX, EDX       &lt;-----what dose this do? because if i didn't do it, i get junk result 
  
      div ebx
      call writeint
      exit
    main endp
  end main
  </code></pre>