21,497
社区成员




; display the unsigned integer value in AX
dec2asc proc
push ax
push dx
push cx
mov dx, -1 ; flag of ending
push dx ; flag to stack
mov cx, 10
l_div10:
xor dx, dx
div cx ; DX:AX / CX
push dx
test ax, ax
jne l_div10
mov cx, -1
mov ah, 2 ; display character in DL
l_disp:
pop dx
cmp dx, cx
je l_ret
add dl, '0' ; one-digit value turns to character
int 21h ; display the digit
jmp l_disp
l_ret:
pop cx
pop dx
pop ax
ret
dec2asc endp