3 TITLE DOS KEYB Command
- Interrupt
9 Non
-US Support
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;; DOS - NLS Support - KEYB Command
7 ;; (C) Copyright 1988 Microsoft
9 ;; File Name: KEYBI9.ASM
14 ;; Converts scan codes to ASCII for non-US keyboards.
15 ;; This orutine uses the tables loaded into the SHARED_DATA_AREA
16 ;; from KEYBOARD.SYS by the KEYB_COMMAND module.
18 ;; Documentation Reference:
19 ;; ------------------------
20 ;; PC DOS 3.3 Detailed Design Document - May 1986
22 ;; Procedures Contained in This File:
23 ;; ----------------------------------
24 ;; KEYB_STATE_PROCESSOR - Scan to ASCII translator.
26 ;; External Procedure References:
27 ;; ------------------------------
30 ;; Linkage Information: Refer to file KEYB.ASM
31 ;; --------------------
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 INCLUDE KEYBEQU
.INC ;;
41 INCLUDE DSEG
.inc ;; System data segments
42 INCLUDE POSTEQU
.inc ;; System equates
43 INCLUDE KEYBSHAR
.INC ;;
44 INCLUDE KEYBI2F
.INC ;;
45 INCLUDE KEYBI9C
.INC ;;
46 INCLUDE KEYBCPSD
.INC ;;
47 INCLUDE KEYBCMD
.INC ;;
49 PUBLIC KEYB_STATE_PROCESSOR
;;
51 CODE SEGMENT PUBLIC 'CODE' ;;
53 ASSUME
CS:CODE,DS:CODE ;;
55 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
57 ;; Procedure: KEYB_STATE_PROCESSOR
60 ;; Convert scan to ASCII using the tables loaded into the
61 ;; SHARED_DATA_AREA. Conversion is directed by the STATE LOGIC
62 ;; commands contained in the SHARED_DATA_AREA. This routine
63 ;; interprets those commands.
76 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80 HOT_KEY_ACTIVE
DB 0 ;; 1 if hot key is active
83 ;; These are copies of the BIOS FLAGS
84 FLAGS_TO_TEST
LABEL BYTE ;; KB_FLAG, KB_FLAG_1,2,3
85 KB_SHADOW_FLAGS
DB NUM_BIOS_FLAGS
DUP(0) ;;
86 EXT_KB_FLAG
DB 0 ;; Extended KB Flag for shift states
87 NLS_FLAG_1
DB 0 ;; NLS Flags for dead key etc
90 SAVED_NLS_FLAGS
DB 0,0 ;; Saved copy of the NLS flags
92 OPTION_BYTE
DB 0 ;; Set by OPTION command
94 KB_FLAG_PTRS
DW OFFSET KB_FLAG
;; These are pointers to the BIOS flags
95 DW OFFSET KB_FLAG_1
;; we must test
96 DW OFFSET KB_FLAG_2
;;
97 DW OFFSET KB_FLAG_3
;;
99 XLAT_TAB_PTR
DW 0 ;; pointer to xlat tables for cur state
101 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
105 PROCESS_LEVEL
DB 0 ;;
107 BUSY_FLAG
DB 0 ;; Flag to prevent re-entry
109 CMD_JUMP_TABLE
LABEL WORD ;;
110 DW OFFSET IFF_PROC
;; CODE 0
111 DW OFFSET ANDF_PROC
;; 1
112 DW OFFSET ELSEF_PROC
;; 2
113 DW OFFSET ENDIFF_PROC
;; 3
114 DW OFFSET XLATT_PROC
;; 4
115 DW OFFSET OPTION_PROC
;; 5
116 DW OFFSET SET_FLAG_PROC
;; 6
117 DW OFFSET PUT_ERROR_PROC
;; 7
118 DW OFFSET IFKBD_PROC
;; 8
119 DW OFFSET GOTO_PROC
;; 9
120 DW OFFSET BEEP_PROC
;; A
121 DW OFFSET RESET_NLS_PROC
;; B
122 DW OFFSET UNKNOWN_COMMAND
;; C
123 DW OFFSET UNKNOWN_COMMAND
;; D
124 DW OFFSET UNKNOWN_COMMAND
;; E
125 DW OFFSET UNKNOWN_COMMAND
;; F
128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
130 KEYB_STATE_PROCESSOR PROC
NEAR ;;
132 TEST CS:SD
.TABLE_OK
,1 ;;
133 JNZ WE_HAVE_A_TABLE
;;
134 CLC ;; BACK TO US INT 9
143 PUSH AX ;; save scan code for caller
144 PUSH BX ;; save shift states for caller
147 POP DS ;; DS = our seg
149 MOV ES,BX ;; addressability to BIOS data
152 CMP COUNTRY_FLAG
,0FFH ;; Q..country mode?
153 JE INIT_STATE_PROCESSING
;; Y..continue
154 JMP GOTO_BIOS
;; N..exit
156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
157 ;; -------STATE SECTION PROCESSING-------
158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
160 INIT_STATE_PROCESSING: ;;
161 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
162 ;; Set NLS shift flags EITHER_SHIFT, EITHER_ALT, EITHER_CTRL
163 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
165 ;; Q..in shift state?
166 TEST ES:KB_FLAG
,RIGHT_SHIFT
+LEFT_SHIFT
167 JNZ IN_SHIFT_STATE
;; Y..go set bit
168 AND EXT_KB_FLAG
,NOT EITHER_SHIFT
;; N..clear bit
169 JMP SHORT TEST_CTL
;;
171 OR EXT_KB_FLAG
,EITHER_SHIFT
;;
173 TEST ES:KB_FLAG
,CTL_SHIFT
;; Q..in control state?
174 JNZ IN_CTL_STATE
;; Y..go set bit
175 TEST ES:KB_FLAG_3
,R_CTL_SHIFT
;; Q..how bout the right ctl?
176 JNZ IN_CTL_STATE
;; Y..go set the bit
177 AND EXT_KB_FLAG
,NOT EITHER_CTL
;; N..clear the bit
178 JMP SHORT TEST_ALT
;;
180 OR EXT_KB_FLAG
,EITHER_CTL
;;
182 TEST ES:KB_FLAG
,ALT_SHIFT
;; Q..in alt state?
183 JNZ IN_ALT_STATE
;; Y..go set bit
184 TEST ES:KB_FLAG_3
,R_ALT_SHIFT
;; Q..how bout the right alt?
185 JNZ IN_ALT_STATE
;; Y..go set the bit
186 AND EXT_KB_FLAG
,NOT EITHER_ALT
;; N..clear the bit
187 JMP SHORT COPY_FLAGS
;;
189 OR EXT_KB_FLAG
,EITHER_ALT
;;
191 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
192 ;; Copy BIOS KB flags from BIOS data seg into the
193 ;; FLAGS_TO_TEST structure.
194 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
197 MOV CX,NUM_BIOS_FLAGS
;;
198 MOV SI,0 ;; pointers to the BIOS flags
199 MOV DI,0 ;; create shadow copies
201 MOV BX,KB_FLAG_PTRS
[SI] ;; pointer to next flag
202 MOV AL,ES:[BX] ;; flag in AL
203 MOV KB_SHADOW_FLAGS
[DI],AL ;; save it in the shadow table
207 LOOP MOVE_NEXT_FLAG
;;
209 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
210 ;; Interpret State Logic Commands
211 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
214 MOV OPTION_BYTE
,0 ;; clear options
215 MOV SI,SD
.LOGIC_PTR
;;
216 LEA SI,[SI].SL_LOGIC_CMDS
;;
218 MOV BL,[SI] ;; command byte in BL
222 SHR BL,1 ;; ISOLATE COMMAND CODE
223 SHL BL,1 ;; command code * 2
224 JMP CMD_JUMP_TABLE
[BX] ;; go process command
226 JMP FATAL_ERROR
;; bad news
229 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
232 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
233 JNE IFKBD_DONE
;; N..don't process
235 MOV AX,[SI+1] ;; Keyboard Type Flag
237 TEST SD
.KEYB_TYPE
,AX ;; Q..are we the right system?
238 JNZ IFKBD_TEST_OK
;; Y..
239 IFKBD_TEST_FAILED: ;;
240 MOV TAKE_ELSE
,YES
;; test failed - take ELSE
241 JMP SHORT IFKBD_DONE
;;
243 INC PROCESS_LEVEL
;; process commands within IF
246 INC NEST_LEVEL
;; IFKBD increments nest level
247 INC SI ;; bump past IFKBD
252 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
256 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
257 JNE PUT_ERROR_DONE
;; N..don't process
258 MOV DI,SD
.ACTIVE_XLAT_PTR
;; pointer to active Xlat Section
259 MOV AL,[SI+1] ;; state id in AL
260 CALL PUT_ERROR
;; check active section
261 JC PUT_ERROR_DONE
;; carry set if translation found
262 MOV DI,SD
.COMMON_XLAT_PTR
;; check common Xlat Section
263 MOV AL,[SI+1] ;; state id for XLATT in AL
272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
273 ;; Search for a state whose ID matches the ID
274 ;; on the PUT_ERROR command
275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
278 LEA DI,[DI].XS_FIRST_STATE
;; point to first state in section
280 CMP [DI].XS_STATE_LEN
,0 ;; Q..out of states?
281 JE PE_EXIT
;; Y..exit
282 CMP AL,[DI].XS_STATE_ID
;; Q..is this the requested state?
284 ADD DI,[DI].XS_STATE_LEN
;; N..check next state
285 JMP SHORT PE_NEXT_STATE
;;
288 MOV AX,[DI].XS_ERROR_CHAR
;; get error char in AX
290 STC ;; indicate that we found the state
296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
299 CLC ;; clear carry flag indicating
300 POP BX ;; we should continue INT 9
306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
310 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
311 JNE IFF_DONE
;; N..don't process IFF
312 MOV BL,[SI] ;; command byte
313 AND BL,FLAG_ID_BITS
;; isolate flag id
315 MOV AL,FLAGS_TO_TEST
[BX] ;; flag in AL
316 TEST BYTE PTR[SI],NOT_TEST
;; Q..is this a NOT test?
318 TEST AL,[SI]+1 ;; Y..check for bit set
322 TEST AL,[SI]+1 ;; Y..check for bit clear
325 MOV TAKE_ELSE
,YES
;; flag test failed - take ELSE
326 JMP SHORT IFF_DONE
;;
328 INC PROCESS_LEVEL
;; process commands within IF
332 INC NEST_LEVEL
;; IFF increments nest level
333 INC SI ;; bump past IFF
337 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
340 MOV AL,PROCESS_LEVEL
;;
341 CMP AL,NEST_LEVEL
;; Q..nest level = process level?
342 JNE CHECK_TAKE_ELSEF
;; N..check for take_else
343 DEC PROCESS_LEVEL
;; Y..we just finished the "IF" block
344 JMP ELSEF_DONE
;; so we are finished with IFF/ELSEF
346 CMP TAKE_ELSE
,YES
;; Q..are we scanning for ELSE?
347 JNE ELSEF_DONE
;; N..done
348 DEC NEST_LEVEL
;; ELSEF itself is back a level
349 CMP AL,NEST_LEVEL
;; Q..nest level = process level?
350 JNE NOT_THIS_ELSEF
;; N..this else is not the one
351 INC PROCESS_LEVEL
;; Y..process ELSEF block
352 MOV TAKE_ELSE
,NO
;; reset
354 INC NEST_LEVEL
;; stuff within the ELSEF is up a level
357 INC SI ;; bump past ELSEF
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362 MOV AL,PROCESS_LEVEL
;;
363 CMP AL,NEST_LEVEL
;; Q..nest level = process level?
364 JNE ENDIFF_DONE
;; N..don't adjust process level
365 DEC PROCESS_LEVEL
;; Y..we just finished the IF/ELSE
367 DEC NEST_LEVEL
;; ENDIF decrements nest level
368 INC SI ;; bump past ENDIF
371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
372 ;; Translations may be in the Common or Specific
373 ;; Sections. Search the Specific section first
374 ;; then the common section.
375 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
377 MOV AL,PROCESS_LEVEL
;;
378 CMP AL,NEST_LEVEL
;; Q..nest level = process level?
379 JNE XLATT_DONE
;; N..next command
380 MOV DI,SD
.ACTIVE_XLAT_PTR
;; pointer to active Xlat Section
381 MOV AL,[SI+1] ;; state id for XLATT in AL
382 CALL TRANSLATE
;; check active section
383 JC XLATT_FOUND
;; carry set if translation found
384 MOV DI,SD
.COMMON_XLAT_PTR
;; check common Xlat Section
385 MOV AL,[SI+1] ;; state id for XLATT in AL
389 OR EXT_KB_FLAG
,SCAN_MATCH
;; set flag indicating scan matched
390 TEST OPTION_BYTE
,EXIT_IF_FOUND
;; Q..exit
400 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
401 ;; Search for a state whose ID matches the ID
402 ;; on the XLATT command
403 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
406 LEA DI,[DI].XS_FIRST_STATE
;; point to first state in section
408 CMP [DI].XS_STATE_LEN
,0 ;; Q..out of states?
409 JE TP_EXIT
;; Y..exit
410 CMP AL,[DI].XS_STATE_ID
;; Q..is this the requested state?
412 ADD DI,[DI].XS_STATE_LEN
;; N..check next state
413 JMP SHORT TP_NEXT_STATE
;;
416 AND EXT_KB_FLAG
,NOT SCAN_MATCH
;; reset flag before search
417 PUSH SI ;; save pointer to next command
418 LEA SI,[DI].XS_FIRST_TAB
;; point to first xlat table
419 MOV XLAT_TAB_PTR
,SI ;; start of XLAT tables
420 MOV AL,SCAN_CODE
;; restore incoming scan code
421 JMP SHORT NEXT_XLAT_TAB
;;
422 TP_DONE: ;; return here from XLAT
427 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
428 ;; Check xlate tables for matching scan code
429 ;; The xlate table can be in one of two forms:
430 ;; Type 1 = Table contains buffer entries only.
431 ;; Scan code is used as an index into xlat table
432 ;; Type 2 = Table contains pairs of SCAN/BUFFER_ENTRY.
433 ;; Table must be searched for matching scan.
434 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
437 MOV SI,XLAT_TAB_PTR
;; pointer to xlat tables
438 CMP [SI].XLAT_TAB_SIZE
,0 ;; Q..any more xlat tables?
439 JNE PROCESS_XLAT_TAB
;; Y..check um
440 JMP TP_DONE
;; N..done
442 MOV DL,[SI].XLAT_OPTIONS
;; save translate options IN DL
443 MOV BX,[SI].XLAT_TAB_SIZE
;; Y..calc pointer to next xlat tab
445 MOV XLAT_TAB_PTR
,BX ;; pointer to next xlat tab
446 TEST DL,TYPE_2_TAB
;; Q..is this a type 2 table?
447 JZ TYPE_1_LOOKUP
;; N..go do table lookup
448 TYPE_2_SEARCH: ;; Y..search table
450 MOV CL,[SI].XLAT_NUM
;; number of xlat entries
451 MOV BX,DEFAULT_TAB_2_ENT_SZ
;; default entry size
452 TEST DL,ASCII_ONLY
+ZERO_SCAN
;; Q..are buffer entries ASCII only?
453 JZ NEXT_TAB_2_ENTRY
;; N..continue
454 MOV BX,ASC_ONLY_TAB_2_ENT_SZ
;; Y..set size in BX
455 NEXT_TAB_2_ENTRY: ;; entry size is in BX
456 CMP CX,0 ;; Q..last entry?
457 JE NEXT_XLAT_TAB
;; y..go to next table
458 CMP AL,[SI].XLAT_SCAN
;; Q..scan match?
459 JE FOUND_TAB_2_ENTRY
;; Y..go create buffer entry
460 ADD SI,BX ;; point to next entry
461 LOOP NEXT_TAB_2_ENTRY
;;
462 JMP SHORT NEXT_XLAT_TAB
;;
463 FOUND_TAB_2_ENTRY: ;; Q..set scan code to 0?
464 MOV AH,AL ;; default scan code in AH
465 MOV AL,[SI].XLAT_2_BUF_ENTRY
;; ASCII code from table in AL
466 TEST DL,ASCII_ONLY
+ZERO_SCAN
;; Q..are buffer entries ASCII only?
467 JNZ BUFFER_ENTRY_READY
;; Y..buffer entry is ready
468 MOV AH,[SI].XLAT_2_BUF_ENTRY
+1 ;; N..scan code from table as well
469 JMP SHORT BUFFER_ENTRY_READY
;; go put entry in buffer
472 CMP AL,[SI].XLAT_SCAN_LO
;; Q..is scan in range of this table?
473 JB NEXT_XLAT_TAB
;; N..next table
474 CMP AL,[SI].XLAT_SCAN_HI
;; Q..is scan in range of this table?
475 JA NEXT_XLAT_TAB
;; N..next table
476 SUB AL,[SI].XLAT_SCAN_LO
;; convert scan code to xlat index
477 TEST DL,ASCII_ONLY
+ZERO_SCAN
;; Q..ASCII only in xlat ?
478 JZ TWO_BYTE_LOOKUP
;; N..go do 2-byte lookup
479 LEA BX,[SI].XLAT_1_BUF_ENTRY
;; Y..do 1-byte lookup
480 XLAT [SI].XLAT_1_BUF_ENTRY
;; ASCII code in AL
481 MOV AH,SCAN_CODE
;; SCAN in AH
482 JMP SHORT BUFFER_ENTRY_READY
;; go put entry in buffer
484 MOV BL,2 ;; multiply scan index
486 MOV BX,AX ;; real index in BX
487 MOV AX,WORD PTR [SI].XLAT_1_BUF_ENTRY
[BX] ;; get 2-byte buffer entry
489 BUFFER_ENTRY_READY: ;;
490 TEST DL,ZERO_SCAN
;; Q..set scan part to zero?
491 JZ NO_ZERO_SCAN
;; N..
492 XOR AH,AH ;; scan = 0
494 CALL BUFFER_FILL
;; go put entry in buffer
495 STC ;; indicate translation found
500 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
502 MOV AL,PROCESS_LEVEL
;;
503 CMP AL,NEST_LEVEL
;; Q..nest level = process level?
504 JNE DONE_OPTION
;; N..done
505 MOV AL,[SI]+1 ;; mask in AL
506 TEST BYTE PTR[SI],NOT_TEST
;; Q..is this a NOT?
508 OR OPTION_BYTE
,AL ;; N..OR in the mask bits
512 AND OPTION_BYTE
,AL ;; Y..AND out the mask bits
517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
520 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
521 JNE RN_DONE
;; N..don't process
527 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
530 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
531 JNE BP_DONE
;; N..don't process
532 MOV BEEP_PENDING
,YES
;; set beep pending flag. the beep
533 ;; will be done just before iret
537 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
540 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
541 JNE GOTO_DONE
;; N..don't process
542 MOV BL,[SI] ;; command byte in BL
543 AND BL,NOT COMMAND_BITS
;; remove command code
544 OR BL,BL ;; Q..goto label?
545 JZ GOTO_LABEL
;; Y..go jump
546 CMP BL,EXIT_INT_9_FLAG
;; Q..SPECIAL - Exit Int 9?
547 JNE NOT_EXIT_INT_9
;; N..
548 JMP EXIT
;; Y..bye bye
550 CMP BL,EXIT_STATE_LOGIC_FLAG
;; Q..SPECIAL - Exit State Logic?
551 JNE NOT_EXIT_S_L
;; N..
552 JMP GOTO_BIOS
;; Y..goto bios
554 JMP FATAL_ERROR
;; garbage in that command
556 ADD SI,[SI]+1 ;; bump by relative offset
557 MOV PROCESS_LEVEL
,0 ;; reset process and nest level
560 ADD SI,3 ;; bump to next command
562 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
566 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
567 JNE ANDF_DONE
;; N..don't process ANDF
568 MOV BL,[SI] ;; command byte
569 AND BL,FLAG_ID_BITS
;; isolate flag id
571 MOV AL,FLAGS_TO_TEST
[BX] ;; flag in AL
572 TEST BYTE PTR[SI],NOT_TEST
;; Q..is this a NOT test?
574 TEST AL,[SI]+1 ;; Y..check for bit set
575 JNZ ANDF_DONE
;; if set then remain in IFF
578 TEST AL,[SI]+1 ;; Y..check for bit clear
579 JZ ANDF_DONE
;; if clear then remain in IFF
581 MOV TAKE_ELSE
,YES
;; flag test failed - take ELSE
582 DEC PROCESS_LEVEL
;; IFF would have inc'd - so dec
584 INC SI ;; bump past ANDF
588 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
590 ;; Flag Table must be in the Common Section
591 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
595 CMP AL,PROCESS_LEVEL
;; Q..nest level = process level?
596 JNE SF_DONE
;; N..don't process
598 MOV DI,SD
.COMMON_XLAT_PTR
;; check common Xlat Section
599 MOV AL,[SI+1] ;; state id in AL
600 LEA DI,[DI].XS_FIRST_STATE
;; point to first state in section
602 CMP [DI].XS_STATE_LEN
,0 ;; Q..out of states?
603 JE SF_DONE
;; Y..exit
604 CMP AL,[DI].XS_STATE_ID
;; Q..is this the requested state?
606 ADD DI,[DI].XS_STATE_LEN
;; N..check next state
607 JMP SHORT SF_NEXT_STATE
;;
610 AND EXT_KB_FLAG
,NOT SCAN_MATCH
;; reset flag before search
611 PUSH SI ;; save pointer to next command
612 LEA SI,[DI].XS_FIRST_TAB
;; point to table
613 MOV AL,SCAN_CODE
;; restore incoming scan code
614 MOV CX,[SI] ;; number of entries
615 CMP CX,0 ;; Q..any entries?
616 JE SF_RESTORE
;; N..done
617 INC SI ;; Y..Bump to first entry
620 CMP AL,[SI] ;; Q..scan match?
621 JE FOUND_SF_ENTRY
;; Y..go set flag
622 ADD SI,3 ;; point to next entry
623 LOOP NEXT_SF_ENTRY
;;
624 JMP SHORT SF_RESTORE
;; no match found
626 MOV NLS_FLAG_1
,0 ;; clear all NLS bits
628 MOV BL,[SI]+1 ;; flag id in BX
630 MOV AL,[SI]+2 ;; mask in AL
631 OR FLAGS_TO_TEST
[BX],AL ;; set the bit
632 OR EXT_KB_FLAG
,SCAN_MATCH
;; set flag indicating scan matched
633 TEST OPTION_BYTE
,EXIT_IF_FOUND
;; Q..exit
640 INC SI ;; bump past command
645 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
646 ;; Fatal Error routine. Come here when
647 ;; we have a critical error such as an
648 ;; invalid State Logic Command.
649 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
652 JMP SHORT EXIT
;; end the int 9 processing
654 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
656 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
660 STC ;; indicate we should end INT 9
667 KEYB_STATE_PROCESSOR ENDP
;;