assume cs:code
data segment
db 10 dup(0)
data ends
code segment
start: mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
s2: mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
dtoc: push ax
push si
mov dx,0
push dx ;把数字0进栈
mov bl,10
mov cx,1
s0: div bl ;用12666除以10,商存在al,余数存在ah
mov dl,ah
mov dh,0
push dx
mov ch,0
mov cl,al
mov ah,0
loop s0 ;循环结束后,栈中数据从栈顶向下依次是1,2,6,6,6,0,si,ax
mov cx,6
s1: pop ax
mov bx,cx
mov [bx],al
loop s1
pop si
pop ax
ret
show_str: push dx
push cx
push ax
push si
mov ax,0b800h
mov es,ax
mov al,dh
mov ah,0a0h
mul ah
mov si,ax
mov al,dl
mov bl,2
mul bl
mov ah,0
add si,ax ;si中存放了起始地址
mov bx,0
mov dl,cl
mov cx,17
s: mov al,[bx]
mov ah,dl
mov es:[si],ax
inc bx
add si,2
loop s
pop si
pop ax
pop cx
pop dx
ret
code ends
end start