title: TASM program outputs garbage and may hang upon exit
body: <p>I have the following code, which takes a number in hexadecimal format and prints out its decimal format.</p>
  
  <p>This program runs kinda fine in Turbo Debugger, but when I run it in DOS, I see some extra symbols in output after my number output: </p>
  
  <pre><code>.model small
  .stack 100h
  .486
  .code
  
  save proc
      itm:
          xor dx,dx
          mov bx,10
          div bx
          add dl,30h
          inc cx
          pop bx
          push dx
          push bx
          cmp ax,0
          jne itm
     ret
  save endp
  
  start:
      mov ax, 0FFFFh
      call save
      mov ah, 02
      print:
          pop dx
          int 21h
          loop print
         int 20h
  end start
  </code></pre>
  
  <p>Output:</p>
  
  <p><code>
  C:\TASM&gt;lab31
  65535 ò Φ■╤   9°☻░╧♠UWSîÄPA÷0ó♥┴∞└εê$♦ó♥α♦▲ê$ó♦Σê←ë♦ó♥☻╨sÄ÷♣t╣ ╞ ÷┤ⁿ8sê¬ê²≤&amp;mî│░ⁿ┘╗♥÷ t&lt;sÿ☻╪╟♣I☼&gt;♥b!├─4&amp;Gê&amp;_ëΩî∞[┴éΦ
                                                                                                                       z│Φ ☺\│Φ ♀fδ[♥3¡ïA1èG┴├═≥uè ç♦└┌é─Ω╕↕ëX╪♥♦♫↕Y^▼Z╖
                                                                                                                                                                        ←tÇ5▲♦▼δá♦├☻├ █
  ☻┬!    C└(A∞1▬:↕ÿ├ƒ♥╞[%█☼C└≥░Φ
        1357                 46$♦♦
  </code></p>
  
  <p>As you can see 65535 prints ok, but then garbage appears. When I run the program in Turbo Debugger, it hangs after writing out 65535.</p>