An example of polling a keyboard using port 60h and port 64h:
cli ; stop software-Interrupts mov al, 2 ; stop IRQ 1 out 21h, al sti P1: in al, 64h ; get Status test al, 1 ; is there something in the outputbuffer? jz P1 test al, 20h ; it is a byte from the PS2-Mouse? jnz P1 in al, 60h ; get a key cmp al, 1 ; Escape-key? jz XRAUS ; then goto end ;βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ mov si, OFFSET SONTAB ; get the offsetaddress of our special-key table mov cl, Extablen ; lenght XSUCH: cmp al, [si] jz XFOUND lea si, [si+1] ; instead of "inc si" dec cl jnz XSUCH ;βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ mov si, OFFSET TASTTAB ; get the offsetaddress of our key table mov cx, tablen mov bx, OFFSET TEXTTAB ; our corresponding ASCII table SUCH: cmp al, [si] jz short FOUND lea si, [si+1] dec cx jnz SUCH jmp P1 ;βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ XRAUS: in al, 60h ; clear outputbuffer cli xor al, al ; enable IRQ 1 out 21h, al sti mov ah, 1 ; clear buffer in the ram int 16h ; ...some more instructions ;βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ FOUND: mov si, tablen ; Length sub si, cx xor ecx, ecx mov cl, [bx+si] ; get the ASCII from our table ; ...some more instructions ;βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ XFOUND: ; Tab,shift li.,shift re.,HOME,UP,LEFT,RIGHT,END,DOWN cmp cl, 1 ; DOWN-key jnz short ... ; jump to next .... .... cmp cl, 9 ; Tab-key jnz P1 ; ...some more instructions :------------------------Data area---------------------- TASTTAB DB 02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh DB 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Eh,1Fh DB 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Bh,2Ch,2Dh,2Eh,2Fh DB 30h,31h,32h,33h,34h,35h,39h DB 56h tablen = ($-TASTTAB) TEXTTAB DB "1234567890Γ'" ; with some german letters inside DB "qwertzuiopΓΌ+as" DB "dfghjklΓΆΓ€^#yxcv" DB "bnm,.- " DB "<" Textablen = ($-TEXTTAB) ;--------------------------------------------------------------------------- ; Tab,shift left.,shift rigth.,HOME,UP,LEFT,RIGHT,END,DOWN ;---------- SONTAB DB 0Fh,2Ah,36h,47h,48h,4Bh,4Dh,4Fh,50h Extablen = ($-SONTAB) DB 0,0,0 ; for data_alignment of following entries