keyboard.asm

来自「这是DOS系统的源代码,汇编写的,值得看看,对开发操作系统的人员有价值」· 汇编 代码 · 共 88 行

ASM
88
字号
; ========================================================

COMMENT #

	KEYBOARD.ASM

	Copyright (c) 1991 - Microsoft Corp.
	All rights reserved.
	Microsoft Confidential

	Functions to use the ROM BIOS for getting
	input from keyboard via interrupt 16h


	Video initialization function. This function
	must be called before any of the other vio
	library functions.


	johnhe - 03/03/89

END COMMENT #

;========================================================

include	BIOS_IO.INC
include	MODEL.INC

;========================================================


.CODE

; =======================================================
; int  KbdGetKey( void );
;
; Waits for a character from the keyboard and returns the
; character in AL and scan code in AH
; =======================================================

KbdGetKey PROC

        mov     AH,KBD_GET_CHAR
	int	16h
        ret

KbdGetKey ENDP

; =======================================================
; int  KbdIsWaiting( void );
;
; Checks for a character waiting in the keyboard buffer
; Returns 0 in AX if no character is waiting.
; The character is not removed from the buffer and will
; be returned by the next call to KbdGetKey
; =======================================================

KbdIsWaiting PROC 

        mov     AH,KBD_IS_WAITING
	int	16h
        mov     AX,1                    ; Assume char is waiting
        jnz     IsWaitingReturn         ; Char waiting so return character
        xor     AX,AX                   ; No char waiting so return zero
IsWaitingReturn:
        ret

KbdIsWaiting ENDP

; =======================================================
; int  KbdGetStatus( void );
;
; Returns the status of the shift and ctrl keys in AX
; =======================================================

KbdGetStatus PROC

        mov     AH,KBD_GET_STATUS
	int	16h
        cbw                             ; Clear AH
        ret

KbdGetStatus ENDP

; =======================================================
	END
; =======================================================

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?