keybrd.asm
来自「汇编语言 参考书 包含作业与答案 从入门到精通 通俗易懂」· 汇编 代码 · 共 71 行
ASM
71 行
; This sample shows the
; use of keyboard functions.
; Try typing something to
; "User Screen".
;
; When "step delay" is too
; long, keyboard buffer
; is used.
;
; Try setting "step delay"
; to 1, for more realistic
; emulation.
;
; This code will loop until
; you press ESC key, other
; keys will be printed.
#make_COM#
; Used to print a message:
include 'emu8086.inc'
ORG 100h
; Print a welcome message:
LEA SI, msg1
CALL print_string
;============================
; Eternal loop to get
; and print keys:
wait_for_key:
; check for keystroke in
; keyboard buffer:
MOV AH, 1
INT 16h
JZ wait_for_key
; get keystroke from keyboard:
; (remove from the buffer)
MOV AH, 0
INT 16h
; print the key:
MOV AH, 0Eh
INT 10h
; press 'ESC' to exit:
CMP AL, 1Bh
JZ exit
JMP wait_for_key
;============================
exit:
RET
DEFINE_PRINT_STRING
msg1 DB 'Type anything...', 13, 10
DB '[Enter] - carriage return.', 13, 10
DB '[Ctrl]+[Enter] - line feed.', 13, 10
DB 'You will hear a beep', 13, 10
DB ' when buffer is overflown.', 13, 10
DB 'Press ESC to exit.', 13, 10, 0
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?