include io32.inc
.data
msg1 byte 'Please press a key :',0
msg2 byte 13,10,'The key ASCII is :',0
buffer byte ?
.code
start:
;显示msg1
mov eax,offset msg1
call dispmsg
;等待按键并判断
call readc
cmp al,1bh
jz done
mov buffer,al
;显示msg2
mov eax,offset msg2
call dispmsg
;显示高字节
mov al,buffer
shr al,4
call htoasc
call dispc
;显示低字节
mov al,buffer
call htoasc
call dispc
done: exit 0
;子程序
htoasc proc
and al,0fh
or al,30h
cmp al,39h
jbe htoend
add al,7
htoend: ret
htoasc endp
end start