📄 keyboard.mod
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -