ASCII IF...THEN , - . 2- . RIGHT$ , . ASC - . , , IF...THEN Alt-A, Alt-B .. 100 C$ = INKEY$:IF C$="" THEN 100 ' 110 IF LEN(C$)=2 THEN 500 ' . - 500 120 IF C$="a" OR C$="A" THEN GOSUB 1100 ' A? 130 IF C$="b" OR C$="B" THEN GOSUB 1200 ' B? 140 IF C$="c" OR C$="C" THEN GOSUB 1300 ' C? . . 500 C$=RIGHT$(C$,1) ' . 510 C=ASC(C$) ' 520 IF C=30 THEN GOSUB 2100 ' Alt-A? 530 IF C=48 THEN GOSUB 2200 'Alt-B? 540 IF C=46 THEN GOSUB 2300 'Alt-C? , 120 ( ) - ASCII: 120 IF C=97 OR C=65 THEN GOSUB 1100 C$ , 510. , - , , C , , . , ASCII C$ . , 91, . , 32. , . , IF C=97 THEN ... : 500 C=ASC(C$) ' ASCII 510 IF NOT ((C>64 AND C<91)OR(C>96 AND C<123)) THEN ... 520 IF C<91 THEN C=C+32 ' 530 IF C=97 THEN ... '... . 7 8 21H , , , . 8 Ctrl-Break ( Ctrl-Break[3.2.8]), 7 . AL. AL ASCII 0, . AL - . ;--- MOV AH,7 ; INT 21H ; CMP AL,0 ; JE EXTENDED_CODE ; , . ;, AL ;--- EXTENDED_CODE: INT 21H ; CMP AL,75 ; "-" JNE C_R ; , . JMP CURSOR_LEFT; , C_R: CMP AL,77 ; .. BIOS , - , MS DOS. 0 AH - 16H. AL. - . AL 0, AH . Ctrl-Break. ;--- MOV AH,0 ; INT 16H ; CMP AL,0 ; JE EXTENDED_CODE ; , . . ; AL ;--- EXTENDED_CODE: CMP AH,75 ; AH ; .. 3.1.4 . , - . , ASCII . - , - . - , , - , 25 . . - INKEY$, [3.1.3]. , . - PRINT, POKE , , [4.3.1] ( - &HB000 &HB800 - ). PRINT , - . . . KEYSTROKE$. 100 ' PRINT 110 LOCATE 10,40 ' 10,40 120 KEYSTROKE$="" ' 130 C$=INKEY$:IF C$="" THEN 130 ' 140 KEYSTROKE$=KEYSTROKE$ + C$ ' 150 PRINT C$; ' 160 GOTO 130 ' 100 ' POKE 110 DEF SEG = &HB000 ' 120 POINTER = 1678 ' 10,40 130 KEYSTROKE$="" ' 140 C$=INKEY$:IF C$="" THEN 140 ' 150 KEYSTROKE$=KEYSTROKE$ + C$ ' 160 POKE POINTER,ASC(C$) ' 170 POINTER=POINTER + 2 ' 180 GOTO 140 ' . 1 21H , , . Ctrl-Break, Ctrl-Break [3.2.8]. - AL. AL ASCII 0. AL . ;--- MOV AH,1 ; INT 21H ; CMP AL,0 ; ? JE EXTENDED_CODE ; , . . ; AL ;--- INT 21H ; AL CMP AL,77 ; "-" JNE C_R ; , JMP CURSOR_RIGHT ; , C_R: CMP AL,75 ;... .. <ESC>. - . , , . <Enter> ( ). 3.1.5 . , ; , - . , - . , - , , [3.1.2]. . INKEY$, : 100 C$=INKEY$ ' 110 IF C$ <> "" THEN...' , ... 120 ... ' . 6 21H - . Ctrl-Break. DL 0FFH. 6 - - , DL. 1, . , AL. ASCII 0 . MOV AH,6 ; DOS MOV DL,0FFH ; INT 21H ; JZ NO_CHAR ; CMP AL,0 ; JE EXTENDED_CODE ; , . ... ; AL ASCII EXTENDED_CODE: INT 21H ; ... ; AL 3.1.6 . MS DOS . , , , . , , , . - , , / . , . 3-- . , DOS . . . , INPUT. INPUT - , . <Enter> - ( <Enter> ASCII 13 ). INPUT , DOS, . INPUT , . , INPUT , . 254 . , . INPUT "", _. . . 110 INPUT "Enter your name: ",NAME$ ' 120 INPUT "Enter your age: ",AGE% ' INPUT , , . INKEY$ , , , , - , . . - . [3.1.8] , INKEY$ - . . 0AH 21H 254 , . , . DS:DX , . , . , - . . - . , 1 . - ASCII 13 - - , , . , 50- 53 ASCII 51. 50 ASCII 50, 53- - ASCII 13. ;--- STRING DB 53 DUP(?) ; 50 ;--- LEA DX,STRING ;DS:DX MOV BX,DX ; BX MOV AL,51 ; (+1 CR) MOV [BX],AL ; 1- MOV AH,0AH ; INT 21H ; ;--- MOV AH,[BX]+1 ; AH MS DOS. "-" , . - , , ( , - ). , . , , . MS DOS , . 3FH 21H - , - . (file handle), , /. 0 BX. DS:DX , , CX - : ;--- MOV AH,3FH ; MOV BX,0 ; LEA DX,STRING_BUFFER ; MOV CX,100 ; INT 21H ; DOS : (ASCII 13 ASCII 10). - , 100 102 . AX -. 3.1.7 / -. , 0040:0017 0040:0018 , - - : , = 1 0040:0017 7 Insert 6 CapsLock CapsLock 5 NumLock NumLock 4 ScrollLock ScrollLock 3 Alt 2 Ctrl 1 Shift 0 Shift 0040:0018 7 Insert 6 CapsLock 5 NumLock 4 ScrollLock 3 Ctrl-NumLock Ctrl-NumLock , -, . Ins, 8 ( Ins ). , 3 0040:0018 1, Ctrl-NumLock; , . , , , , . NumLock CapsLock, - , . , , , . , AT , . . NumLock , , 5 0040:0017 0. "" , - 223 ( 11011111B - . ). . 1, "" 32 (00100000B). 100 DEF SEG = &H40 ' 110 STATUSBYTE=PEEK(&H17) 'BIOS 120 NEWBYTE=STATUSBYTE AND 223 ' 5 130 POKE(&H17,NEWBYTE) ' , , : 120 NEWBYTE=STATUSBYTE OR 32 ' 5 130 POKE(&H17,NEWBYTE) ' 110-130 : 110 POKE(&H417,PEEK(&H417)AND 223) 110 POKE(&H417,PEEK(&H417)OR 223) . 2 16H - - . 0040:0017, . AL. ;--- MOV AH,2 ; INT 16H ; TEST AL,10000000B ; 7 JZ INSERT_OFF ; 0, INSERT . , - 7 0040:0017 ( - 0000:0417). SUB AX,AX ; MOV ES,AX ; MOV AL,10000000B ; 7 OR ES:[417H],AL ; 3.1.8 . , , . 1 2 - , - . , , . ASCII, , - . , - . - 16H. , . . 3-3. . , , , . INKEY$ -- . , ASCII 8, 9, 13 27 <BackSpace>, <Tab>, <Enter> <Escape> Ctrl-H, -I, -M -[. Ctrl, 0040:0017, . - , . 100 C$=INKEY$:IF C$="" THEN 100 ' 110 IF LEN(C$)=2 THEN 700 ' , 700 120 C=ASC(C$) ' ASCII 130 IF C<32 THEN 300 ' , 300 140 IF C<65 OR C>123 THEN 100 ' 150 ''' , , : 160 S$=S$+C$ ' 170 PRINT C$; ' 180 '''... .. 190 GOTO 100 ' . . 300 ''' ASCII 310 DEF SEG = 0 ' 320 REGISTER=PEEK(&H417) ' 330 X=REGISTER AND 4 'X=4, Ctrl 340 IF X=0 THEN 500 ' , 500 350 ''' Ctrl-, 360 IF C=8 THEN GOSUB 12000 ', - 370 ''' .. 380 GOTO 100 ' . . 500 ''' 4- : ASCII 8, 510 '''9, 13 27, Ctrl 520 IF C=8 THEN GOSUB 5000 ' <BackSpace> 530 IF C=9 THEN GOSUB 6000 ' <Tab> 540 IF C=13 THEN GOSUB 7000 ' <CR> 550 IF C=27 THEN GOSUB 8000 ' <Esc> 560 GOTO 100 ' . . 700 ''' 710 C$=RIGHT$(C$,1) ' 2- C$ 720 C=ASC(C$) ' 730 ''' C - - , , 740 IF C<71 OR C>81 THEN 100 ' 750 IF C=72 THEN GOSUB 3500 ' "-" 760 '''... .. 770 GOTO 100 ' . Ctrl-H, -I, -M -[. , , , Ctrl, -. , , - , . ;--- NEXT: MOV AH,0 ; BIOS INT 16H ; CMP AL,0 ; JE EXTENDED_CODE ; , . CMP AL,32 ; JL CONTROL_CODE ; , . CMP AL,65 ; - JL NEXT ; , CMP AL,123 ; JL NEXT ; ;--- AL STOSB ; ES:DI MOV AH,2 ; MOV DL,AL ; DL INT 21H ; . . JMP NEXT ; ;--- CONTROL_CODE: CMP AL,13 ; ASCII 13? JNE TAB ; , . CMP AH,28 ; - <CR> JNE C_M ; , Ctrl-M CALL CARRIAGE_RET; JMP NEXT ; C_M: CALL CTRL_M ; Ctrl-M JMP NEXT ; TAB: CMP AL,9 ; ... . . CMP AL,10 ; . . REJECT: JMP NEXT ; ;--- (2- AH): EXTENDED_CODE: CMP AH,71 ; JL REJECT ; , . CMP AH,81 ; JL REJECT ; , . ;---AH , : CMP AH,72 ;"-"? JE C_U ; , CMP AH,80 ;"-"? JE C_D ; , . . C_U: CALL CURSOR_UP ; JMP NEXT ; C_D: CALL CURSOR_DOWN ; JMP NEXT ; 3.1.9 . - A 8255 ( 60H - . [1.1.1]), 9. - - , -, . ( - -, , <Ins>, , BIOS [3.1.7]). " " DOS BIOS " ". . , - , 9. - , PCjr (INT 48H) 62 83- , IBM PC. 9, . - 49H PCjr -, - , () . , - , , MS DOS [3.2.6]. 9, . - [1.2.3], . : 1. - - . 2. - - -. 3. . - A. . B ( 61H), - . - 7 1, 0. , 6 B . 1, . AT, 8255. - , - ( ) ( ). , AT, 7 - 1. AT, 7 0, : 0F0H, -. , - -, - . , - . - -. , , , , - 30 - A. , ASCII . , - . - , XLAT. XLAT AL 0 255, AL 1-- 256- , DS:BX. . AL - 30, 30 (31- , ). 97, ASCII "a". - A , , . , - , - -. , . , . [3.1.1] , . 0040:001A - , 0040:001C - . BIOS ( 40H) 30 60. - , , . , - 2 - , 30 ( ), , 60. , , 2; 60, 30. . . 3-4. . . . , - , 100 , . CapsLock . ;--- TABLE DB 16 DUP(0) ; 1- 16 DB 'qwertyuiop',0,0,0,0 ; DB 'asdfghjkl',0,0,0,0,0 ; DB 'zxcvbnm' ; DB 16 DUP(0) ; DB 'QWERTYUIOP',0,0,0,0 ; DB 'ASDFGHJKL',0,0,0,0,0 ; DB 'ZXCVBNM' ; ;--- CLI ; PUSH DS ; MOV AX,SEG NEW_KEYBOARD ;DS:DX MOV DS,AX ; MOV DX,OFFSET NEW_KEYBOARD ; MOV AL,9 ; MOV AH,25H ; DOS INT 21H ; POP DS ; STI ; , [1.3.4]. ;--- NEW_KEYBOARD PROC FAR ; PUSH AX ; PUSH BX ; PUSH CX ; PUSH DI ; PUSH ES ; ;--- - IN AL,60H ; - A MOV AH,AL ; AH PUSH AX ; - IN AL,61H ; B OR AL,10000000B ; 7 OUT 61H,AL ; AND AL,01111111B ; 7 OUT 61H,AL ; B ;---ES BIOS MOV AX,40H ; MOV ES,AX ; POP AX ; - ;--- CMP AL,42 ; ? JNE KEY_UP ; - MOV BL,1 ; - OR ES:[17H],BL ; JMP QUIT ; KEY_UP: CMP AL,170 ; ? JNE NEXTKEY ; - MOV BL,11111110B ; - AND ES:[17H],BL ; JMP QUIT ; NEXTKEY: ; ;--- - - TEST AL,10000000B ; ? JNZ QUIT ; - MOV BL,ES:[17H] ; TEST BL,00000011B ; ? JZ CONVERT_CODE ; - ADD AL,100 ; - CONVERT_CODE: MOV BX,OFFSET TABLE ; XLAT TABLE ; - ASCII CMP AL,0 ; 0? JE QUIT ; , ;--- , MOV BX,1AH ; MOV CX,ES:[BX] ; MOV DI,ES:[BX]+2 ; CMP CX,60 ; ? JE HIGH_END ; - . INC CX ; INC CX ; 2 CMP CX,DI ; JE QUIT ; , JMP GO_AHEAD ; HIGH_END: CMP DI,30 ; . JE QUIT ; , ;--- - GO_AHEAD: MOV ES:[DI],AL ; CMP DI,60 ; ? JNE NO_WRAP ; , 2 MOV DI,28 ; = 28+2 NO_WRAP: ADD DI,2 ; MOV ES:[BX]+2,DI ; ;--- QUIT: POP ES ; POP DI ; POP CX ; POP BX ; POP AX ; MOV AL,20H ; OUT 20H,AL ; IRET ; NEW_KEYBOARD ENDP  2. . , -, -- . , , . , <Backspace> - ASCII, <Delete> - . Ctlr , - . - ASCII: - ASCII, , () . , . ASCII , 3 . , , , - ( ), DOS. 3.2.1 <BackSpace>, <Enter>, <Escape> <Tab>. <BackSpace>, <Enter>, <Escape> <Tab> - , - ASCII. [7.1.9], 32 ASCII. Ctrl: ASCII 8 BackSpace Ctrl + H ASCII 9 Tab Ctrl + I ASCII 13 Enter Ctrl + M ASCII 27 Escape Ctrl + [ [3.2.2] - Ctrl. , , - <Shift> + <Tab>, 0;15. - . - INPUT <Backspace>, <Tab> <Enter>. INKEY$ , . - . , - TAB. BIOS DOS, <BackSpace> <Tab>. , ASCII AL, - , , . 3.2.2 -: <Shift>, <Ctrl> <Alt>. - - . , . ASCII: (1) <Shift> - (2) Ctrl-A Ctrl-Z ASCII 1 26. - , [3.3.5]. PCjr , . , . Ctrl-Alt, - , , Alt, Ctrl, Shift. [3.1.7]