I need to convert 32-bit number to ASCII. I don't know how I can do it ....
This is the code what I wrote : The biggest number that could convert is 0001FFFF , if I set Dx to 000F and Ax to FFFF the assembler will give me a divide overflow error !!!
data segment
save db 10 dup(' ') , '$' ; the ASCII will save here
data ends
stack segment
dw 128 dup(0)
stack ends
code segment
assume cs:code , ds:data , ss:stack
main proc far
mov ax, data
mov ds, ax
mov es, ax
mov di,offset save
add di , 9
mov ax,0ffffh
mov dx,0001h
mov cx,10 ; dx ax will divide by cx
convert:
div cx
add dl,'0'
mov [di],dl
dec di
mov dx,0
cmp ax,cx
jge convert
add al,'0'
mov [di] , al
;show the number
mov ah,09h
mov dx,offset save
int 21h
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
main endp
code ends
end main
what should i do?
thanks in advance