News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Printing decimals

Started by Vortex, December 25, 2004, 01:01:29 PM

Previous topic - Next topic

Vortex

Here is a very usefull print decimal routine coded by MichaelW:
PrintDec PROC numb:WORD
mov ax,numb   
;
   ; Init divisor.
mov bx,10
   ; Zero digit counter.
mov cx,0
@@:
   ; Zero MSW of dividend.
mov dx,0
   ; Divide value by 10.
div bx
   ; Push remainder.
push dx
   ; Increment digit count.
inc cx
   ; Repeat if quotient > 0.
or ax,ax
jnz @B
@@:
   ; Pop digit off stack.
pop dx
   ; Convert to ascii.
add dl,30h
   ; Display.
mov ah,2
int 21h
   ; Repeat CX times.
loop @B
ret
PrintDec ENDP


Thanks Michael  :U