小程序帮忙看看
键盘输入十六进制显示10进制
data segment
input db 'please input the 16 number:$'
ero db 'error!please input again!$'
data ends
cod segment
assume cs:cod,ds:data
start:mov ax,data
mov ds,ax
call receive
call enter
call disp
mov ah,4ch
int 21h
receive proc
mov bx,0
mov dx,offset input
mov ah,9
int 21h
mov bx,0
next: mov ah,1
int 21h
cmp al,0dh
jz return
cmp al,30h
jb err
cmp al,3ah
jb num
jmp err
num: sub al,30h
jmp save
err: call enter
mov dx,offset ero
mov ah,9
int 21h
jmp next
save:mov cl,4
shl bx,cl
add bl,al
jmp next
return: ret
receive endp
enter proc
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
enter endp
disp proc
mov dx,0
mov ax,bx
mov cx,10000
call kh
mov cx,1000
call kh
mov cx,100
call kh
mov cx,10
call kh
mov cx,1
call kh
kh proc
div cx
mov bx,dx
mov dl,al
push ax
mov ah,2
int 21h
pop ax
mov ax,bx
mov dx,0
ret
kh endp
ret
disp endp
cod ends
end start
[解决办法]
输出时,显示的刚才除出来的还只是数值,要 add dl, '0' 转换为相应的字符再调用 int21h;kh 子程定义应该分离到 disp 子程外面来,汇编没有嵌套子程的说法。