|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
dtoc: mov bx,10
inc si
s: div bx
add dl,30h
mov ds:[si],dl
mov dx,0
inc ax
mov cx,ax
dec ax
jcxz s1
inc si
loop s
s1: ret
show_str: dec si
mov bl,dh
mov dh,0
add dl,dl
mov di,dx
mov dx,0
mov bh,0
mov ax,160
mul bx
add ax,160
mov bx,ax
mov ax,0b800h
mov es,ax
mov ch,0
mov dx,cx
s8: mov al,ds:[si]
mov es:[bx+di],al
mov es:[bx+di+1],dl
mov cl,ds:[si]
mov ch,0
dec si
add di,2
jcxz s10
jmp s8
s10:ret
code ends
end start
为什么我单步执行可以,直接运行会报错,显示除法溢出呢
试试我修改的代码: data segment
db 010h dup (0)
data ends
stack segment stack
dw 080h dup (0)
stack ends
code segment
assume cs:code , ds:data , ss:stack
main proc near
mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8 ; 第8行
mov dl,3 ; 第3列
mov cl,2 ; 字符颜色:绿色
call show_str
xor ax,ax
int 016h
mov ax,4c00h
int 21h
main endp
Align 010h
dtoc proc near
mov bx,10
s: cwd
div bx
add dl,30h
mov ds:[si],dl
or ax,ax
jz s1
inc si
jmp s
s1: ret
dtoc endp
Align 10h
show_str proc near
mov ax,0b800h
mov es,ax
xor bx,bx
mov bl,dh
dec bx
xor dh,dh
add dx,dx
mov di,dx
mov ax,160
mul bx
add di,ax
s8: mov al,ds:[si]
or al,al
jz s10
stosb
mov al,cl
stosb
dec si
jmp s8
s10: ret
show_str endp
code ends
end main
|
|