-
Notifications
You must be signed in to change notification settings - Fork 15
/
keyboard.asm
58 lines (45 loc) · 1.08 KB
/
keyboard.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
; this sample shows the use of keyboard functions.
; try typing something into emulator screen.
;
; keyboard buffer is used, when someone types too fast.
;
; for realistic emulation, run this example at maximum speed
;
; this code will loop until you press esc key,
; all other keys will be printed.
name "keybrd"
org 100h
; print a welcome message:
mov dx, offset msg
mov ah, 9
int 21h
;============================
; 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
msg db "Type anything...", 0Dh,0Ah
db "[Enter] - carriage return.", 0Dh,0Ah
db "[Ctrl]+[Enter] - line feed.", 0Dh,0Ah
db "You may hear a beep", 0Dh,0Ah
db " when buffer is overflown.", 0Dh,0Ah
db "Press Esc to exit.", 0Dh,0Ah, "$"
end