; Keyboard driver. KB_init: push es push 0 pop es mov eax, [es:9*4] ; save old int vectar mov [KB_OldVect], eax mov ax, cs ; set new int vector shl eax, 16 mov ax, KB_IntHandler mov [es:9*4], eax pop es ret KB_restore: mov eax, [KB_OldVect] push es push 0 pop es mov [es:9*4], eax pop es ret KB_IntHandler: pusha in al, 60h mov bx, [cs:KB_pntin] mov byte [cs:bx+KB_buf], al inc bx cmp bx, 128 jng KB_l1 mov bx, 0 KB_l1: mov [cs:KB_pntin], bx popa pushf ; Execute default code in old int vector call dword [cs:KB_OldVect] iret KB_read: ; returns scan code in: dl mov dl, 0 mov bx, [KB_pntout] cmp bx, [KB_pntin] je KB_l2 mov dl, [bx+KB_buf] inc bx cmp bx, 128 jng KB_l3 mov bx, 0 KB_l3: mov [KB_pntout], bx KB_l2: ret KB_OldVect dd 0 KB_pntin dw 0 KB_pntout dw 0 KB_buf db 0 times 127 db 0