|
主题 : : 大家帮我看看我实在是找不到原因了,为什么结果不是12666?? [待解决] |
回复[ 5次 ]
点击[ 474次 ] | |
荣誉值:0
信誉值:0
注册日期:2009-10-07 14:18 |
assume cs:code
data segment
db 10 dup(0)
data ends
code segment
start: mov bx,data
mov ax,12666
mov ds,bx
mov ss,bx
mov sp,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
dtoc: push di
push si
push bx
push cx
a: mov cx,dx
jcxz goon ;判断dx高位是否为0
mov cx,0ah
call div_str
push cx
inc si
jmp short a
goon:mov cx,ax
jcxz re_num
mov cx,0ah
call div_str
push cx
inc si
jmp short goon
re_num: mov cx,si
s: pop ax
mov bx,30h
add ax,bx
mov ds:[di],ax
inc di
loop s
pop cx
pop bx
pop si
pop di
ret
div_str:push bx
push ax
mov ax,dx
div cl
mov bx,ax
mov ah,0
mov dx,ax
pop ax
push dx
mov dx,bx
mov dl,dh
mov dh,0
div cx
mov cx,dx
pop dx
pop bx
ret
show_str: push di
push si
push bx
push es ;注意ss:sp指向长度
dec dh ;送入变量dh行号,dl为排号注意寄存器的使用cl为颜色
dec dl
mov ax,0
mov al,dh
mov bx,0
mov bl,10
mul bl
mov bx,ax
mov ax,0b800h
add ax,bx
mov es,ax
mov ax,0
mov al,dl
add al,dl
mov bx,ax
mov di,0
mov ch,cl
ok: mov cl,[si]
push cx
mov ch,0
jcxz return
pop cx
mov es:[bx+di],cx
add di,2
inc si
jmp short ok
return: pop cx
pop es
pop bx
pop si
pop di
ret
code ends
end start | | |