title: x86 assembly: Problem with spliting a number to it's digits when it contains 0 at the end
body: <p>I'm working on a program which gets a number (for example, 42 ) then prints it to the screen using interrupt 21 with ah 2.
  My programs manages to split the number, but when I get a number like 60 my programs calls interrupt 0h because I'm dividing by 0</p>
  
  <p>How can I overcome this?</p>
  
  <p>This is the code:</p>
  
  <pre><code>PROC printNumber 
      push bp 
      push dx
      push bx
      push ax
      mov bp, sp 
  
      mov ax, [bp + number]
      mov dx, 0 
      mov bx, 10
      splitNumber:
          cmp ax, 0
          jz exit 
          div bx  
          add dx, '0'
          mov ah, 2
          int 21h 
          jmp splitNumber
  
  
      exit:
      pop ax
      pop bx
      pop dx
      pop bp
      retn 2
  ENDP printNumber
  </code></pre>
  
  <p>Thanks! :D</p>