;Programmed by Billal BEGUERADJ ;www.begueradj.50megs.com ;beg.bill@yahoo.com ;the aim of the following program is to display a non signed decimal number ;that is stored in AX .MODEL SMALL .STACK .DATA .CODE displayn PROC ;------------------------------------------------------- ;this procedure displays the number that is stored in AX ;------------------------------------------------------- push ax push dx add al,48 ;we must add 48 to our number since ASCII 0 is 48 mov dl,al ;the ASCII code of the number must be stocked into DL mov ah,2 int 21h pop dx pop ax ret displayn ENDP displaywholenumber PROC ;----------------------------------------------------------- ;display the non signed decimal number that is stocked in AX ;----------------------------------------------------------- push AX push dx push cx mov bx,10 ;BX est le dénominateur mov cx,0 ;CX is our counter decompose: mov dx,0 div bx ;AX/BX = what remains = DX and quotient = AX push dx ;stock what remains in the stack inc cx cmp ax,0 ;quotient = 0 ? jnz decompose ;if not continue decomposition displ: pop ax ;load a number from the stack call displayn ;in order to display it loop displ ;repeat displayin until CX = 0 pop cx pop bx pop ax ret displaywholenumber ENDP main PROC ;------------------------------------------- ;the beginning of the main program ;------------------------------------------- MOV AX,@DATA MOV DS,AX MOV ax, 9999 ;9999 is for instance the number to display call displaywholenumber mov ax,04c00h int 21h main ENDP END main