summaryrefslogtreecommitdiff
path: root/v4.0/src/DEV/PRINTER/PARSE4E.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/DEV/PRINTER/PARSE4E.ASM')
-rw-r--r--v4.0/src/DEV/PRINTER/PARSE4E.ASM1106
1 files changed, 1106 insertions, 0 deletions
diff --git a/v4.0/src/DEV/PRINTER/PARSE4E.ASM b/v4.0/src/DEV/PRINTER/PARSE4E.ASM
new file mode 100644
index 0000000..872a458
--- /dev/null
+++ b/v4.0/src/DEV/PRINTER/PARSE4E.ASM
@@ -0,0 +1,1106 @@
1;***************************************************************
2;** **
3;** ******** ** ** ******* **
4;** ** ** ** ** **
5;** ** ******* ***** **
6;** ** ** ** ** **
7;** ** ** ** ******* **
8;** **
9;** ****** * ****** ****** ******* ****** **
10;** ** ** ** ** ** ** ** ** ** ** **
11;** ****** ******* ****** ***** ****** ****** **
12;** ** ** ** ** ** ** ** ** ** **
13;** ** ** ** ** ** ****** ******* ** ** **
14;** **
15;***************************************************************
16;
17; File Name: PARSE.ASM
18; ----------
19;
20; Description: A command parser for DEVICE command in the CONFIG.SYS file.
21; ------------
22;
23; Procedures contained in the file:
24; ---------------------------------
25; PARSER: Main routine for command processing.
26; GET_CHAR: Gets a character from command line.
27; IS_ALPH: Checks if character is an alpha character.
28; IS_DIGIT: Checks if character is a digit.
29; IS_DELIM: Checks if character is a DOS delimiter.
30; DEVICE_PARSE: Pulls device name from command line and
31; inserts in table.
32; ID_PARSE: Pulls id name from command line and insers in table
33; HWCP_PARMS: Extract HWCP number, converts it to binary and
34; inserts it in table.
35; HWCP_PARSE: Extracts HWCP number if only one number is given.
36; MUL_HWCP: Extracts multiple HWCP's numbers, if they are given
37; in a list.
38; DESG_PARMS: Extracts designate number, converts it to binary
39; and inserts it in table.
40; DESG_FONT: Extracts the designate and the font if both were
41; given in command line.
42; DESG_PARSE: Pulls designate number if it is the only one given.
43; GET_NUMBER: Converts a number to binary.
44; OFFSET_TABLE: Updates the counter in table #1.
45; FIND_RIGHT_BR: Looks for a right bracket.
46;
47;
48; Change history:
49; ---------------
50;
51;
52;LOGIC:
53;------
54; Establish addressability to parameters.
55; Skip until end of path and file name -first delimiter
56;
57; Loop:
58; Isolate the first non-delimiter or non delimeter characters.
59; If End_of_Line_Delimiter then
60; return an error_code
61; Else
62; If first non-delimiter is ALPHA then
63; (assume a device name)
64; Extracts device name
65; Update offset counter
66;
67; Isolate the first non-delimiter characters after id name.
68; If End_of_Line_Delimiter then
69; return an error_code
70; Else
71; If first non-delimiter is ALPHA-NUMARIC or
72; If character is '(' then
73; (assume an id name)
74; Extracts id name
75; Update offset counter
76;
77; Pull out HWCP
78; If error flag is set then exit
79; Else if end of line flag is set then exit
80;
81; Pull out DESG parms
82; If error_flag is set then exit.
83; Else if end of line flag is set then exit
84; Else if Number of devices is four then Exit
85; Else Loop
86;
87;
88;Subroutines Logic:
89;------------------
90;
91; GET_CHAR:
92; ---------
93; Load character in AL
94; If character less than 20h then
95; turn Z-flag on
96;
97; IS_ALPHA:
98; ---------
99; Save character
100; 'Convert character to upper case'
101; If character >=A and <=Z then
102; turn Z-flag on
103; exit
104; Else
105; Restore character
106; exit.
107;
108; IS_DIGIT:
109; --------- If Character >=0 and <=9 then
110; turn Z-flag on
111;
112; IS_DELIMITER:
113; -------------
114; If character a dos delimiter (' ','=',',',';',TAB)
115; then turn Z-flag on
116;
117; DEVICE_PARSE:
118; -------------
119; Set device name length counter.
120; Loop
121; If a dos delimiter then
122; add spaces to name (if require)
123; Else if char is ALPHA-NUM then
124; save in table
125; If name >8 character thne
126; error; exit
127; Else
128; error; exit
129;
130; ID_PARSE:
131; --------- Set id name length counter.
132; Loop
133; If a dos delimiter then
134; add spaces to name (if require)
135; Else if char is ALPHA-NUM then
136; save in table
137; If name >8 character then
138; error; exit
139; Else if char is ')' or '(' then
140; set flags
141; Else
142; error; exit
143;
144; HWCP_PARMS:
145; -----------
146; Loop: Set flags off
147; If char is a DIGIT then
148; convert number to binary
149; update table
150; Else if char is ',' then
151; no HWCP was given
152; exit
153; Else if char is '(' then
154; assume multiple HWCP
155; Else if char is ')' then
156; end of parms, exit
157; Else if not a delimiter then
158; error, exit set carry flag set carry flag
159; Loop
160;
161; HWCP_PARSE:
162; ----------- Increment counter
163; Get number and convert to binary
164; Update the table
165; Set table_5 pointer
166;
167; MUL_HWCP:
168; ---------
169; Loop: If char is ')' then
170; end of list, exit
171; If char is a DIGIT
172; Get number and convert to binary
173; Update table.
174; If char is not a delimiter then
175; error, exit set carry flag
176; Loop
177;
178; DESG_PARMS:
179; -----------
180; Loop: If char is a DIGIT then
181; Get number and convert to binary
182; Update table.
183; If char is a ')' then
184; end of parms, exit
185; If char is a '(' then
186; assume given desg. and font
187; If char is a ',' then
188; no desg ginven
189; scane for ')'
190; If char is not a delimiter then
191; error, exit set carry flag
192; Loop
193;
194; DESG_FONT:
195; ----------
196; Loop: If char is a ',' then
197; no desg number was given
198; update table
199; If char is a ')' then
200; end of desg-font pair, exit
201; If char is a DIGIT then
202; Get number and convert to binary
203; Update table
204; If char not a delimiter then
205; error, exit set carry flag
206; Loop
207;
208; DESG_PARSE:
209; ----------- Get number and conver to binary
210; Update table
211;
212; GET_NUMBER:
213; ----------- Get ASCII number from parms
214; conver to binary
215; add to total
216;
217; OFFSET_TABLE:
218; -------------
219; Increment the number of parms
220;
221; FIND_RIGHT_BR:
222; --------------
223; Loop: If char is ')' then
224; found bracket exit
225; If char is not ' ' then
226; error, exit set carry flag
227; Loop
228; END
229;------------------------------------------------------
230;
231; The following is the table structure of the parser. All fields are
232; two bytes field (accept for the device and id name)
233;
234; TABLE HEADER :
235; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
236; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
237; ³ N = Number of devices. ³
238; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
239; ³ Device # 1 offset ÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
240; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³
241; ³ Device # 2 offset ³ ³ Table_1 (a) ³
242; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³
243; ³ Device # 3 offset ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
244; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
245; ³ Device # 4 offset ³
246; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
247;
248;
249; N = 1,2,3 or 4. A two bytes number indicating the number of device specified.
250; DEVICE # N OFFSET : a two bytes offset address to table_1. (ie. Device #1 offset
251; is a pointer to table_1 (a). Device #2 offset is a pointer to table_1
252; (b)...etc.). If an error was detected in the command N is set to zero.
253;
254;
255;
256; TABLE_1 :
257; ÍÍÍÍÍÍÍÍÍ
258;
259; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
260; ³ N = Number of Offsets. ³ ³ ³
261; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ÚÄÄÄÄÄij Table_2 (a) ³
262; ³ Device Name offset ÄÅÄÄÄÄÙ ³ ³
263; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
264; ³ Device Id offset ÄÅÄÄÄÄÄÄ¿
265; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
266; ³ Device HWCP offset ÄÅÄÄÄÄ¿ ³ ³ ³
267; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ÀÄÄÄij Table_3 (a) ³
268; ³ Device Desg offset ÄÅÄÄ¿ ³ ³ ³
269; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
270; ³ "Reserved" ³ ³ ³
271; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
272; ³ ³ ³ ³
273; ³ ÀÄÄÄÄÄij Table_4 (a) ³
274; ³ ³ ³
275; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
276; ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
277; ³ ³ ³
278; ÀÄÄÄÄÄÄÄij Table_5 (a) ³
279; ³ ³
280; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
281;
282;
283; N=Length of table_1, or the number of offsets contained in table_1.
284; The offsets are pointers (two bytes) to the parameters value of the device.
285; "Reserved" : a two byte memory reserved for future use of the "PARMS" option.
286;
287;
288; TABLE_2 :
289; ÍÍÍÍÍÍÍÍÍ
290;
291; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
292; ³ N = Length of devices name ³
293; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
294; ³ Device name ³
295; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
296;
297; N = Length of device name. Device length is always 8 byte long.
298; Device Name : the name of the device (eg. LPT1, CON, PRN). The name
299; is paded with spaces to make up the rest of the 8 characters.
300;
301;
302;
303; TABLE_3 :
304; ÍÍÍÍÍÍÍÍÍ
305;
306; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
307; ³ N = Length of Id name. ³
308; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
309; ³ Id Name ³
310; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
311;
312; N = Length of id name. Id name length is always 8 byte long.
313; Id Name : the name of the id (eg. EGA, VGA, 3812). The name
314; is paded with spaces to make up the rest of the 8 character.
315;
316;
317;
318; TABLE_4 :
319; ÍÍÍÍÍÍÍÍÍ
320;
321; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
322; ³ N = Length of table. ³
323; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
324; ³ HWCP # 1 ³
325; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
326; ³ HWCP # 2 ³
327; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
328; ³ . ³
329; ³ . ³
330; ³ . ³
331; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
332; ³ HWCP # 10 ³
333; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
334;
335;
336; N = Length of table in words. Or the number of HWCP's.
337; HWCP # N : a hardware code page number converted to binary. The maximum
338; number of pages allowed is 10.
339;
340;
341;
342; TABLE_5 :
343; ÍÍÍÍÍÍÍÍÍ
344;
345; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
346; ³ N = Length of table. ³
347; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
348; ³ Designate ³
349; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
350; ³ Font ³
351; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
352;
353; N = Lenght of table. 0 - nothing was specified
354; 1 - Only a designate was specified.
355; 2 - Designate and font were given. If the Desg field
356; was left empty in the DEVICE command then the
357; Designate field is filled with 0FFFFH.
358; Designate, Font : Are the Desg. and Font binary numbers.
359;
360;------------------------------------------------------
361;
362
363PROGRAM SEGMENT
364
365 ASSUME CS:PROGRAM
366 ASSUME DS:PROGRAM
367 ASSUME ES:PROGRAM
368
369 ORG 100H
370
371START:
372 JMP NOW
373
374;RESERVED MEMORY:
375TABLE_1 DW ? ; Pointer at offsets.
376TABLE_2 DW ? ; Pointer at device name.
377TABLE_3 DW ? ; Pointer at id name.
378TABLE_4 DW ? ; Pointer at hwcp.
379TABLE_5 DW ? ; Pointer at desg and font.
380TABLE DB 290 DUP (?) ; Table of parsed parms. Max 4 devices.
381DEVNUM DW ? ; Counter to number of devices.
382RIGHT_FLAG DB ? ; Flag to indicate a left bracket.
383DEV_ERR_FLG DB ? ; Device name error flag.
384ID_ERR_FLG DB ? ; Id name error flag.
385ERROR_FLAG DB ? ; Error flag_terminate program if set to 1.
386COMMA_FLAG DB ? ; Indicate the number of commas incounterd.
387HWCP_FLAG DB ? ; Flag for multiple hwcps.
388DESG_FLAG DB ? ; Flag indicates desg. and font.
389
390;Main part of program-links different sumbroutines together
391NOW:
392 CALL PARSER
393 INT 20H ;Exit DOS.
394
395PARSER PROC
396
397 PUSH AX ; ;;;;;;;;;;;;;;;;;;
398 PUSH BX ; ;
399 PUSH CX ; ; SAVE
400 PUSH DX ; ; ALL
401 PUSH DS ; ; REGISTERS.
402 PUSH ES ; ;
403 PUSH DI ; ;
404 PUSH SI ; ;;;;;;;;;;;;;;;;;;
405
406 ;LES SI,RH.RH0_BPBA ; Point at all after DEVICE=
407 ; in the CONFIG.SYS file.
408
409 mov di,81h ; ;;;;;;;;;;;;;;;;;;;;;;;;;
410 mov cl,cs:byte ptr [di-1] ; ; ;;
411 xor ch,ch ; ; ERASE THIS ;;
412 add di,cx ; ;;;;;;;; CODE IN ;;
413 mov ds:word ptr[di],0a0dh ; ; CPS ;;
414 ; ;;;;;;;; ;;
415 MOV SI,0081h ; ;Set SI at parameters. ;;
416 ; ;;;;;;;;;;;;;;;;;;;;;;;;;
417
418;Skip to end of file name, to the first DOS delimiter.
419
420 MOV DEVNUM,02H ; Number of devices counter.
421
422GET_PARMS_A: CALL GET_CHAR ; Get command character in AL .
423 JZ EXIT_B ; No parms found.
424 CALL IS_DELIM ; If not a delimiter then.
425 JNE GET_PARMS_A ; Check next character.
426
427 MOV DI,OFFSET TABLE ; Get the table address.
428 ADD DI,02H ; Point at devices offsets.
429 MOV BX,DI ;
430 ADD BX,08H ; Point BX at parms offsets.
431TAB2: CALL UPDATE_TABLE ; Update table pointers value.
432
433CLR_DELIM: CALL GET_CHAR ; Get character into AL.
434 JZ EXIT_B ; No parms found.
435 CALL IS_ALPHA ; If alpha then assume.
436 JZ DEVICE ; A device name.
437 CALL IS_DELIM ; Is it a delimiter
438 JNE EXIT_A ; If not then error.
439 JMP CLR_DELIM ; Get next character.
440
441DEVICE: MOV DEV_ERR_FLG,00H ; Set device error flag off;
442 CALL DEVICE_PARSE ; Call routine to parse device name.
443 CMP DEV_ERR_FLG,01H ; If error flag is
444 JZ EXIT_A ; set then exit.
445 CALL OFFSET_TABLE ; Update table.
446
447ID_PARMS: CALL GET_CHAR ; Load a character in AL.
448 JZ EXIT_A ; Exit if end of line (error).
449 CMP AL,'(' ; If AL is a '(' then
450 JE ID ; Parse ID name.
451 CALL IS_ALPHA ; If an Alpha
452 JE ID ; Then parse ID name.
453 CALL IS_DIGIT ; If a digit
454 JE ID ; Then parse ID name.
455 CALL IS_DELIM ; If not a delimiter
456 JNE EXIT_A ; Then error, exit
457 JMP ID_PARMS ; Get another number
458
459EXIT_B: CMP DEVNUM,02H ; If device number above 2 then
460 JA EXIT_C ; Exit parse.
461 JMP EXIT_A ; Else error, exit
462
463ID: MOV ID_ERR_FLG,00H ; Set id error flag off.
464 CALL ID_PARSE ; Parse ID name.
465 CMP ID_ERR_FLG,01H ; Was error flag set, then
466 JE EXIT_A ; Print error message.
467 CALL OFFSET_TABLE ; Update table of offsets.
468
469 CALL HWCP_PARMS ; Get code page number
470 CMP ERROR_FLAG,01H ; If error, then
471 JE EXIT_A ; Print error message and exit
472 CMP ERROR_FLAG,02H ; If end of string
473 JE EXIT_H ; Then exit.
474
475 CALL DESG_PARMS ; Get designate number
476 CMP ERROR_FLAG,01H ; If error, then
477 JE EXIT_A ; Print error message and exit
478 JMP EXIT_H ; Then exit.
479
480EXIT_A: MOV DI,OFFSET TABLE ; Load table offset
481 MOV DS:WORD PTR [DI],00H ; Set error to on.
482 STC ; Set carry flag
483 JMP EXIT_P ; Exit parse.
484
485EXIT_H: MOV DI,OFFSET TABLE ; Load table offset.
486 ADD DS:WORD PTR [DI],01H ; Increment number of devices.
487 CMP DEVNUM,08H ; If 4 devices loaded
488 JE EXIT_C ; Then exit parse.
489 ADD DEVNUM,02H ; Increment the number of devices
490 ADD DI,DEVNUM ; Point at next devices offset.
491 MOV BX,TABLE_5 ; BX point at
492 ADD BX,06H ; end of previous table.
493 JMP TAB2 ; Get next device.
494
495EXIT_C: CLC
496
497EXIT_P: POP SI ; ;;;;;;;;;;;;;;;;;;
498 POP DI ; ;
499 POP ES ; ; RESTORE
500 POP DS ; ; ALL
501 POP DX ; ; REGISTERS.
502 POP CX ; ;
503 POP BX ; ;
504 POP AX ; ;;;;;;;;;;;;;;;;;;
505 RET
506
507PARSER ENDP
508
509
510;********************************************************
511;** GET_CHAR : a routine to get next character pointed **
512;** to by ES:SI into AL. **
513;********************************************************
514
515GET_CHAR PROC
516
517 MOV AL,ES:BYTE PTR [SI] ; Load character pointed to
518 CMP AL,09H ; by ES:[SI] in AL.
519 JE ZOFF ; If tab then O.K
520 CMP AL,20H ; Turn Z-flag on
521 JL TURN_Z_ON ; if character
522ZOFF: INC SI ; is below
523 JMP GET_CHAR_X ; 20h.
524 ; ( End of line
525TURN_Z_ON: CMP AL,AL ; delimiters ).
526GET_CHAR_X: RET
527
528GET_CHAR ENDP
529
530
531;********************************************************
532;** IS_ALPHA : a routine to check the character in **
533;** AL if it is an alpha character (a...z,A...Z). **
534;** If character is lower case, convert to upper case. **
535;********************************************************
536
537IS_ALPHA PROC
538
539 PUSH AX ; Save value of AL
540 AND AL,0DFH ; Convert to upper case
541 CMP AL,'A' ; If <'A', then
542 JB IS_ALPHA_X ; NZ-flag is set, exit
543 CMP AL,'Z' ; If >'Z', then
544 JA IS_ALPHA_X ; NZ-flag is set, exit
545 CMP AL,AL ; Force Z-flag
546 POP DX ; Discard lower case.
547 JMP IA_X ; Exit.
548IS_ALPHA_X: POP AX ; Restore value of AL
549IA_X: RET
550
551IS_ALPHA ENDP
552
553
554;********************************************************
555;** IS_DIGIT : a routine to check if the character in **
556;** AL register is a digit (i.e. 1..9). **
557;********************************************************
558
559IS_DIGIT PROC
560
561 CMP AL,'0' ; If < '0' then
562 JB IS_NUM_X ; NZ-flag is set, exit
563 CMP AL,'9' ; If > '9' then
564 JA IS_NUM_X ; NZ-flag is set, exit
565 CMP AL,AL ; Set Z-flag to indecate digit
566IS_NUM_X: RET
567
568IS_DIGIT ENDP
569
570
571;********************************************************
572;** IS_DELIM : This routine check if the character in **
573;** AL is a delimiter. ('+',' ',';',',','=',tab) **
574;********************************************************
575
576IS_DELIM PROC
577
578 CMP AL,' ' ; Test for space.
579 JE IS_DELIM_X ; Z-flag is set, exit
580 CMP AL,',' ; Test for comma.
581 JE IS_DELIM_X ; Z-flag is set, exit
582 CMP AL,';' ; Test for semicolon.
583 JE IS_DELIM_X ; Z-flag is set, exit
584 CMP AL,'=' ; Test for equal sign.
585 JE IS_DELIM_X ; Z-flag is set, exit
586 CMP AL,09h ; Test for TAB.
587
588IS_DELIM_X: RET ; Exit
589
590IS_DELIM ENDP
591
592
593;********************************************************
594;** DEVICE_PARSE : Parse the device driver name and **
595;** store in table. Update offset. **
596;********************************************************
597
598DEVICE_PARSE PROC
599
600 MOV DI,TABLE_2
601 MOV DS:WORD PTR [DI],0008H ; Save dev name size.
602 ADD DI,02H ; Increment DI.
603 MOV CX,9 ; Set counter.
604NEXT_C: CALL IS_ALPHA ; if Check then.
605 JZ SAVE_C ; Save it.
606 CALL IS_DIGIT ; if Digit then.
607 JZ SAVE_C ; Save it.
608 CMP AL,'-' ; If '-' then.
609 JZ SAVE_C ; Save it.
610 CALL IS_DELIM ; If a delimiter then.
611 JZ ADD_SPACE1 ; Pad with spaces.
612 CMP AL,':' ; If a colon
613 JE ADD_SPACE1 ; then end device parse
614 JMP ERR_DEV_PAR ; Else an error.
615
616SAVE_C: DEC CX ; Decrement counter.
617 CMP CX,0 ; If counter zero then.
618 JE ERR_DEV_PAR ; Error.
619 MOV DS:BYTE PTR [DI],AL ; Save char in table.
620 INC DI ; Increment pointer.
621 CALL GET_CHAR ; Get another char.
622 JZ ERR_DEV_PAR
623 JMP NEXT_C ; Check char.
624
625ERR_DEV_PAR: MOV DEV_ERR_FLG,01H ; Set error flag.
626 JMP DEV_PAR_X ; Exit.
627
628ADD_SPACE1: DEC CX ; Check counter.
629 CMP CX,1
630 JL DEV_PAR_X ; Exit if already 8.
631LL1: MOV DS:BYTE PTR [DI],' ' ; Pad name with spaces.
632 INC DI ; Increment pointer.
633 LOOP LL1 ; Loop again.
634DEV_PAR_X: RET
635
636DEVICE_PARSE ENDP
637
638
639;********************************************************
640;** ID_PARSE : Parse the id driver name and **
641;** store in table. Update offset. **
642;********************************************************
643
644ID_PARSE PROC
645
646 MOV DI,TABLE_3
647 MOV DS:WORD PTR [DI],0008H ; Save dev name size.
648 ADD DI,02H ; Increment DI.
649 MOV RIGHT_FLAG,00H ; Clear flag.
650 MOV CX,9 ; Set counter.
651
652NEXT_I: CALL IS_ALPHA ; If Check then.
653 JZ SAVE_I ; Save it.
654 CALL IS_DIGIT ; if Digit then.
655 JZ SAVE_I ; Save it.
656 CMP AL,'-' ; If '-' then.
657 JZ SAVE_I ; Save it.
658 CMP AL,'(' ; If '(' then.
659 JE RIG_BR_FLG ; Set flag.
660 CMP AL,')' ; If ')' then
661 JE BR_FLG_LEF ; Pad with spaces.
662 CALL IS_DELIM ; If a delimiter then.
663 JZ ADD_SPACE2 ; Pad with spaces.
664 JMP ERR_ID_PAR ; Else an error.
665
666SAVE_I: DEC CX ; Decrement counter.
667 CMP CX,0 ; If counter zero then.
668 JLE ERR_ID_PAR ; Error.
669 MOV DS:BYTE PTR [DI],AL ; Save char in table.
670 INC DI ; Increment pointer.
671 CALL GET_CHAR ; Get another char.
672 JZ ADD_SPACE2 ; Exit routine.
673 JMP NEXT_I ; Check char.
674
675ERR_ID_PAR: MOV ID_ERR_FLG,01H ; Set error falg on.
676 JMP ID_PAR_X ; Exit.
677
678BR_FLG_LEF: CMP RIGHT_FLAG,01H ; If left bracket was
679 JNE ERR_ID_PAR ; found and no previous
680 JMP ADD_SPACE2 ; Bracket found, then error
681
682RIG_BR_FLG: CMP RIGHT_FLAG,01H ; If more than one bracket
683 JE ERR_ID_PAR ; then error.
684 CMP CX,09 ; If '(' and already id
685 JB ERR_ID_PAR ; then error.
686 MOV RIGHT_FLAG,01H ; Set flag for.
687 CALL GET_CHAR ; Left brackets.
688 JZ ERR_ID_PAR ; If end of line,exit.
689 JMP NEXT_I ; Check character.
690
691ADD_SPACE2: DEC CX ; Check counter.
692 CMP CX,1
693 JL ID_PAR_X ; Exit if already 8.
694
695LL2: MOV DS:BYTE PTR [DI],' ' ; Pad name with spaces.
696 INC DI ; Increment pointer.
697 LOOP LL2 ; Loop again.
698
699ID_PAR_X: RET
700
701ID_PARSE ENDP
702
703;********************************************************
704;** HWCP_PARMS : Scane for the hardware code page, and **
705;** parse it if found. Flag codes set to: **
706;** ERROR_FLAG = 0 - parsing completed. No error. **
707;** ERROR_FLAG = 1 - error found exit parse. **
708;** ERROR_FLAG = 2 - end of line found, exit parse. **
709;********************************************************
710
711
712HWCP_PARMS PROC
713
714 MOV COMMA_FLAG,00H ; Set the comma flag off.
715 MOV ERROR_FLAG,00H ; Set the error flag off.
716 DEC SI ; Point at current char in Al.
717 CMP RIGHT_FLAG,01H ; If no left brackets then
718 JNE LEFT_BR ; Exit parse.
719
720HWCP_1: CALL GET_CHAR ; Load character in AL.
721 JZ LEFT_BR ; Exit, if end of line.
722 CALL IS_DIGIT ; Check if digit, then
723 JE HP1 ; Parse hwcp parms.
724 CMP AL,',' ; If a comma
725 JE COMMA_1 ; Jump to comma_1
726 CMP AL,')' ; If a ')' then
727 JE RIGHT_BR ; end of current dev parms.
728 CMP AL,'(' ; If a '(' then
729 JE HWCP_2 ; There are multible hwcp.
730 CALL IS_DELIM ; Else, if not a delimiter
731 JNE EXIT_2 ; Then error, exit
732 JMP HWCP_1 ; Get another character.
733
734LEFT_BR: CMP RIGHT_FLAG,01H ; If no left bracket
735 JE EXIT_2 ; Then error, exit
736 JMP RB1 ; Jump to rb1
737
738COMMA_1: CMP COMMA_FLAG,01H ; If comma flag set
739 JE COM_2_HC ; Then exit hwcp parse.
740 MOV COMMA_FLAG,01H ; Else set comma flag.
741JMP HWCP_1 ; Get another character.
742
743HWCP_2: CMP RIGHT_FLAG,01H ; If left bracket not set
744 JNE EXIT_2 ; then error.
745 CALL MUL_HWCP ; else call multiple hwcp
746 ADD DI,02H ; routine. Increment DI
747 MOV TABLE_5,DI ; Desg. Table starts at end
748 CALL OFFSET_TABLE ; Update table of offsets.
749 JMP HP_X ; Exit.
750
751HP1: JMP HWCP ; Jump too long.
752
753COM_2_HC: MOV DI,TABLE_4 ; DI points at hwcp table
754 MOV DS:WORD PTR [DI],0000H ; Set number of pages to
755 MOV COMMA_FLAG,00H ; Zero and reset comma flag.
756 ADD DI,02H ; Increment DI.
757 MOV TABLE_5,DI ; Desg. Table starts at end
758 CALL OFFSET_TABLE ; Update table of offsets.
759 JMP HP_X ; of hwcp table. Exit.
760
761RIGHT_BR: CMP RIGHT_FLAG,01H ; If left brackets not
762 JNE EXIT_2 ; Found then error.
763RB1: MOV ERROR_FLAG,02H ; Set end of line flag.
764 MOV BX,TABLE_4 ; Point at hwcp table
765 ADD BX,02H ; Adjust pointer to desg
766 MOV TABLE_5,BX ; table, and save in table_5
767 MOV DI,TABLE_1 ; Point at table of offsets
768 ADD DI,08H ; Set at DESG offset
769 MOV DS:WORD PTR [DI],BX ; Update table.
770 JMP HP_X ; Exit
771
772
773
774EXIT_2: MOV ERROR_FLAG,01H ; Set error flag.
775 JMP HP_X ; and exit.
776
777HWCP: CMP RIGHT_FLAG,01H ; If left brackets not
778 JNE EXIT_2 ; Found then error.
779 CALL HWCP_PARSE ; Call parse one hwcp.
780 CMP ERROR_FLAG,01H ; If error flag set
781 JE HP_X ; Then exit, else
782 CALL OFFSET_TABLE ; Update table of offsets.
783
784HP_X: RET
785
786HWCP_PARMS ENDP
787
788
789;********************************************************
790;** HWCP_PARSE : Parse the hardware code page page **
791;** number and change it from hex to binary. **
792;********************************************************
793
794HWCP_PARSE PROC
795
796 MOV DI,TABLE_4 ; Load address of hwcpages.
797 ADD DS:WORD PTR [DI],0001H ; Set count to 1
798
799 CALL GET_NUMBER ; Convert number to binary.
800 CMP ERROR_FLAG,01H ; If error then
801 JE HWCP_X ; Exit.
802 MOV DS:WORD PTR [DI+2],BX ; Else, save binary page number
803 ADD DI,04H ; Increment counter
804 MOV TABLE_5,DI ; Set pointer of designate num
805
806HWCP_X: RET
807
808HWCP_PARSE ENDP
809
810
811;********************************************************
812;** MUL_HWCP : Parse multiple hardware code pages **
813;** and convert them from hex to binary numbers. **
814;********************************************************
815
816MUL_HWCP PROC
817
818 MOV DI,TABLE_4 ; Load offset of table_4
819 MOV BX,DI ; in DI and Bx.
820 MOV HWCP_FLAG,00H ; Set hwcp flag off.
821
822MH1: CALL GET_CHAR ; Load character in AL.
823 JZ MH3 ; Exit if end of line.
824 CMP AL,')' ; If ')' then exit
825 JE MH2 ; end of parms.
826 CALL IS_DIGIT ; If a digit, then
827 JE MH4 ; Convert number to binary.
828 CALL IS_DELIM ; If not a delimiter
829 JNE MH3 ; then error, exit
830 JMP MH1 ; get another character.
831
832MH2: CALL GET_CHAR ; Get next character
833 JMP MH_X ; and exit.
834
835MH3: MOV ERROR_FLAG,01H ; Set error flag on.
836 JMP MH_X ; Exit.
837
838MH4: ADD HWCP_FLAG,01H ; Set hwcp flag on (0 off)
839 ADD DI,02H ; Increment table pointer
840 PUSH BX ; Save Bx
841 CALL GET_NUMBER ; Convert number to binary.
842 MOV DS:WORD PTR [DI],BX ; Add number to table
843 POP BX ; Restore BX.
844 CMP ERROR_FLAG,01H ; If error then
845 JE MH_X ; Exit.
846 ADD DS:WORD PTR [BX],01H ; Increment hwcp count.
847 DEC SI ; Point at character in AL
848 JMP MH1 ; (delimeter or ')').
849MH_X: RET
850
851MUL_HWCP ENDP
852
853
854
855;********************************************************
856;** DESG_PARMS : Scane for the designate numbers, and **
857;** parse it if found. Flag codes set to: **
858;** ERROR_FLAG = 0 - parsing completed. No error. **
859;** ERROR_FLAG = 1 - error found exit parse. **
860;** ERROR_FLAG = 2 - end of line found, exit parse. **
861;********************************************************
862
863
864DESG_PARMS PROC
865
866 MOV DI,TABLE_1 ; Get offset of dev in DI
867 MOV BX,TABLE_5 ; & offset of desg. in BX.
868 ADD DI,08 ; Location of desg offset in table.
869 MOV DS:WORD PTR [DI],BX ; Update table.
870 MOV COMMA_FLAG,00H ; Set comma flag off.
871
872 cmp al,'('
873 je df
874 cmp al,')'
875 je right_br2
876
877 cmp al,','
878 jne desg_parm1
879 mov comma_flag,01h
880
881DESG_PARM1: CALL GET_CHAR ; Get character in AL.
882 JZ EXIT_3 ; Error, if end of line
883 CALL IS_DIGIT ; If character is a digit
884 JE DESG ; Then convert to binary.
885 CMP AL,')' ; If a ')', then
886 JE RIGHT_BR2 ; end of parameters.
887 CMP AL,'(' ; If a '(' then
888 JE DF ; parse desg and font.
889 CMP AL,',' ; If a comma then
890 JE DP3 ; set flag.
891 CALL IS_DELIM ; If not a delimiter
892 JNE EXIT_3 ; then error.
893 JMP DESG_PARM1 ; Get another character.
894
895RIGHT_BR2: CMP RIGHT_FLAG,01H ; IF no '(' encountered,
896 JNE EXIT_3 ; then error, exit
897 JMP DP_x ; Jump to DP1.
898
899EXIT_3: MOV ERROR_FLAG,01H ; Set error flag on
900 JMP DP_X ; Exit.
901
902DF: CMP RIGHT_FLAG,01H ; If no '(' encountered
903 JB EXIT_3 ; then error, exit
904 CALL DESG_FONT ; Parse desg and font.
905 JMP DP1 ; Jump to DP1.
906
907DP2: CALL FIND_RIGHT_BR ; Check for ')'
908 JMP DP_X ; Exit.
909
910DP3: CMP COMMA_FLAG,01H ; If comma flag set
911 JE DP2 ; then error
912 MOV COMMA_FLAG,01H ; Else set comma flag on.
913 JMP DESG_PARM1 ; Get another character.
914
915DESG: MOV ERROR_FLAG,00H ; Set error flag off.
916 CALL DESG_PARSE ; Parse desg.
917DP1: CMP ERROR_FLAG,01H ; If error flag on then
918 JE DP_X ; Exit,
919 CALL FIND_RIGHT_BR ; Else check for ')'
920 CALL OFFSET_TABLE ; Update table
921
922DP_X: RET
923
924DESG_PARMS ENDP
925
926
927
928;********************************************************
929;** DESG_FONT : Parse the designate and font numbers & **
930;** change them from decimal to binary. **
931;********************************************************
932
933
934DESG_FONT PROC
935
936
937 MOV DI,TABLE_5 ; Get desg font table.
938 MOV COMMA_FLAG,00H ; Set comma flag off.
939DF1: CALL GET_CHAR ; Load a character in AL.
940 JZ DF3 ; Error if end of line.
941 CMP AL,',' ; Check if a comma.
942 JE DF2 ; Set flag.
943 CALL IS_DIGIT ; If a digit, then
944 JE DF5 ; Convert number to binary.
945 CMP AL,')' ; If a ')' then
946 JE DF4 ; Exit.
947 CALL IS_DELIM ; If not a delimiter
948 JNE DF3 ; then error, exit
949 JMP DF1 ; Get another character.
950
951DF2: CMP COMMA_FLAG,01H ; If comma flag on
952 JE DF3 ; then error, exit
953 MOV COMMA_FLAG,01H ; Set comma flag on
954 ADD DS:WORD PTR [DI],01H ; Increment desg counter.
955 MOV DS:WORD PTR [DI+2],0FFFFH ; Load ffffh for desg empty
956 JMP DF1 ; field.
957
958DF3: MOV ERROR_FLAG,01H ; Set error flag on.
959 JMP DF_X ; Exit.
960
961DF4: CMP DESG_FLAG,00H ; If desg flag off
962 JE DF3 ; then error, exit
963 JMP DF_X ; Else exit.
964
965DF5: ADD DS:WORD PTR [DI],01H ; Increment desg font count.
966 CMP DESG_FLAG,01H ; If desg flag is on
967 JE DF6 ; then get font.
968 CMP COMMA_FLAG,01H ; if comma flag is on
969 JE DF6 ; then get font.
970 MOV DESG_FLAG,01H ; Set desg flag on
971 JMP DF7 ; Get desg number.
972
973DF6: ADD DI,02H ; adjust pointer to font.
974 MOV DESG_FLAG,02H ; Set desg and font flag.
975DF7: CALL GET_NUMBER ; Get a number & convert to
976 CMP ERROR_FLAG,01H ; binary.
977 JE DF_X ; If error flag set, Exit.
978 MOV DS:WORD PTR [DI+2],BX ; Store number in table.
979 CMP DESG_FLAG,02H ; If desg and font flag
980 JNE DF1 ; not set, then get char.
981 CALL FIND_RIGHT_BR ; Check for right bracket.
982
983DF_X: RET
984
985DESG_FONT ENDP
986
987
988;********************************************************
989;** DESG_PARSE : Parse the designate number and **
990;** change it from decimal to binary. **
991;********************************************************
992
993DESG_PARSE PROC
994
995 MOV DI,TABLE_5 ; Load designate location
996 ADD DS:WORD PTR [DI],0001H ; Update table count.
997
998 CALL GET_NUMBER ; Get the ascii number and
999 CMP ERROR_FLAG,01H ; conver it to binary
1000 JE DESG_X ; If error then exit
1001
1002 MOV DS:WORD PTR [DI+2],BX ; Else, save desg number
1003
1004
1005DESG_X: RET
1006
1007DESG_PARSE ENDP
1008
1009
1010;********************************************************
1011;** GET_NUMBER : Convert the number pointed to by SI **
1012;** to a binary number and store it in BX **
1013;********************************************************
1014
1015GET_NUMBER PROC
1016
1017 MOV CX,0AH ; Set multiplying factor
1018 XOR BX,BX ; Clear DX
1019
1020NEXT_NUM: SUB AL,30H ; Conver number to binary
1021 CBW ; Clear AH
1022 XCHG AX,BX ; Switch ax and bx to mul
1023 MUL CX ; already converted number by 10.
1024 JO ERR_NUM ; On over flow jump to error.
1025 ADD BX,AX ; Add number to total.
1026 JC ERR_NUM ; On over flow jump to error.
1027 XOR AX,AX ; Clear AX (clear if al=0a).
1028 CALL GET_CHAR ; Get next character
1029 JZ GET_NUM_X ; Exit, if end of line.
1030 CALL IS_DIGIT ; Call is digit.
1031 JNZ GET_NUM_X ; Exit if not a number.
1032 JMP NEXT_NUM ; Loop.
1033
1034ERR_NUM: MOV ERROR_FLAG,01H ; Set error code to 1.
1035
1036GET_NUM_X: RET
1037
1038GET_NUMBER ENDP
1039
1040
1041;********************************************************
1042;** UPDATE_TABLE : This routine set up pointers to the **
1043;** different offsets of the different tables **
1044;********************************************************
1045
1046UPDATE_TABLE PROC
1047
1048 MOV DS:WORD PTR [DI],BX ; Offset of offsets
1049 MOV TABLE_1,BX ; Table_1 points at offsets
1050
1051 MOV DI,BX ;
1052 ADD BX,0CH ;
1053 MOV DS:WORD PTR [DI+2],BX ; Offset of DEVICE name.
1054 MOV TABLE_2,BX ; Table_2 point at device name.
1055
1056 ADD BX,0AH ;
1057 MOV DS:WORD PTR [DI+4],BX ; Offset of ID name.
1058 MOV TABLE_3,BX ; Table_3 point at ID name.
1059
1060 ADD BX,0AH ;
1061 MOV DS:WORD PTR [DI+6],BX ; Offset of HWCP pages.
1062 MOV TABLE_4,BX ; Table_4 point at HWCP pages.
1063
1064 RET
1065
1066UPDATE_TABLE ENDP
1067
1068
1069;********************************************************
1070;** OFFSET_TABLE : This routine set up pointers of **
1071;** tables number one and two. **
1072;********************************************************
1073
1074OFFSET_TABLE PROC
1075
1076 MOV DI,TABLE_1 ; Increment the number
1077 ADD DS:WORD PTR [DI],01H ; of parms foun. (ie. id,hwcp
1078 RET ; and desg)
1079
1080OFFSET_TABLE ENDP
1081
1082
1083;********************************************************
1084;** FIND_RIGHT_BR :This routine scane the line for a **
1085;** ')' if cannot find it turns error flag on **
1086;********************************************************
1087
1088FIND_RIGHT_BR PROC
1089
1090FBR1: CMP AL,')' ; If a right bracket
1091 JE FBR_X ; then exit.
1092 CMP AL,' ' ; If not a space
1093 JNE FBR2 ; Then error.
1094 CALL GET_CHAR ; Get a character
1095 JZ FBR2 ; If end of line then exit.
1096 JMP FBR1 ; Else get another character.
1097
1098FBR2: MOV ERROR_FLAG,01H ; Set error flag on
1099FBR_X: MOV AL,20H ; Erase character from AL.
1100 RET
1101
1102FIND_RIGHT_BR ENDP
1103
1104
1105PROGRAM ENDS
1106 END START