decimaldata dw 10000,1000,100,10,1
inttodecstring proc
;input: ax=integer to output, si=string space to work in
;output: si=start of decimal string
;NOTE: output string has leading zeros!!!
push di
push bx
push cx
push dx
mov bx,si
mov di,0
loop1itds:
;divide by powers of tens
mov cx,decimaldata[di]
mov dx,0
div cx
;convert result to a digit string
add al,40h
mov byte ptr [di][bx],al
;transfer remainder to ax
mov ax,dx
add di,2
cmp di,10
jb loop1itds
pop dx
pop cx
pop bx
pop di
ret
inttodecstring endp