马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
assume cs:code,ss:stack
stack segment
db 10 dup (0)
stack ends
code segment
start:mov ax,12666
mov bx,stack
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
dtoc: push dx
push cx
push ax
push si
push bx
mov bx,0
s0: mov cx,10
mov dx,0 ;除之前把dx置为0什么意思?
div cx
mov cx,ax
jcxz s1
add dx,30h
push dx
inc bx
jmp short s0
s1: add dx,30h
push dx
inc bx
mov cx,bx
mov si,0
s2: pop ax
mov [si],al
inc si
loop s2
ay: pop bx
pop si
pop ax
pop cx
pop dx
ret
show_str:push bx
push cx
push si
mov al,0a0h
dec dh
mul dh
mov bx,ax
mov al,2
mul dl
sub ax,2
add bx,ax
mov ax,0b800h
mov es,ax
mov di,0
mov al,cl
mov ch,0
s3: mov cl,ds:[si]
jcxz ok
mov es:[bx+di],cl
mov es:[bx+di+1],al
inc si
add di,2
jmp short s3
ok: pop si
pop cx
pop bx
ret
code ends
end start
上面我做有标号那里,dx存放的是高16位数据,为什么在做32位除法前要把dx置为0,我把12666改为0FFFFFFFFH,计算出来的数字就不对了. |