1

I am trying to print decimal numbers by converting them into characters, although I succeeded in splitting the number into two digits, I can't print them and I don't know why.

Here is my code:

.MODEL small
.STACK 64
.DATA

.CODE

MAIN PROC FAR
         MOV   AX,@DATA
         MOV   DS,AX

         mov   ax,15
         mov   bx,10
         div   bx
    ;result in al
    ;remainder in dl
         mov   bl,DL
         mov   bh,al

         add   bl,'0'
         add   bh,'0'

         MOV   AH,02H
         MOV   DL,bh
         INT   21H

         MOV   AH,02H
         MOV   DL,bl
         INT   21H

         hlt
MAIN ENDP
END MAIN

Any idea why my code doesn't print the characters??

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
  • 1
    You should be zeroing out DX before the div because the division by a 16-bit register will result in dividing the 32-bit number in DX:AX by the register BX (in your case). What results do you get printed and what did you expect to be printed? – Michael Petch Nov 18 '20 at 14:51
  • @MichaelPetch thank you MOV DX,0 solved the problem thank you ... I didn't get any output but now I get 15 – Fearful Phoenix Nov 18 '20 at 14:54

0 Answers0