assume cs:code
data segment
db 10 dup (0)
data ends
code segment
start: mov ax,1266
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ah,4ch
int 21h
dtoc: push cx
push bx
dtoc1: mov dx,0 ;用16位除法所以把DX清0
mov bx,10
div bx ;商保存在ax,余数保存在dx
mov cx,ax ;ax/10=0 ,程序就不再向下执行而是跳到ok
jcxz ok
add dx,30h ;把结果加上30h转化为字符
mov [si],dl ;把转化了的字符传给数据段以便show_str子程序调用
inc si
jmp short dtoc1
ok: mov bl,0
mov [si],bl
pop bx
pop cx
ret
show_str:push ax
push bx
push cx
push si
mov ax,0b800h
mov es,ax
mov di,0
mov al,160
mul dh
mov bx,ax
mov al,2
mul dl
sub ax,2
add bx,ax
mov ah,02
mov ch,0
str:mov cl,[di]
jcxz ok1
mov al,cl
mov es:[bx+si],ax
inc di
add si,2
jmp str
ok1:pop si
pop cx
pop bx
pop ax
ret
code ends
end start
请高手帮忙,我的show_str子程序没有问题,就是dtoc子程序出现了问题;其中12666的显示我是倒着的 |