]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DEV/PRINTER/CPSPI.ASM
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;; FILENAME: CPS Printer Device Driver INIT module (CPSPInn)
8 ;; TYPE: Assemble file (non-resident code)
9 ;; LINK PROCEDURE: Link CPSPMnn+CPSFONT+CPSPInn into .EXE format. CPSPM01
10 ;; must be first. CPSPInn must be last. Everything
11 ;; before CPSPInn will be resident.
15 ;; LAYOUT : This file is divided into two main section :
16 ;; ++++++++++++++++++++++++
17 ;; ++ DEVICE Parser ++
18 ;; ++++++++++++++++++++++++
20 ;; ++++++++++++++++++++++++
22 ;; ++++++++++++++++++++++++
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 INCLUDE CPSPEQU
.INC ;;
28 PUBLIC CODE_END
;; for MAP listing only
29 PUBLIC RESIDENT_END
;;
30 PUBLIC STACK_ALLOCATED
;;
33 EXTRN PRINTER_DESC_NUM
:WORD ;;
34 EXTRN PRINTER_DESC_TBL
:WORD ;;
35 EXTRN INIT_CHK
:WORD,TABLE
:WORD ;;
36 EXTRN HARD_SL1
:BYTE,RAM_SL1
:BYTE ;;
37 EXTRN HARD_SL2
:BYTE,RAM_SL2
:BYTE ;;
38 EXTRN HARD_SL3
:BYTE,RAM_SL3
:BYTE ;;
39 EXTRN HARD_SL4
:BYTE,RAM_SL4
:BYTE ;;
40 EXTRN RESERVED1
:WORD,RESERVED2
:WORD ;;
42 EXTRN MSG_NO_INIT_P
:BYTE ;;
43 EXTRN MSG_NO_INIT
:BYTE ;;
44 EXTRN MSG_BAD_SYNTAX
:BYTE ;;
45 EXTRN MSG_INSUFF_MEM
:BYTE ;;
48 CSEG
SEGMENT PARA
PUBLIC 'CODE' ;;
52 CODE_END EQU
$ ;; end of resident code
54 DW 0 ;; -- there are 16 bytes kept,
55 ;; including this word
57 RESIDENT_END
DW 0FFFH ;; end of extended resident area
58 STACK_ALLOCATED
DW -1 ;; end of extended resident area
60 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62 ;; End of resident code
64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
66 ;; Incorporating Device Command Parser :
68 ;; -- extracted from PARSE4E.ASM, size 49582 bytes
70 ;; (some modifications have to be made in the section right after the parser's
71 ;; document and before the GET_PARMS_A, one of them is :)
73 ;; -- move the TABLE to the printer device driver's main module
75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
77 ;; ++++++++++++++++++++++++
78 ;; ++ DEVICE Parser ++
79 ;; ++++++++++++++++++++++++
81 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
84 ;; PARSER's code -- non resident
86 ;; -- set ES:[DI] pointing to the Request Header before calling PARSER
88 ;; to be called as PARSER with ES:[DI] defined as Request Header
89 ;; If there is any syntax error in the DEVICE command line, the
90 ;; Parser return a 0 in the first word (NUMBER)of the first table.
92 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
95 ; Description: A command parser for DEVICE command in the CONFIG.SYS file.
98 ; Procedures contained in the file:
99 ; ---------------------------------
100 ; PARSER: Main routine for command processing.
101 ; GET_CHAR: Gets a character from command line.
102 ; IS_ALPH: Checks if character is an alpha character.
103 ; IS_DIGIT: Checks if character is a digit.
104 ; IS_DELIM: Checks if character is a DOS delimiter.
105 ; DEVICE_PARSE: Pulls device name from command line and
107 ; ID_PARSE: Pulls id name from command line and insers in table
108 ; HWCP_PARMS: Extract HWCP number, converts it to binary and
109 ; inserts it in table.
110 ; HWCP_PARSE: Extracts HWCP number if only one number is given.
111 ; MUL_HWCP: Extracts multiple HWCP's numbers, if they are given
113 ; DESG_PARMS: Extracts designate number, converts it to binary
114 ; and inserts it in table.
115 ; DESG_FONT: Extracts the designate and the font if both were
116 ; given in command line.
117 ; DESG_PARSE: Pulls designate number if it is the only one given.
118 ; GET_NUMBER: Converts a number to binary.
119 ; OFFSET_TABLE: Updates the counter in table #1.
120 ; FIND_RIGHT_BR: Looks for a right bracket.
129 ; Establish addressability to parameters.
130 ; Skip until end of path and file name -first delimiter
133 ; Isolate the first non-delimiter or non delimeter characters.
134 ; If End_of_Line_Delimiter then
135 ; return an error_code
137 ; If first non-delimiter is ALPHA then
138 ; (assume a device name)
139 ; Extracts device name
140 ; Update offset counter
142 ; Isolate the first non-delimiter characters after id name.
143 ; If End_of_Line_Delimiter then
144 ; return an error_code
146 ; If first non-delimiter is ALPHA-NUMARIC or
147 ; If character is '(' then
148 ; (assume an id name)
150 ; Update offset counter
153 ; If error flag is set then exit
154 ; Else if end of line flag is set then exit
156 ; Pull out DESG parms
157 ; If error_flag is set then exit.
158 ; Else if end of line flag is set then exit
159 ; Else if Number of devices is four then Exit
168 ; Load character in AL
169 ; If character less than 20h then
175 ; 'Convert character to upper case'
176 ; If character >=A and <=Z then
184 ; --------- If Character >=0 and <=9 then
189 ; If character a dos delimiter (' ','=',',',';',TAB)
190 ; then turn Z-flag on
194 ; Set device name length counter.
196 ; If a dos delimiter then
197 ; add spaces to name (if require)
198 ; Else if char is ALPHA-NUM then
200 ; If name >8 character thne
206 ; --------- Set id name length counter.
208 ; If a dos delimiter then
209 ; add spaces to name (if require)
210 ; Else if char is ALPHA-NUM then
212 ; If name >8 character then
214 ; Else if char is ')' or '(' then
221 ; Loop: Set flags off
222 ; If char is a DIGIT then
223 ; convert number to binary
225 ; Else if char is ',' then
228 ; Else if char is '(' then
229 ; assume multiple HWCP
230 ; Else if char is ')' then
232 ; Else if not a delimiter then
233 ; error, exit set carry flag set carry flag
237 ; ----------- Increment counter
238 ; Get number and convert to binary
240 ; Set table_5 pointer
244 ; Loop: If char is ')' then
247 ; Get number and convert to binary
249 ; If char is not a delimiter then
250 ; error, exit set carry flag
255 ; Loop: If char is a DIGIT then
256 ; Get number and convert to binary
258 ; If char is a ')' then
260 ; If char is a '(' then
261 ; assume given desg. and font
262 ; If char is a ',' then
265 ; If char is not a delimiter then
266 ; error, exit set carry flag
271 ; Loop: If char is a ',' then
272 ; no desg number was given
274 ; If char is a ')' then
275 ; end of desg-font pair, exit
276 ; If char is a DIGIT then
277 ; Get number and convert to binary
279 ; If char not a delimiter then
280 ; error, exit set carry flag
284 ; ----------- Get number and conver to binary
288 ; ----------- Get ASCII number from parms
294 ; Increment the number of parms
298 ; Loop: If char is ')' then
300 ; If char is not ' ' then
301 ; error, exit set carry flag
304 ;------------------------------------------------------
306 ; The following is the table structure of the parser. All fields are
307 ; two bytes field (accept for the device and id name)
311 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
312 ; ³ N = Number of devices. ³
313 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
314 ; ³ Device # 1 offset ÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
315 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³
316 ; ³ Device # 2 offset ³ ³ Table_1 (a) ³
317 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³
318 ; ³ Device # 3 offset ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
319 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
320 ; ³ Device # 4 offset ³
321 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
324 ; N = 1,2,3 or 4. A two bytes number indicating the number of device specified.
325 ; DEVICE # N OFFSET : a two bytes offset address to table_1. (ie. Device #1 offset
326 ; is a pointer to table_1 (a). Device #2 offset is a pointer to table_1
327 ; (b)...etc.). If an error was detected in the command N is set to zero.
334 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
335 ; ³ N = Number of Offsets. ³ ³ ³
336 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ÚÄÄÄÄÄij Table_2 (a) ³
337 ; ³ Device Name offset ÄÅÄÄÄÄÙ ³ ³
338 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
339 ; ³ Device Id offset ÄÅÄÄÄÄÄÄ¿
340 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
341 ; ³ Device HWCP offset ÄÅÄÄÄÄ¿ ³ ³ ³
342 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ÀÄÄÄij Table_3 (a) ³
343 ; ³ Device Desg offset ÄÅÄÄ¿ ³ ³ ³
344 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
346 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
348 ; ³ ÀÄÄÄÄÄij Table_4 (a) ³
350 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
351 ; ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
353 ; ÀÄÄÄÄÄÄÄij Table_5 (a) ³
355 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
358 ; N=Length of table_1, or the number of offsets contained in table_1.
359 ; The offsets are pointers (two bytes) to the parameters value of the device.
360 ; "Reserved" : a two byte memory reserved for future use of the "PARMS" option.
366 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
367 ; ³ N = Length of devices name ³
368 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
370 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
372 ; N = Length of device name. Device length is always 8 byte long.
373 ; Device Name : the name of the device (eg. LPT1, CON, PRN). The name
374 ; is paded with spaces to make up the rest of the 8 characters.
381 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
382 ; ³ N = Length of Id name. ³
383 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
385 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
387 ; N = Length of id name. Id name length is always 8 byte long.
388 ; Id Name : the name of the id (eg. EGA, VGA, 3812). The name
389 ; is paded with spaces to make up the rest of the 8 character.
396 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
397 ; ³ N = Length of table. ³
398 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
400 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
402 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
406 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
408 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
411 ; N = Length of table in words. Or the number of HWCP's.
412 ; HWCP # N : a hardware code page number converted to binary. The maximum
413 ; number of pages allowed is 10.
420 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
421 ; ³ N = Length of table. ³
422 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
424 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
426 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
428 ; N = Lenght of table. 0 - nothing was specified
429 ; 1 - Only a designate was specified.
430 ; 2 - Designate and font were given. If the Desg field
431 ; was left empty in the DEVICE command then the
432 ; Designate field is filled with 0FFFFH.
433 ; Designate, Font : Are the Desg. and Font binary numbers.
435 ;------------------------------------------------------
439 TABLE_1
DW ?
; Pointer at offsets.
440 TABLE_2
DW ?
; Pointer at device name.
441 TABLE_3
DW ?
; Pointer at id name.
442 TABLE_4
DW ?
; Pointer at hwcp.
443 TABLE_5
DW ?
; Pointer at desg and font.
444 ;TABLE DB 290 DUP (?) ; Table of parsed parms. Max 4 devices.
445 DEVNUM
DW ?
; Counter to number of devices.
446 RIGHT_FLAG
DB ?
; Flag to indicate a left bracket.
447 DEV_ERR_FLG
DB ?
; Device name error flag.
448 ID_ERR_FLG
DB ?
; Id name error flag.
449 ERROR_FLAG
DB ?
; Error flag_terminate program if set to 1.
450 COMMA_FLAG
DB ?
; Indicate the number of commas incounterd.
451 HWCP_FLAG
DB ?
; Flag for multiple hwcps.
452 DESG_FLAG
DB ?
; Flag indicates desg. and font.
454 ;Main part of program-links different sumbroutines together
458 PUSH AX ; ;;;;;;;;;;;;;;;;;;
462 PUSH DS ; ; REGISTERS.
465 PUSH SI ; ;;;;;;;;;;;;;;;;;;
467 LES SI,RH
.RH0_BPBA
; Point at all after DEVICE=
468 ; in the CONFIG.SYS file.
471 ;Skip to end of file name, to the first DOS delimiter.
473 MOV DEVNUM
,02H ; Number of devices counter.
475 GET_PARMS_A: CALL GET_CHAR
; Get command character in AL .
476 JZ EXIT_B
; No parms found.
477 CALL IS_DELIM
; If not a delimiter then.
478 JNE GET_PARMS_A
; Check next character.
480 MOV DI,OFFSET TABLE
; Get the table address.
481 ADD DI,02H ; Point at devices offsets.
483 ADD BX,08H ; Point BX at parms offsets.
484 TAB2: CALL UPDATE_TABLE
; Update table pointers value.
486 CLR_DELIM: CALL GET_CHAR
; Get character into AL.
487 JZ EXIT_B
; No parms found.
488 CALL IS_ALPHA
; If alpha then assume.
489 JZ DEVICE
; A device name.
490 CALL IS_DELIM
; Is it a delimiter
491 JNE EXIT_A
; If not then error.
492 JMP CLR_DELIM
; Get next character.
494 DEVICE: MOV DEV_ERR_FLG
,00H ; Set device error flag off;
495 CALL DEVICE_PARSE
; Call routine to parse device name.
496 CMP DEV_ERR_FLG
,01H ; If error flag is
497 JZ EXIT_A
; set then exit.
498 CALL OFFSET_TABLE
; Update table.
500 ID_PARMS: CALL GET_CHAR
; Load a character in AL.
501 JZ EXIT_A
; Exit if end of line (error).
502 CMP AL,'(' ; If AL is a '(' then
503 JE ID
; Parse ID name.
504 CALL IS_ALPHA
; If an Alpha
505 JE ID
; Then parse ID name.
506 CALL IS_DIGIT
; If a digit
507 JE ID
; Then parse ID name.
508 CALL IS_DELIM
; If not a delimiter
509 JNE EXIT_A
; Then error, exit
510 JMP ID_PARMS
; Get another number
512 EXIT_B: CMP DEVNUM
,02H ; If device number above 2 then
513 JA EXIT_C
; Exit parse.
514 JMP EXIT_A
; Else error, exit
516 ID: MOV ID_ERR_FLG
,00H ; Set id error flag off.
517 CALL ID_PARSE
; Parse ID name.
518 CMP ID_ERR_FLG
,01H ; Was error flag set, then
519 JE EXIT_A
; Print error message.
520 CALL OFFSET_TABLE
; Update table of offsets.
522 CALL HWCP_PARMS
; Get code page number
523 CMP ERROR_FLAG
,01H ; If error, then
524 JE EXIT_A
; Print error message and exit
525 CMP ERROR_FLAG
,02H ; If end of string
526 JE EXIT_H
; Then exit.
528 CALL DESG_PARMS
; Get designate number
529 CMP ERROR_FLAG
,01H ; If error, then
530 JE EXIT_A
; Print error message and exit
531 JMP EXIT_H
; Then exit.
533 EXIT_A: MOV DI,OFFSET TABLE
; Load table offset
534 MOV DS:WORD PTR [DI],00H ; Set error to on.
536 JMP EXIT_P
; Exit parse.
538 EXIT_H: MOV DI,OFFSET TABLE
; Load table offset.
539 ADD DS:WORD PTR [DI],01H ; Increment number of devices.
540 CMP DEVNUM
,08H ; If 4 devices loaded
541 JE EXIT_C
; Then exit parse.
542 ADD DEVNUM
,02H ; Increment the number of devices
543 ADD DI,DEVNUM
; Point at next devices offset.
544 MOV BX,TABLE_5
; BX point at
545 ADD BX,06H ; end of previous table.
546 JMP TAB2
; Get next device.
550 EXIT_P: POP SI ; ;;;;;;;;;;;;;;;;;;
554 POP DX ; ; REGISTERS.
557 POP AX ; ;;;;;;;;;;;;;;;;;;
563 ;********************************************************
564 ;** GET_CHAR : a routine to get next character pointed **
565 ;** to by ES:SI into AL. **
566 ;********************************************************
570 MOV AL,ES:BYTE PTR [SI] ; Load character pointed to
571 CMP AL,09H ; by ES:[SI] in AL.
572 JE ZOFF
; If tab then O.K
573 CMP AL,20H
; Turn Z-flag on
574 JL TURN_Z_ON
; if character
575 ZOFF: INC SI ; is below
576 JMP GET_CHAR_X
; 20h.
578 TURN_Z_ON: CMP AL,AL ; delimiters ).
584 ;********************************************************
585 ;** IS_ALPHA : a routine to check the character in **
586 ;** AL if it is an alpha character (a...z,A...Z). **
587 ;** If character is lower case, convert to upper case. **
588 ;********************************************************
592 PUSH AX ; Save value of AL
593 AND AL,0DFH ; Convert to upper case
594 CMP AL,'A' ; If <'A', then
595 JB IS_ALPHA_X
; NZ-flag is set, exit
596 CMP AL,'Z' ; If >'Z', then
597 JA IS_ALPHA_X
; NZ-flag is set, exit
598 CMP AL,AL ; Force Z-flag
599 POP DX ; Discard lower case.
601 IS_ALPHA_X: POP AX ; Restore value of AL
607 ;********************************************************
608 ;** IS_DIGIT : a routine to check if the character in **
609 ;** AL register is a digit (i.e. 1..9). **
610 ;********************************************************
614 CMP AL,'0' ; If < '0' then
615 JB IS_NUM_X
; NZ-flag is set, exit
616 CMP AL,'9' ; If > '9' then
617 JA IS_NUM_X
; NZ-flag is set, exit
618 CMP AL,AL ; Set Z-flag to indecate digit
624 ;********************************************************
625 ;** IS_DELIM : This routine check if the character in **
626 ;** AL is a delimiter. ('+',' ',';',',','=',tab) **
627 ;********************************************************
631 CMP AL,' ' ; Test for space.
632 JE IS_DELIM_X
; Z-flag is set, exit
633 CMP AL,',' ; Test for comma.
634 JE IS_DELIM_X
; Z-flag is set, exit
635 CMP AL,';' ; Test for semicolon.
636 JE IS_DELIM_X
; Z-flag is set, exit
637 CMP AL,'=' ; Test for equal sign.
638 JE IS_DELIM_X
; Z-flag is set, exit
639 CMP AL,09h ; Test for TAB.
641 IS_DELIM_X: RET ; Exit
646 ;********************************************************
647 ;** DEVICE_PARSE : Parse the device driver name and **
648 ;** store in table. Update offset. **
649 ;********************************************************
654 MOV DS:WORD PTR [DI],0008H ; Save dev name size.
655 ADD DI,02H ; Increment DI.
656 MOV CX,9 ; Set counter.
657 NEXT_C: CALL IS_ALPHA
; if Check then.
659 CALL IS_DIGIT
; if Digit then.
661 CMP AL,'-' ; If '-' then.
663 CALL IS_DELIM
; If a delimiter then.
664 JZ ADD_SPACE1
; Pad with spaces.
665 CMP AL,':' ; If a colon
666 JE ADD_SPACE1
; then end device parse
667 JMP ERR_DEV_PAR
; Else an error.
669 SAVE_C: DEC CX ; Decrement counter.
670 CMP CX,0 ; If counter zero then.
671 JE ERR_DEV_PAR
; Error.
672 MOV DS:BYTE PTR [DI],AL ; Save char in table.
673 INC DI ; Increment pointer.
674 CALL GET_CHAR
; Get another char.
676 JMP NEXT_C
; Check char.
678 ERR_DEV_PAR: MOV DEV_ERR_FLG
,01H ; Set error flag.
679 JMP DEV_PAR_X
; Exit.
681 ADD_SPACE1: DEC CX ; Check counter.
683 JL DEV_PAR_X
; Exit if already 8.
684 LL1: MOV DS:BYTE PTR [DI],' ' ; Pad name with spaces.
685 INC DI ; Increment pointer.
686 LOOP LL1
; Loop again.
692 ;********************************************************
693 ;** ID_PARSE : Parse the id driver name and **
694 ;** store in table. Update offset. **
695 ;********************************************************
700 MOV DS:WORD PTR [DI],0008H ; Save dev name size.
701 ADD DI,02H ; Increment DI.
702 MOV RIGHT_FLAG
,00H ; Clear flag.
703 MOV CX,9 ; Set counter.
705 NEXT_I: CALL IS_ALPHA
; If Check then.
707 CALL IS_DIGIT
; if Digit then.
709 CMP AL,'-' ; If '-' then.
711 CMP AL,'(' ; If '(' then.
712 JE RIG_BR_FLG
; Set flag.
713 CMP AL,')' ; If ')' then
714 JE BR_FLG_LEF
; Pad with spaces.
715 CALL IS_DELIM
; If a delimiter then.
716 JZ ADD_SPACE2
; Pad with spaces.
717 JMP ERR_ID_PAR
; Else an error.
719 SAVE_I: DEC CX ; Decrement counter.
720 CMP CX,0 ; If counter zero then.
721 JLE ERR_ID_PAR
; Error.
722 MOV DS:BYTE PTR [DI],AL ; Save char in table.
723 INC DI ; Increment pointer.
724 CALL GET_CHAR
; Get another char.
725 JZ ADD_SPACE2
; Exit routine.
726 JMP NEXT_I
; Check char.
728 ERR_ID_PAR: MOV ID_ERR_FLG
,01H ; Set error falg on.
731 BR_FLG_LEF: CMP RIGHT_FLAG
,01H ; If left bracket was
732 JNE ERR_ID_PAR
; found and no previous
733 JMP ADD_SPACE2
; Bracket found, then error
735 RIG_BR_FLG: CMP RIGHT_FLAG
,01H ; If more than one bracket
736 JE ERR_ID_PAR
; then error.
737 CMP CX,09 ; If '(' and already id
738 JB ERR_ID_PAR
; then error.
739 MOV RIGHT_FLAG
,01H ; Set flag for.
740 CALL GET_CHAR
; Left brackets.
741 JZ ERR_ID_PAR
; If end of line,exit.
742 JMP NEXT_I
; Check character.
744 ADD_SPACE2: DEC CX ; Check counter.
746 JL ID_PAR_X
; Exit if already 8.
748 LL2: MOV DS:BYTE PTR [DI],' ' ; Pad name with spaces.
749 INC DI ; Increment pointer.
750 LOOP LL2
; Loop again.
756 ;********************************************************
757 ;** HWCP_PARMS : Scane for the hardware code page, and **
758 ;** parse it if found. Flag codes set to: **
759 ;** ERROR_FLAG = 0 - parsing completed. No error. **
760 ;** ERROR_FLAG = 1 - error found exit parse. **
761 ;** ERROR_FLAG = 2 - end of line found, exit parse. **
762 ;********************************************************
767 MOV COMMA_FLAG
,00H ; Set the comma flag off.
768 MOV ERROR_FLAG
,00H ; Set the error flag off.
769 DEC SI ; Point at current char in Al.
770 CMP RIGHT_FLAG
,01H ; If no left brackets then
771 JNE LEFT_BR
; Exit parse.
773 HWCP_1: CALL GET_CHAR
; Load character in AL.
774 JZ LEFT_BR
; Exit, if end of line.
775 CALL IS_DIGIT
; Check if digit, then
776 JE HP1
; Parse hwcp parms.
777 CMP AL,',' ; If a comma
778 JE COMMA_1
; Jump to comma_1
779 CMP AL,')' ; If a ')' then
780 JE RIGHT_BR
; end of current dev parms.
781 CMP AL,'(' ; If a '(' then
782 JE HWCP_2
; There are multible hwcp.
783 CALL IS_DELIM
; Else, if not a delimiter
784 JNE EXIT_2
; Then error, exit
785 JMP HWCP_1
; Get another character.
787 LEFT_BR: CMP RIGHT_FLAG
,01H ; If no left bracket
788 JE EXIT_2
; Then error, exit
789 JMP RB1
; Jump to rb1
791 COMMA_1: CMP COMMA_FLAG
,01H ; If comma flag set
792 JE COM_2_HC
; Then exit hwcp parse.
793 MOV COMMA_FLAG
,01H ; Else set comma flag.
794 JMP HWCP_1
; Get another character.
796 HWCP_2: CMP RIGHT_FLAG
,01H ; If left bracket not set
797 JNE EXIT_2
; then error.
798 CALL MUL_HWCP
; else call multiple hwcp
799 ADD DI,02H ; routine. Increment DI
800 MOV TABLE_5
,DI ; Desg. Table starts at end
801 CALL OFFSET_TABLE
; Update table of offsets.
804 HP1: JMP HWCP
; Jump too long.
806 COM_2_HC: MOV DI,TABLE_4
; DI points at hwcp table
807 MOV DS:WORD PTR [DI],0000H ; Set number of pages to
808 MOV COMMA_FLAG
,00H ; Zero and reset comma flag.
809 ADD DI,02H ; Increment DI.
810 MOV TABLE_5
,DI ; Desg. Table starts at end
811 CALL OFFSET_TABLE
; Update table of offsets.
812 JMP HP_X
; of hwcp table. Exit.
814 RIGHT_BR: CMP RIGHT_FLAG
,01H ; If left brackets not
815 JNE EXIT_2
; Found then error.
816 RB1: MOV ERROR_FLAG
,02H ; Set end of line flag.
817 MOV BX,TABLE_4
; Point at hwcp table
818 ADD BX,02H ; Adjust pointer to desg
819 MOV TABLE_5
,BX ; table, and save in table_5
820 MOV DI,TABLE_1
; Point at table of offsets
821 ADD DI,08H ; Set at DESG offset
822 MOV DS:WORD PTR [DI],BX ; Update table.
827 EXIT_2: MOV ERROR_FLAG
,01H ; Set error flag.
830 HWCP: CMP RIGHT_FLAG
,01H ; If left brackets not
831 JNE EXIT_2
; Found then error.
832 CALL HWCP_PARSE
; Call parse one hwcp.
833 CMP ERROR_FLAG
,01H ; If error flag set
834 JE HP_X
; Then exit, else
835 CALL OFFSET_TABLE
; Update table of offsets.
842 ;********************************************************
843 ;** HWCP_PARSE : Parse the hardware code page page **
844 ;** number and change it from hex to binary. **
845 ;********************************************************
849 MOV DI,TABLE_4
; Load address of hwcpages.
850 ADD DS:WORD PTR [DI],0001H ; Set count to 1
852 CALL GET_NUMBER
; Convert number to binary.
853 CMP ERROR_FLAG
,01H ; If error then
855 MOV DS:WORD PTR [DI+2],BX ; Else, save binary page number
856 ADD DI,04H ; Increment counter
857 MOV TABLE_5
,DI ; Set pointer of designate num
864 ;********************************************************
865 ;** MUL_HWCP : Parse multiple hardware code pages **
866 ;** and convert them from hex to binary numbers. **
867 ;********************************************************
871 MOV DI,TABLE_4
; Load offset of table_4
872 MOV BX,DI ; in DI and Bx.
873 MOV HWCP_FLAG
,00H ; Set hwcp flag off.
875 MH1: CALL GET_CHAR
; Load character in AL.
876 JZ MH3
; Exit if end of line.
877 CMP AL,')' ; If ')' then exit
878 JE MH2
; end of parms.
879 CALL IS_DIGIT
; If a digit, then
880 JE MH4
; Convert number to binary.
881 CALL IS_DELIM
; If not a delimiter
882 JNE MH3
; then error, exit
883 JMP MH1
; get another character.
885 MH2: CALL GET_CHAR
; Get next character
888 MH3: MOV ERROR_FLAG
,01H ; Set error flag on.
891 MH4: ADD HWCP_FLAG
,01H ; Set hwcp flag on (0 off)
892 ADD DI,02H ; Increment table pointer
894 CALL GET_NUMBER
; Convert number to binary.
895 MOV DS:WORD PTR [DI],BX ; Add number to table
897 CMP ERROR_FLAG
,01H ; If error then
899 ADD DS:WORD PTR [BX],01H ; Increment hwcp count.
900 DEC SI ; Point at character in AL
901 JMP MH1
; (delimeter or ')').
908 ;********************************************************
909 ;** DESG_PARMS : Scane for the designate numbers, and **
910 ;** parse it if found. Flag codes set to: **
911 ;** ERROR_FLAG = 0 - parsing completed. No error. **
912 ;** ERROR_FLAG = 1 - error found exit parse. **
913 ;** ERROR_FLAG = 2 - end of line found, exit parse. **
914 ;********************************************************
919 MOV DI,TABLE_1
; Get offset of dev in DI
920 MOV BX,TABLE_5
; & offset of desg. in BX.
921 ADD DI,08 ; Location of desg offset in table.
922 MOV DS:WORD PTR [DI],BX ; Update table.
923 MOV COMMA_FLAG
,00H ; Set comma flag off.
934 DESG_PARM1: CALL GET_CHAR
; Get character in AL.
935 JZ EXIT_3
; Error, if end of line
936 CALL IS_DIGIT
; If character is a digit
937 JE DESG
; Then convert to binary.
938 CMP AL,')' ; If a ')', then
939 JE RIGHT_BR2
; end of parameters.
940 CMP AL,'(' ; If a '(' then
941 JE DF ; parse desg and font.
942 CMP AL,',' ; If a comma then
944 CALL IS_DELIM
; If not a delimiter
945 JNE EXIT_3
; then error.
946 JMP DESG_PARM1
; Get another character.
948 RIGHT_BR2: CMP RIGHT_FLAG
,01H ; IF no '(' encountered,
949 JNE EXIT_3
; then error, exit
950 JMP DP_x
; Jump to DP1.
952 EXIT_3: MOV ERROR_FLAG
,01H ; Set error flag on
955 DF: CMP RIGHT_FLAG
,01H ; If no '(' encountered
956 JB EXIT_3
; then error, exit
957 CALL DESG_FONT
; Parse desg and font.
958 JMP DP1
; Jump to DP1.
960 DP2: CALL FIND_RIGHT_BR
; Check for ')'
963 DP3: CMP COMMA_FLAG
,01H ; If comma flag set
965 MOV COMMA_FLAG
,01H ; Else set comma flag on.
966 JMP DESG_PARM1
; Get another character.
968 DESG: MOV ERROR_FLAG
,00H ; Set error flag off.
969 CALL DESG_PARSE
; Parse desg.
970 DP1: CMP ERROR_FLAG
,01H ; If error flag on then
972 CALL FIND_RIGHT_BR
; Else check for ')'
973 CALL OFFSET_TABLE
; Update table
981 ;********************************************************
982 ;** DESG_FONT : Parse the designate and font numbers & **
983 ;** change them from decimal to binary. **
984 ;********************************************************
990 MOV DI,TABLE_5
; Get desg font table.
991 MOV COMMA_FLAG
,00H ; Set comma flag off.
992 DF1: CALL GET_CHAR
; Load a character in AL.
993 JZ DF3
; Error if end of line.
994 CMP AL,',' ; Check if a comma.
996 CALL IS_DIGIT
; If a digit, then
997 JE DF5
; Convert number to binary.
998 CMP AL,')' ; If a ')' then
1000 CALL IS_DELIM
; If not a delimiter
1001 JNE DF3
; then error, exit
1002 JMP DF1
; Get another character.
1004 DF2: CMP COMMA_FLAG
,01H ; If comma flag on
1005 JE DF3
; then error, exit
1006 MOV COMMA_FLAG
,01H ; Set comma flag on
1007 ADD DS:WORD PTR [DI],01H ; Increment desg counter.
1008 MOV DS:WORD PTR [DI+2],0FFFFH ; Load ffffh for desg empty
1011 DF3: MOV ERROR_FLAG
,01H ; Set error flag on.
1014 DF4: CMP DESG_FLAG
,00H ; If desg flag off
1015 JE DF3
; then error, exit
1016 JMP DF_X
; Else exit.
1018 DF5: ADD DS:WORD PTR [DI],01H ; Increment desg font count.
1019 CMP DESG_FLAG
,01H ; If desg flag is on
1020 JE DF6
; then get font.
1021 CMP COMMA_FLAG
,01H ; if comma flag is on
1022 JE DF6
; then get font.
1023 MOV DESG_FLAG
,01H ; Set desg flag on
1024 JMP DF7
; Get desg number.
1026 DF6: ADD DI,02H ; adjust pointer to font.
1027 MOV DESG_FLAG
,02H ; Set desg and font flag.
1028 DF7: CALL GET_NUMBER
; Get a number & convert to
1029 CMP ERROR_FLAG
,01H ; binary.
1030 JE DF_X
; If error flag set, Exit.
1031 MOV DS:WORD PTR [DI+2],BX ; Store number in table.
1032 CMP DESG_FLAG
,02H ; If desg and font flag
1033 JNE DF1
; not set, then get char.
1034 CALL FIND_RIGHT_BR
; Check for right bracket.
1041 ;********************************************************
1042 ;** DESG_PARSE : Parse the designate number and **
1043 ;** change it from decimal to binary. **
1044 ;********************************************************
1048 MOV DI,TABLE_5
; Load designate location
1049 ADD DS:WORD PTR [DI],0001H ; Update table count.
1051 CALL GET_NUMBER
; Get the ascii number and
1052 CMP ERROR_FLAG
,01H ; conver it to binary
1053 JE DESG_X
; If error then exit
1055 MOV DS:WORD PTR [DI+2],BX ; Else, save desg number
1063 ;********************************************************
1064 ;** GET_NUMBER : Convert the number pointed to by SI **
1065 ;** to a binary number and store it in BX **
1066 ;********************************************************
1070 MOV CX,0AH ; Set multiplying factor
1071 XOR BX,BX ; Clear DX
1073 NEXT_NUM: SUB AL,30H
; Conver number to binary
1075 XCHG AX,BX ; Switch ax and bx to mul
1076 MUL CX ; already converted number by 10.
1077 JO ERR_NUM
; On over flow jump to error.
1078 ADD BX,AX ; Add number to total.
1079 JC ERR_NUM
; On over flow jump to error.
1080 XOR AX,AX ; Clear AX (clear if al=0a).
1081 CALL GET_CHAR
; Get next character
1082 JZ GET_NUM_X
; Exit, if end of line.
1083 CALL IS_DIGIT
; Call is digit.
1084 JNZ GET_NUM_X
; Exit if not a number.
1085 JMP NEXT_NUM
; Loop.
1087 ERR_NUM: MOV ERROR_FLAG
,01H ; Set error code to 1.
1094 ;********************************************************
1095 ;** UPDATE_TABLE : This routine set up pointers to the **
1096 ;** different offsets of the different tables **
1097 ;********************************************************
1101 MOV DS:WORD PTR [DI],BX ; Offset of offsets
1102 MOV TABLE_1
,BX ; Table_1 points at offsets
1106 MOV DS:WORD PTR [DI+2],BX ; Offset of DEVICE name.
1107 MOV TABLE_2
,BX ; Table_2 point at device name.
1110 MOV DS:WORD PTR [DI+4],BX ; Offset of ID name.
1111 MOV TABLE_3
,BX ; Table_3 point at ID name.
1114 MOV DS:WORD PTR [DI+6],BX ; Offset of HWCP pages.
1115 MOV TABLE_4
,BX ; Table_4 point at HWCP pages.
1122 ;********************************************************
1123 ;** OFFSET_TABLE : This routine set up pointers of **
1124 ;** tables number one and two. **
1125 ;********************************************************
1129 MOV DI,TABLE_1
; Increment the number
1130 ADD DS:WORD PTR [DI],01H ; of parms foun. (ie. id,hwcp
1136 ;********************************************************
1137 ;** FIND_RIGHT_BR :This routine scane the line for a **
1138 ;** ')' if cannot find it turns error flag on **
1139 ;********************************************************
1143 FBR1: CMP AL,')' ; If a right bracket
1144 JE FBR_X
; then exit.
1145 CMP AL,' ' ; If not a space
1146 JNE FBR2
; Then error.
1147 CALL GET_CHAR
; Get a character
1148 JZ FBR2
; If end of line then exit.
1149 JMP FBR1
; Else get another character.
1151 FBR2: MOV ERROR_FLAG
,01H ; Set error flag on
1152 FBR_X: MOV AL,20H
; Erase character from AL.
1157 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1159 ;; ++++++++++++++++++++++++
1160 ;; ++ INIT Command ++
1161 ;; ++++++++++++++++++++++++
1163 ;;==== Command Code 0 - Initialization ======
1165 ;; messages returned :
1167 ;; msg_bad_syntax -- syntax error from parser, no driver installation
1168 ;; msg_no_init -- device cannot be initialised
1169 ;; msg_insuff_mem -- insufficient memory
1171 ;; layout : the initialization is done in two stages :
1173 ;; ++++++++++++++++++++++++
1174 ;; ++ INIT Stage 1 ++ to examine and extract the
1175 ;; ++++++++++++++++++++++++ parameters defined for the
1176 ;; device_id in DEVICE command,
1177 ;; according to the printer
1178 ;; description table for the
1181 ;; ++++++++++++++++++++++++
1182 ;; ++ INIT Stage 2 ++ to set the BUFfer for the LPTn
1183 ;; ++++++++++++++++++++++++ or PRN according to device_id's
1188 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1194 ; Tables for the deivce_id parameters in the order of device_id in the
1196 ; === the tables serves as the link between LPTn to be defined in the 2nd
1197 ; stage, and the device_id that is processed in the first stage.
1199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1201 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1202 ;; device ID indicators :
1203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1204 DID_MAX EQU
4 ;; device entris exepcted in PARSE
1205 ;; not more than 16. ;; table
1207 DID_STATUS
DW 0 ;; status of parsing device id
1208 ;; = 0 : all Device-ID bad
1211 DID_MATCH
DW 0 ;; this DID has device_name matched
1213 DID_FAIL
DW 0 ;; to fail the good DID_STATUS and
1214 ;; the matched name. (due to
1215 ;; inconsistency among the same LPTn
1216 ;; or between PRN and LPT1.)
1218 ;; (DID_STATUS) AND (DID_MATCH) XOR (DID_FAIL) determines the success of DID
1221 DID_ONE EQU
00001H ;; first device-ID
1222 DID_TWO EQU
00002H ;; second "
1223 DID_THREE EQU
00004H ;; third "
1224 DID_FOUR EQU
00008H ;; fourth "
1225 ;;maximun number of device_id = 16 ;;
1227 DID_BIT
LABEL WORD ;;
1232 ;;maximun number of device_id = 16 ;;
1233 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1234 ;; device paramters according to the
1235 ;; device_id defined in DEVICE and the
1236 ;; parameters defined for the device_id
1237 ;; in the printer description table.
1239 HRMAX
LABEL word ;; number of hwcp+cart slots supported
1244 ;upto max DID_MAX ;;
1246 CTMAX
LABEL word ;; number of cart slots supported
1251 ;upto max DID_MAX ;;
1253 RMMAX
LABEL word ;; number of ram-slots supported
1258 ;upto max DID_MAX ;;
1260 RBUMAX
LABEL word ;; number of ram-designate slots
1265 ;upto max DID_MAX ;;
1267 DESCO
LABEL word ;; offset to the description table
1268 ;; where the device_id is defined.
1273 ;upto max DID_MAX ;;
1275 FSIZE
LABEL word ;; font size of the device
1280 ;upto max DID_MAX ;;
1282 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1284 ; Hard/RAM slots table in the order of DEVICE parameters
1286 ; number of entries in all HARD_SLn is determined by the max. {HSLOTS}, and
1287 ; number of entries in all RAM_SLn is determined by the max. {RSLOTS}
1289 ; -- they are initialized according to the device_id defined in the DEVICE.
1291 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1293 HARD_SLA
LABEL word ;; index in the order of device in
1294 DW OFFSET
(HARD_SL1
) ;; the PARSE-talbes
1295 DW OFFSET
(HARD_SL2
) ;;
1296 DW OFFSET
(HARD_SL3
) ;;
1297 DW OFFSET
(HARD_SL4
) ;;
1300 RAM_SLA
LABEL word ;;
1301 DW OFFSET
(RAM_SL1
) ;;
1302 DW OFFSET
(RAM_SL2
) ;;
1303 DW OFFSET
(RAM_SL3
) ;;
1304 DW OFFSET
(RAM_SL4
) ;;
1307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1309 ;; ++++++++++++++++++++++++
1310 ;; ++ INIT Command ++
1311 ;; ++++++++++++++++++++++++
1313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1318 ;; parse the initialization parameters in DEVICE command
1319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1322 CMP BUF
.BFLAG
,BF_PRN
;; since PRN is the FIRST device header
1326 MOV AX,OFFSET CODE_END
;; defined only once for each DEVICE
1333 INC AX ;; leave 16 bytes,room for resident_end
1334 MOV RESIDENT_END
,AX ;;
1336 CALL PARSER
;; call only once, for PRM
1338 JMP PROCESS_TABLE
;;
1343 JNB PROCESS_TABLE
;;
1350 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1352 ;; ++++++++++++++++++++++++
1353 ;; ++ INIT Stage 1 ++
1354 ;; ++++++++++++++++++++++++
1356 ;; INIT - FIRST STAGE :
1358 ;; == test and extract if the parameters on device-id is valid
1359 ;; == determine the DID_STATUS according to the validity of the parameters
1360 ;; == procedure(s) called -- DID_EXTRACT
1362 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1367 POP ES ;; PSE points to Device offsets
1368 MOV DI,OFFSET
(table
) ;; ES:[DI]
1369 MOV DX,PSE
.PAR_DEV_NUM
;;
1373 JNZ NO_SYNTAX_ERR
;;
1377 MOV DX,OFFSET MSG_BAD_SYNTAX
;;
1380 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1381 SYNTAX_ERROR
: ;; set the request header status
1382 ;; according to the STATE
1383 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1384 MOV AX, RESIDENT_END
;;
1387 SUB AX,Cx ;; additional segment required.
1401 LES DI,dword ptr buf
.rh_ptro
;; get Request Header address
1402 ; MOV RH.RH0_ENDO,AX ;;
1403 MOV RH
.RH0_ENDO
,0 ;;
1404 MOV RH
.RH0_ENDS
,CX ;;
1405 MOV RH
.RHC_STA
,stat_cmderr
;; set status in request header
1415 MOV INIT_CHK
,0001H ;; ERROR 0001
1416 JMP BAD_DID
;; more than supported no. of device
1419 PUSH DI ;; pointer to PAR_OT (table 1)
1422 JMP END_DID
;; DI = offset to the 1st PARSE table
1423 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1425 MOV DI,PSE
.PAR_OFF
;; points to the nth device
1427 ;; find the description for the
1429 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1430 MOV CX,PRINTER_DESC_NUM
;;
1431 MOV SI, OFFSET
(PRINTER_DESC_TBL
); offset to the description table
1436 PUSH CX ;; save device count
1437 PUSH SI ;; pointer to printer-descn's offset
1438 MOV SI,CS:WORD PTR[SI] ;;
1440 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1441 ; $LEAVE Z ;; LEAVE if no more device description
1443 PUSH DI ;; save offset to PAR_DEVOT
1444 MOV DI,PSE
.PAR_DIDO
;;
1445 MOV CX,PSE
.PAR_DIDL
;; length of parsed device name
1446 LEA DI,PSE
.PAR_DID
;; pointer to parse device name
1449 LEA SI,[SI].TYPEID
;; offset to name of device-id
1452 POP DI ;; get back offset to PAR_DEVOT
1453 ;;;;;;;;;;;;;;;;;;;;;;;;
1454 ; $EXITIF Z ;; EXIT if name matched
1457 CALL DID_EXTRACT
;; get the parameters
1459 POP SI ;; balance push-pop
1462 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1463 ; $ORELSE ;; try next description :
1467 POP SI ;; of printer_descn offset table
1469 INC SI ;; next offset to PRINTER_DESCn
1471 POP CX ;; one description less
1473 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1474 ; $ENDLOOP ;; DEVICE-ID not defined in
1482 MOV INIT_CHK
,0004H ;; ERROR 0004
1484 POP SI ;; balance push-pop
1486 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1487 ; $ENDSRCH ;; End of scanning printer_desc
1489 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1492 INC DI ;; points to next device in PART_OT
1501 MOV AX,DID_STATUS
;;
1507 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1509 ;; ++++++++++++++++++++++++
1510 ;; ++ INIT Stage 2 ++
1511 ;; ++++++++++++++++++++++++
1513 ;; INIT -- SECOND STAGE :
1515 ;; == match the device_name extracted in stage 1 with the name of PRN or
1518 ;; == if the PRN/LPTn has never been defined before, then set up the BUF
1519 ;; for the PRN/LPTn if the DID_STATUS is good; otherwise message will
1520 ;; be generated indicating it cannot be initilized.
1522 ;; == if there is PRN, LPT1 is also setup, and vice vera. IF both PRN and
1523 ;; LPT1 are on the DEVICE command, or there are multiple entries for
1524 ;; the same LPTn, the consistency is checked. It they are inconsistent
1525 ;; the associated LPTn or PRN is forced to fail by : DID_FAIL.
1527 ;; == if the device_name on the DEVICE command is not one of the supported
1528 ;; PRN or LPTn, then DID_MATCH bit will not be set. An error message
1529 ;; will be generated for the device_name indicating it cannot be
1532 ;; == procedure(s) called : CHK_DID .. check DID parameters for device
1533 ;; whose name matched.
1534 ;; DEV_CHECK .. if device-name duplicated, or
1535 ;; there are both PRN/LPT1 : check
1536 ;; for consistent parameters.
1538 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1541 POP ES ;; PSE points to Device offsets
1542 MOV DI,OFFSET
(table
) ;; ES:[DI]
1543 xor cx,cx ;; device order in parse table
1546 PUSH DI ;; pointer to PAR_OT
1547 PUSH CX ;; save device count
1548 MOV DI,PSE
.PAR_OFF
;; " " PAR_DEVOT
1551 ;LEAVE NB ;; LEAVE if no more device entry
1554 MORE_DEVICE
: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1555 ;; more parsed_device to be checked
1556 PUSH DI ;; save offset to PAR_DEVOT
1557 MOV DI,PSE
.PAR_DNMO
;;
1558 MOV CX,PSE
.PAR_DNML
;; length of parsed device name
1559 LEA DI,PSE
.PAR_DNM
;; pointer to parse device name
1561 LDS SI,DWORD PTR BUF
.DEV_HDRO
; get the offset to device-n header
1562 LEA SI,HP
.DH_NAME
;; " offset to name of device-n
1564 POP DI ;; get back offset to PAR_DEVOT
1566 ;;;;;;;;;;;;;;;;;;;;;;;;;;
1567 ;EXITIF Z ;; EXIT if name matched
1570 JMP MORE_PARSED_DEVICE
;;
1574 POP CX ;; the DID order
1578 MOV AX,DID_BIT
[BX] ;;
1579 OR DID_MATCH
,AX ;; this DID matched
1583 LEA SI,BUF
.PAR_EXTRACTO
;; was the LPT1/PRN defined before ?
1584 MOV AX,CS:[SI].PAR_DNMO
;;
1587 JNE DEV_COMPARE
;; DI = PAR_DEVOT
1588 ;;-----------------------------------
1590 ;; no device previousely defined
1591 MOV AX,PSE
.PAR_DNMO
;;
1592 MOV CS:[SI].PAR_DNMO
,AX ;; define device parameters for LPTn
1594 MOV AX,PSE
.PAR_DIDO
;;
1595 MOV CS:[SI].PAR_DIDO
,AX ;;
1597 MOV AX,PSE
.PAR_HWCPO
;;
1598 MOV CS:[SI].PAR_HWCPO
,AX ;;
1600 MOV AX,PSE
.PAR_DESGO
;;
1601 MOV CS:[SI].PAR_DESGO
,AX ;;
1603 MOV AX,PSE
.PAR_PARMO
;;
1604 MOV CS:[SI].PAR_PARMO
,AX ;;
1606 ;;---------------------------------
1607 CALL CHK_DID
;; define the STATE according to
1609 JMP MORE_PARSED_DEVICE
;;
1611 DEV_COMPARE
: ;;-------------------------------
1612 ;; e.g. LPT1 and PRN shares one BUF.
1613 ;; or duplicated device name
1616 CMP BUF
.STATE
,CPSW
;;
1617 JNE DEV_COMPARE_FAIL
;;
1619 JMP MORE_PARSED_DEVICE
;;
1621 DEV_COMPARE_FAIL
: ;;
1624 POP DI ;; balance push-pop
1626 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1629 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1630 MORE_PARSED_DEVICE
: ;; name does not match
1636 INC DI ;; points to next device in PART_OT
1639 ;$ENDLOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1640 $$EN7
: ;; no device found for LPTn
1643 POP DI ;; balance push-pop
1645 CMP BUF
.STATE
,CPSW
;;
1646 JE END_LPT
;; for LPT1/PRN pair
1648 MOV BUF
.STATE
,NORMAL
;; no device defined for the LPTn
1650 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1651 ;; End of defining LPTn Buffer
1652 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1655 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1656 ;; set the request header status
1657 ;; according to the STATE
1658 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1659 MOV AX, RESIDENT_END
;;
1662 SUB AX,Cx ;; additional segment required.
1676 LES DI,dword ptr buf
.rh_ptro
;; get Request Header address
1677 MOV RH
.RH0_ENDO
,AX ;;
1678 MOV RH
.RH0_ENDS
,CX ;;
1679 XOR AX,AX ;; clear error code to be returned
1683 MOV AX,STAT_CMDERR
;;
1686 MOV RH
.RHC_STA
,AX ;; set status in request header
1690 CMP BUF
.BFLAG
,BF_LPT1
;;
1693 CMP BUF
.STATE
,CPSW
;;
1695 ;; set PRN to the same setting as LPT1
1698 LEA SI,BUF
.RNORMO
;;
1699 LEA CX,BUF
.BUFEND
;;
1701 MOV BX,BUF
.PRN_BUFO
;; where PRN buffer is
1702 LEA DI,BUF
.RNORMO
;;
1712 CMP BUF
.BFLAG
,BF_LPT3
;; generate error message is this is
1713 je last_round
;; the last LPTn
1715 ;; ERROR messages will be generated
1716 ;; at the end of initialization of all
1719 MOV AX,RESIDENT_END
;;
1720 ADD AX,STACK_SIZE
;;
1721 MOV RESIDENT_END
,AX ;;
1724 SUB AX,Cx ;; additional segment required.
1738 MOV RH
.RH0_ENDO
,AX ;; STACK !!!!!
1739 MOV STACK_ALLOCATED
,0 ;; from now on, internal stack is used
1741 MOV AX,DID_STATUS
;; what is the DID combination ?
1747 ; MOV RH.RH0_ENDO,0 ;; none of the devices are good
1751 MOV DI,OFFSET TABLE
;;
1761 ;; this device in parse table is bad
1766 MOV DI,PSE
.PAR_OFF
;;
1767 MOV SI,PSE
.PAR_DNMO
;;
1775 LEA SI,[SI].PAR_DNM
;;
1778 ADD DI,7 ;; skip backward the blanks
1784 MOV DI, OFFSET MSG_NO_INIT_P
;;
1785 MOV DX,DI ;; for INT 21H
1791 MOV DI, OFFSET MSG_NO_INIT
;;
1792 MOV DX,DI ;; for INT 21H
1796 PUSH CX ;; remaining name that is non blank
1827 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1829 ;; Call by INIT to extract parameters for the deivce_id
1832 ;; ES:[DI] PARSE Table 2, offsets of all parameters
1833 ;; DS:[SI] Printer Description table whose TYPEID matched
1834 ;; DX "inverse" order of devices in the PARSE tables
1836 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1842 ;;-----------------------------
1843 ;; define the DID_parameters
1847 SUB BX,DX ;; order in the Parse table
1848 add bx,bx ;; double to index [bx]
1851 MOV AX,DS:[SI].FONTSZ
;;
1852 MOV FSIZE
[BX],AX ;; size of font buffer to be created
1854 MOV AX,DS:[SI].HSLOTS
;;
1855 CMP AX,HARDSL_MAX
;;
1857 MOV INIT_CHK
, 0010H ;; ERROR 0010H
1859 JMP END_MATCH_BAD
;;
1861 CMP AX,DS:[SI].HWCPMIN
;;
1863 MOV INIT_CHK
, 0012H ;; ERROR 0012H
1865 JMP END_MATCH_BAD
;;
1868 MOV CTMAX
[BX],AX ;; will be reduced by the no. of hwcp
1870 MOV AX,DS:[SI].RSLOTS
;;
1873 MOV INIT_CHK
, 0011H ;; ERROR 0011H
1875 JMP END_MATCH_BAD
;;
1877 MOV RMMAX
[BX],AX ;; see also designate
1882 ;;----------------------------------
1886 HWCPgt: PUSH DI ;; get the hwcp
1888 MOV DI,PSE
.PAR_HWCPO
;;
1889 MOV CX,PSE
.PAR_HWCPL
;; no. of hwcp
1895 MOV CX,DS:[SI].HWCPMIN
;;
1896 SUB CTMAX
[BX],CX ;; what is left becomes cartridge slot
1899 ;; hwcp to be defined
1900 chk_hwcp: MOV AX,DS:[SI].HSLOTS
;; defined in printer_desc
1903 CMP CX,HARDSL_MAX
;;
1904 JNA HWCP_GOOD
;; jump if system error
1905 MOV INIT_CHK
,0003H ;; ERROR 0003
1908 MOV INIT_CHK
,0002H ;; ERROR 0002
1911 HWCP_GOOD: ;; there are sufficient hard-slot for
1913 PUSH SI ;; printer description table of TYPEID
1919 PUSH CX ;; calculate what is left for cart_slot
1920 CMP CX,DS:[SI].HWCPMIN
;;
1921 JNB MORE_THAN_HWCPMIN
;;
1922 MOV CX,DS:[SI].HWCPMIN
;;
1923 MORE_THAN_HWCPMIN
: ;;
1928 MOV CTMAX
[BX],AX ;; no of cart-slot for designate
1929 MOV SI,HARD_SLA
[BX] ;; get the corresponding hard-slots
1937 mov reserved1
,dx ;; IF THERE IS ANY REPETITIVE HWCP
1938 mov reserved2
,bx ;; IF THERE IS ANY REPETITIVE HWCP
1943 INC DI ;; next code page in PARSE table
1945 MOV AX,ES:[DI] ;; get code page value
1947 ;; IF THERE IS ANY REPETITIVE HWCP
1951 cmp ax,cs:[bx].slt_cp
;;
1970 MOV CS:[SI].SLT_CP
,AX ;;
1971 MOV AX,CS:[SI].SLT_AT
;; get the attributes
1972 OR AX,AT_OCC
;; occupied
1973 OR AX,AT_HWCP
;; hwcp slot
1974 MOV CS:[SI].SLT_AT
,AX ;;
1985 ;;---------------------
1986 DESIGN: POP DI ;; get the designate no.
1989 MOV DI,PSE
.PAR_DESGO
;;
1990 MOV AX,PSE
.PAR_DESGL
;;
1992 JA END_MATCH
;; there should have no font entry
1996 MOV AX,PSE
.PAR_DESG
;;
2000 CMP CS:[SI].CLASS
,1 ;;
2001 JNE DESIG_NOt_CLASS1
;;
2003 PUSH BX ;; if there is any cartridge slot ?
2010 JZ END_MATCH
;; fail, as there is no physical RAM.
2012 CMP AX,HARDSL_MAX
;; is the designate more than max ?
2020 DESIG_NOT_CLASS1
: ;;
2021 PUSH BX ;; if there is any physical RAM slot ?
2028 JZ END_MATCH
;; fail, as there is no physical RAM.
2031 CMP AX,RAMSL_MAX
;; is the designate more than max ?
2037 MOV RBUMAX
[BX],AX ;;
2044 ;; MOV DI,PSE.PAR_PARMO ;;
2046 ;,--------------------------
2047 ;; GOOD device_id parameters
2054 NO_SHL: OR DID_STATUS
,AX ;; is defined
2055 ;;-------------------------
2056 END_MATCH: POP DI ;; end of extract
2065 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2067 ;; Called by INIT to define the STATE and BUF for the LPTn according to
2068 ;; the DID_STATUS. Create font buffer if requested through the "desi*nate"
2070 ;; at entry : CX = device order in parse table
2072 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2079 MOV AX,DID_STATUS
;;
2081 PUSH CX ;; order 0 to m
2083 ADD DI,DI ;; indexing : [DI]
2086 SHR AX,CL ;; is the device parameter valid ?
2089 JMP LPT_FAIL
;;--------------------------
2092 ;; good device parameters as determined
2094 MOV BUF
.PDESCO
,AX ;;
2098 MOV AX,CS:[DI].CLASS
;;
2099 MOV BUF
.PCLASS
,AX ;;
2102 MOV AX,HARD_SLA
[DI] ;; in the DID_EXTRACT
2103 MOV BUF
.HARDSO
,AX ;;
2105 MOV AX,RAM_SLA
[DI] ;;
2109 MOV BUF
.HARDMX
,AX ;;
2112 MOV BUF
.HCARMX
,AX ;;
2114 ADD AX,HRMAX
[DI] ;; defore "designate"
2122 PUSH CX ;; calculate the max. length of control
2123 MOV CX,2 ;; sequence that is allowed for the
2124 CMP BUF
.PCLASS
,1 ;; room reserved for physical slots.
2126 MOV CX,1 ;; class 1 printer has one control seq.
2129 DEC AX ;; leave one byte for the length
2132 MOV BUF
.FSELMAX
,AX ;;
2136 MOV BUF
.FTSZPA
,AX ;; FTSIZE in paragraph
2144 JNZ FT_PARA
;; font size
2145 MOV BUF
.FTSIZE
,AX ;; font size in bytes (used with.RBUFMX)
2147 POP DX ;; FTSIZE in paragraph
2149 MOV CX,RBUMAX
[DI] ;; create font buffer per .RBUFMX and
2150 MOV BUF
.RBUFMX
,CX ;; assume sufficient memory for all the
2151 ;; "designate request"
2154 CMP BUF
.PCLASS
,1 ;; always create font buffer for class1
2159 ADD CX,BUF
.HARDMX
;;
2169 MOV AX,RESIDENT_END
;;
2171 ADD AX,DX ;; allocate the font buffers at the end
2172 DEC CX ;; of the resident codes
2176 MOV CX,RESIDENT_END
;;
2177 MOV BUF
.FTSTART
,CX ;;
2178 MOV RESIDENT_END
,AX ;;
2182 POP CX ;; designate requested
2190 PUSH CX ;; STACKS...
2197 MOV DX,BUF
.HARDMX
;;
2198 PUSH DX ;; STACK +1 -- # of HWCP
2203 MOV SI,BUF
.PDESCO
;;
2204 MOV SI,CS:[SI].SELH_O
;;
2206 MOV CL,CS:BYTE PTR [SI] ;;
2207 INC CX ;; including the length byte
2209 MOV DI,BUF
.FTSTART
;; control template
2210 DEF_FTBUF: ;; fill the font buffer with the
2223 ADD DI,BUF
.FTszpa
;;
2229 MOV SI,BUF
.HARDSO
;;
2230 MOV DI,BUF
.FTSTART
;; define the HWCP values
2234 MOV DI,CTL5202_OFFS
;; offset to the HWCP words
2236 MOV AX,CS:[SI].SLT_CP
;;
2237 MOV ES:WORD PTR [DI],AX ;;
2246 ADD DI,BUF
.FTSZPA
;;
2261 MOV BUF
.RSLMX
,CX ;; the no. of ram slots supported
2265 MOV BUF
.RSLMX
,AX ;; the max. of .RAMMX and .RBUFMX
2268 MOV BUF
.STATE
,CPSW
;; the LPTn is CPSW ----- STATE
2270 CMP BUF
.BFLAG
,BF_PRN
;;
2272 MOV AX,DID_BIT
[DI] ;;
2273 MOV BUF
.DID_PRN
,AX ;;
2280 MOV BUF
.STATE
,NORMAL
;; the LPTn is NORMAL --- STATE
2293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2295 ;; Called by INIT to check for consistency between duplicated device name and
2296 ;; between PRN and LPT1
2298 ;; at entry : DI = pointer to PAR_DEVOT
2299 ;; BUF.STATE = any state
2302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2306 LEA SI,BUF
.PAR_EXTRACTO
;;
2310 PUSH SI ;; compare device id
2312 mov SI,[SI].PAR_DIDO
;;
2313 MOV DI,PSE
.PAR_DIDO
;;
2314 MOV CX,PSE
.PAR_DNML
;;
2315 INC CX ;; including length
2321 mov init_chk
,0021h ;; error 0021h
2322 Jmp FORCE_LPT_BAD
;;
2325 PUSH SI ;; compare HWCP
2327 mov SI,[SI].PAR_HWCPO
;;
2328 MOV DI,PSE
.PAR_HWCPO
;;
2329 MOV AX,PSE
.PAR_HWCPL
;;
2331 SHL AX,CL ;; multiply by two
2332 INC AX ;; including length
2339 mov init_chk
,0022h ;; error 0022h
2340 Jmp FORCE_LPT_BAD
;;
2343 PUSH SI ;; compare DESIGNATE
2345 mov SI,[SI].PAR_DESGO
;;
2346 MOV DI,PSE
.PAR_DESGO
;;
2347 MOV AX,PSE
.PAR_DESGL
;;
2349 SHL AX,CL ;; multiply by two
2350 INC AX ;; including length
2357 mov init_chk
,0023h ;; error 0023h
2358 Jmp FORCE_LPT_BAD
;;
2361 PUSH SI ;; compare parameters
2363 mov SI,[SI].PAR_PARMO
;;
2364 MOV DI,PSE
.PAR_PARMO
;;
2365 MOV CX,PSE
.PAR_PARML
;;
2366 INC CX ;; including length
2372 mov init_chk
,0024h ;; error 0024h
2374 FORCE_LPT_BAD
: ;; the second set of parameters is
2375 MOV BUF
.STATE
,NORMAL
;; bad
2377 CMP BUF
.BFLAG
,BF_LPT1
;;
2380 ;; since LPT1 is bad, force PRN to bad
2381 push bx ;; force prn to be bad too
2382 mov bx,buf
.prn_bufo
;;
2383 MOV BUF
.STATE
,NORMAL
;;
2386 mov AX,BUF
.DID_PRN
;; if PRN was not good, DID_PRN = 0
2390 M_END: ;; force the good did_status to fail if
2393 PUSH CX ;; order 0 to m
2394 MOV AX,DID_STATUS
;;
2399 JNC DEV_CHECK_RET
;; already failed
2401 CMP BUF
.STATE
,CPSW
;;
2407 MOV AX,DID_BIT
[BX] ;;
2408 OR DID_FAIL
,AX ;; force DID to fail
2419 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;