;TITLE KEYBIOS - Keyboard BIOS output display program ; ;KEYBIOS.ASM Copyright 1988 James Apolis May 12, 1988 ; ;PURPOSE: ; This program displays the keyboard information returned from ; the BIOS when a key is depressed. ; ;REVISION HISTORY: ; DATE COMMENTS ; ------------ ------------------------------------------------ ; May 12, 1988 Initial creation - Jim Apolis ; January 12, 1995: translated to CP/M-86 - Kirk Lawrence ; ; To assemble under CP/M-86: ASM86 KEYBIOS ; GENCMD KEYBIOS ; VERS EQU '1' ;Version REVS EQU '0' ;Revision ; CSEG ;start of code segment org 100h jmp start ; MSG0 DB 13,10,27,'EKEYBIOS Version ',VERS,'.',REVS DB ' - Copyright 1988, James Apolis',13,10 db 'CP/M-86 translation from DOS by Kirk Lawrence',13,10,10 DB '= Press ESC twice to exit.',13,10 db ' ~~~~~',13,10,'$' MSG1 DB 'ASCII code=$' MSG2 DB 'H Scan code=$' MSG3 DB 'H Shift status=$' MSG4 DB 'H',13,10,'$' MSG5 DB 'Exiting...',13,10,'$' ESC_FLG DB 0 ;Escape key pressed flag ; start: MOV DX,OFFSET MSG0 ;Point to initial message MOV cl,9 ;Output string function INT 224 ;Execute function ; KEY_BIOS_3: MOV AH,0 ;Read keyboard character INT 16H ;Execute function PUSH AX ;Preserve key code CMP AL,1BH ;Escape? JNZ KEY_BIOS_1 ; If not jump MOV AL,ESC_FLG ;Get previous escape flag CMP AL,0FFH ;Flag set? JZ KEYEND ;If so quit program MOV AL,0FFH ;Set escape MOV ESC_FLG,AL ; flag JMP KEY_BIOS_2 ;Go display message ; KEY_BIOS_1: MOV AL,0 ;Reset escape MOV ESC_FLG,AL ; flag ; KEY_BIOS_2: MOV DX,OFFSET MSG1 ;Point to ASCII message MOV cl,9 ;Output string function INT 224 ;Execute function POP AX ;Restore key data PUSH AX ;Preserve key data CALL PNUM ;Output ACSII code MOV DX,OFFSET MSG2 ;Point to scan code message MOV cl,9 ;Output string function INT 224 ;Execute function POP AX ;Restore key data MOV AL,AH ;Move scan code for display CALL PNUM ;Output scan code MOV DX,OFFSET MSG3 ;Point to shift status message MOV cl,9 ;Output string function INT 224 ;Execute function MOV AH,2 ;Read shift status INT 16H ;Execute function CALL PNUM ;Output key code in decimal MOV DX,OFFSET MSG4 ;Point to last message MOV cl,9 ;Output string function INT 224 ;Execute function JMP KEY_BIOS_3 ;Loop ; KEYEND: POP AX ;Clear stack MOV DX,OFFSET MSG5 ;Point to exit message MOV cl,9 ;Output string function INT 224 ;Execute function xor cx,cx int 224 ;Exit to CP/M-86 ; PNUM: PUSH AX ;Preserve number in AL SHR AL,1 ;Shift SHR AL,1 ; right SHR AL,1 ; four SHR AL,1 ; places CALL DSPLSN ;Display MS nibble POP AX ;Restore number in AL PUSH AX ;Preserve number in AL CALL DSPLSN ;Display LS nibble POP AX ;Restore number in AL RET ;Return ; DSPLSN: AND AL,0FH ;Clear MS nibble OR AL,30H ;Convert to ASCII CMP AL,3AH ;Alpha character? JC DSPN ; If not jump ADD AL,7 ;Convert to alpha character DSPN: MOV DL,AL ;Character to output in DL MOV cl,2 ;Output character INT 224 ;Execute function RET ;Return ; END