2021-06-01 18:31:20 +00:00
|
|
|
;Reads a keypress and prints its BIOS code.
|
2021-05-30 16:12:19 +00:00
|
|
|
|
|
|
|
keycode:
|
|
|
|
|
|
|
|
;Read a keypress
|
|
|
|
mov ah, 0x0
|
|
|
|
int 0x16
|
|
|
|
|
|
|
|
;Store the keycode
|
|
|
|
mov [.scan], ah
|
|
|
|
mov [.ascii], al
|
|
|
|
|
|
|
|
;Print the prefix
|
|
|
|
mov si, .prefix
|
|
|
|
call printstr
|
|
|
|
|
|
|
|
;Convert the scancode to a hex string
|
|
|
|
mov ah, [.scan]
|
|
|
|
mov di, .keycode
|
|
|
|
call byte2hexstr
|
|
|
|
|
|
|
|
;Convert the ascii value to a hex string
|
|
|
|
mov ah, [.ascii]
|
|
|
|
mov di, .keycode
|
|
|
|
add di, 0x2
|
|
|
|
call byte2hexstr
|
|
|
|
|
|
|
|
;Print the keycode
|
|
|
|
mov si, .keycode
|
|
|
|
call println
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.prefix:
|
|
|
|
db "0x", 0x0
|
|
|
|
|
|
|
|
.scan:
|
|
|
|
db 0x0
|
|
|
|
|
|
|
|
.ascii:
|
|
|
|
db 0x0
|
|
|
|
|
|
|
|
.keycode:
|
|
|
|
times 0x5 db 0x0
|