我需要将 32 位数字转换为 ASCII。我不知道我该怎么做......
这是我写的代码:可以转换的最大数字是 0001FFFF,如果我将 Dx 设置为000F并将 Ax 设置为FFFF,汇编器会给我一个除法溢出错误!
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
我应该怎么办?
提前致谢