keyboard.mod

来自「Welcome to PMOS. PMOS is a set of module」· MOD 代码 · 共 77 行

MOD
77
字号
IMPLEMENTATION MODULE Keyboard;

	(****************************************************************)
	(*								*)
	(*	Keyboard input module for use in the multitasking	*)
	(*	demonstration. We bypass the usual keyboard input	*)
	(*	module to avoid complicating the demonstration with	*)
	(*	the extra tasks which handle the keyboard.		*)
	(*								*)
	(*  Programmer:		P. Moylan				*)
	(*  Last edited:	17 February 1990			*)
	(*  Status:							*)
	(*	Fault: hangs if you type too fast.			*)
	(*								*)
	(****************************************************************)

FROM BIOS IMPORT
    (* type *)	RegisterPacket,
    (* proc *)	BIOS;

FROM IntLogic IMPORT
    (* proc *)	IAND;

(************************************************************************)

PROCEDURE CharacterPresent(): BOOLEAN;

    (* Reports whether a character is available, but does not fetch it.	*)

    VAR result: BOOLEAN;
	Registers: RegisterPacket;

    BEGIN
	WITH Registers DO
	    AH := 1;  BIOS (22, Registers);

	    (* BIOS service 22, subservice 1, returns ZF = 0 when a	*)
	    (* character is available.  ZF is bit 6 of the flags word.	*)

	    result := IAND (flags, 40H) = 0;
	END (*WITH*);
	RETURN result;
    END CharacterPresent;

(************************************************************************)

PROCEDURE InKey (): CHAR;

    (* Reads a single character code from the keyboard.	*)

    VAR result: CHAR;
	Registers: RegisterPacket;

    BEGIN
	REPEAT
	    (* Do nothing *)
	UNTIL CharacterPresent();
	WITH Registers DO
	    AH := 0;  BIOS (22, Registers);  result := AL;
	END (*WITH*);
	RETURN result;
    END InKey;

(************************************************************************)

PROCEDURE PutBack (ch: CHAR);

    (* A dummy procedure; our multitasking demonstration does not need	*)
    (* the "unread" operation which this procedure normally provides.	*)

    BEGIN
    END PutBack;

(************************************************************************)

END Keyboard.

⌨️ 快捷键说明

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