主题:此程序运行后为何没结果
题目:从键盘取得一个十进制数,并把该数以十六进制数形式在显示器上显示出来
程序如下:
codeseg segment
assume cs:codeseg
main proc far
start: call reader
call relf
call display
call relf
mov ah,4ch
int 21h
main endp
reader proc near
mov bx,0
repeat: mov ah,01h
int 21h
sub al,30h
jl over
cmp al,9
jg over
cbw
xchg ax,bx
mov cx,10
mul cx
xchg ax,bx
add bx,ax
jmp repeat
over: ret
reader endp
display proc near
mov ch,4
loop1: mov cl,4
rol bx,cl
mov al,bl
and al,30h
cmp al,3ah
jl console
add al,7h
console: mov dl,al
mov ah,2
int 21h
dec ch
jnz loop1
ret
display endp
relf proc near
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
relf endp
codeseg ends
end start
程序如下:
codeseg segment
assume cs:codeseg
main proc far
start: call reader
call relf
call display
call relf
mov ah,4ch
int 21h
main endp
reader proc near
mov bx,0
repeat: mov ah,01h
int 21h
sub al,30h
jl over
cmp al,9
jg over
cbw
xchg ax,bx
mov cx,10
mul cx
xchg ax,bx
add bx,ax
jmp repeat
over: ret
reader endp
display proc near
mov ch,4
loop1: mov cl,4
rol bx,cl
mov al,bl
and al,30h
cmp al,3ah
jl console
add al,7h
console: mov dl,al
mov ah,2
int 21h
dec ch
jnz loop1
ret
display endp
relf proc near
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
relf endp
codeseg ends
end start