1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
|
PAGE ,132
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; FILENAME: CPS Printer Device Driver INIT module (CPSPInn)
;; MODULE NAME:
;; TYPE: Assemble file (non-resident code)
;; LINK PROCEDURE: Link CPSPMnn+CPSFONT+CPSPInn into .EXE format. CPSPM01
;; must be first. CPSPInn must be last. Everything
;; before CPSPInn will be resident.
;; INCLUDE FILES:
;; CPSPEQU.INC
;;
;; LAYOUT : This file is divided into two main section :
;; ++++++++++++++++++++++++
;; ++ DEVICE Parser ++
;; ++++++++++++++++++++++++
;;
;; ++++++++++++++++++++++++
;; ++ INIT Command ++
;; ++++++++++++++++++++++++
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
INCLUDE CPSPEQU.INC ;;
;;
PUBLIC INIT ;;
PUBLIC CODE_END ;; for MAP listing only
PUBLIC RESIDENT_END ;;
PUBLIC STACK_ALLOCATED ;;
;;
;;
EXTRN PRINTER_DESC_NUM:WORD ;;
EXTRN PRINTER_DESC_TBL:WORD ;;
EXTRN INIT_CHK:WORD,TABLE:WORD ;;
EXTRN HARD_SL1:BYTE,RAM_SL1:BYTE ;;
EXTRN HARD_SL2:BYTE,RAM_SL2:BYTE ;;
EXTRN HARD_SL3:BYTE,RAM_SL3:BYTE ;;
EXTRN HARD_SL4:BYTE,RAM_SL4:BYTE ;;
EXTRN RESERVED1:WORD,RESERVED2:WORD ;;
;;
EXTRN MSG_NO_INIT_P:BYTE ;;
EXTRN MSG_NO_INIT:BYTE ;;
EXTRN MSG_BAD_SYNTAX:BYTE ;;
EXTRN MSG_INSUFF_MEM:BYTE ;;
;;
;;
CSEG SEGMENT PARA PUBLIC 'CODE' ;;
ASSUME CS:CSEG ;;
;;
;;
CODE_END EQU $ ;; end of resident code
;;
DW 0 ;; -- there are 16 bytes kept,
;; including this word
;;
RESIDENT_END DW 0FFFH ;; end of extended resident area
STACK_ALLOCATED DW -1 ;; end of extended resident area
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; End of resident code
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Incorporating Device Command Parser :
;;
;; -- extracted from PARSE4E.ASM, size 49582 bytes
;;
;; (some modifications have to be made in the section right after the parser's
;; document and before the GET_PARMS_A, one of them is :)
;;
;; -- move the TABLE to the printer device driver's main module
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; ++++++++++++++++++++++++
;; ++ DEVICE Parser ++
;; ++++++++++++++++++++++++
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;; PARSER's code -- non resident
;;
;; -- set ES:[DI] pointing to the Request Header before calling PARSER
;;
;; to be called as PARSER with ES:[DI] defined as Request Header
;; If there is any syntax error in the DEVICE command line, the
;; Parser return a 0 in the first word (NUMBER)of the first table.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;
; Description: A command parser for DEVICE command in the CONFIG.SYS file.
; ------------
;
; Procedures contained in the file:
; ---------------------------------
; PARSER: Main routine for command processing.
; GET_CHAR: Gets a character from command line.
; IS_ALPH: Checks if character is an alpha character.
; IS_DIGIT: Checks if character is a digit.
; IS_DELIM: Checks if character is a DOS delimiter.
; DEVICE_PARSE: Pulls device name from command line and
; inserts in table.
; ID_PARSE: Pulls id name from command line and insers in table
; HWCP_PARMS: Extract HWCP number, converts it to binary and
; inserts it in table.
; HWCP_PARSE: Extracts HWCP number if only one number is given.
; MUL_HWCP: Extracts multiple HWCP's numbers, if they are given
; in a list.
; DESG_PARMS: Extracts designate number, converts it to binary
; and inserts it in table.
; DESG_FONT: Extracts the designate and the font if both were
; given in command line.
; DESG_PARSE: Pulls designate number if it is the only one given.
; GET_NUMBER: Converts a number to binary.
; OFFSET_TABLE: Updates the counter in table #1.
; FIND_RIGHT_BR: Looks for a right bracket.
;
;
; Change history:
; ---------------
;
;
;LOGIC:
;------
; Establish addressability to parameters.
; Skip until end of path and file name -first delimiter
;
; Loop:
; Isolate the first non-delimiter or non delimeter characters.
; If End_of_Line_Delimiter then
; return an error_code
; Else
; If first non-delimiter is ALPHA then
; (assume a device name)
; Extracts device name
; Update offset counter
;
; Isolate the first non-delimiter characters after id name.
; If End_of_Line_Delimiter then
; return an error_code
; Else
; If first non-delimiter is ALPHA-NUMARIC or
; If character is '(' then
; (assume an id name)
; Extracts id name
; Update offset counter
;
; Pull out HWCP
; If error flag is set then exit
; Else if end of line flag is set then exit
;
; Pull out DESG parms
; If error_flag is set then exit.
; Else if end of line flag is set then exit
; Else if Number of devices is four then Exit
; Else Loop
;
;
;Subroutines Logic:
;------------------
;
; GET_CHAR:
; ---------
; Load character in AL
; If character less than 20h then
; turn Z-flag on
;
; IS_ALPHA:
; ---------
; Save character
; 'Convert character to upper case'
; If character >=A and <=Z then
; turn Z-flag on
; exit
; Else
; Restore character
; exit.
;
; IS_DIGIT:
; --------- If Character >=0 and <=9 then
; turn Z-flag on
;
; IS_DELIMITER:
; -------------
; If character a dos delimiter (' ','=',',',';',TAB)
; then turn Z-flag on
;
; DEVICE_PARSE:
; -------------
; Set device name length counter.
; Loop
; If a dos delimiter then
; add spaces to name (if require)
; Else if char is ALPHA-NUM then
; save in table
; If name >8 character thne
; error; exit
; Else
; error; exit
;
; ID_PARSE:
; --------- Set id name length counter.
; Loop
; If a dos delimiter then
; add spaces to name (if require)
; Else if char is ALPHA-NUM then
; save in table
; If name >8 character then
; error; exit
; Else if char is ')' or '(' then
; set flags
; Else
; error; exit
;
; HWCP_PARMS:
; -----------
; Loop: Set flags off
; If char is a DIGIT then
; convert number to binary
; update table
; Else if char is ',' then
; no HWCP was given
; exit
; Else if char is '(' then
; assume multiple HWCP
; Else if char is ')' then
; end of parms, exit
; Else if not a delimiter then
; error, exit set carry flag set carry flag
; Loop
;
; HWCP_PARSE:
; ----------- Increment counter
; Get number and convert to binary
; Update the table
; Set table_5 pointer
;
; MUL_HWCP:
; ---------
; Loop: If char is ')' then
; end of list, exit
; If char is a DIGIT
; Get number and convert to binary
; Update table.
; If char is not a delimiter then
; error, exit set carry flag
; Loop
;
; DESG_PARMS:
; -----------
; Loop: If char is a DIGIT then
; Get number and convert to binary
; Update table.
; If char is a ')' then
; end of parms, exit
; If char is a '(' then
; assume given desg. and font
; If char is a ',' then
; no desg ginven
; scane for ')'
; If char is not a delimiter then
; error, exit set carry flag
; Loop
;
; DESG_FONT:
; ----------
; Loop: If char is a ',' then
; no desg number was given
; update table
; If char is a ')' then
; end of desg-font pair, exit
; If char is a DIGIT then
; Get number and convert to binary
; Update table
; If char not a delimiter then
; error, exit set carry flag
; Loop
;
; DESG_PARSE:
; ----------- Get number and conver to binary
; Update table
;
; GET_NUMBER:
; ----------- Get ASCII number from parms
; conver to binary
; add to total
;
; OFFSET_TABLE:
; -------------
; Increment the number of parms
;
; FIND_RIGHT_BR:
; --------------
; Loop: If char is ')' then
; found bracket exit
; If char is not ' ' then
; error, exit set carry flag
; Loop
; END
;------------------------------------------------------
;
; The following is the table structure of the parser. All fields are
; two bytes field (accept for the device and id name)
;
; TABLE HEADER :
; ��������������
; ����������������������������Ŀ
; � N = Number of devices. �
; ����������������������������Ĵ
; � Device # 1 offset ����������������>��������������������������Ŀ
; ����������������������������Ĵ � �
; � Device # 2 offset � � Table_1 (a) �
; ����������������������������Ĵ � �
; � Device # 3 offset � ����������������������������
; ����������������������������Ĵ
; � Device # 4 offset �
; ������������������������������
;
;
; N = 1,2,3 or 4. A two bytes number indicating the number of device specified.
; DEVICE # N OFFSET : a two bytes offset address to table_1. (ie. Device #1 offset
; is a pointer to table_1 (a). Device #2 offset is a pointer to table_1
; (b)...etc.). If an error was detected in the command N is set to zero.
;
;
;
; TABLE_1 :
; ���������
;
; ����������������������������Ŀ ��������������������������Ŀ
; � N = Number of Offsets. � � �
; ����������������������������Ĵ ������ij Table_2 (a) �
; � Device Name offset ������� � �
; ����������������������������Ĵ ����������������������������
; � Device Id offset �������Ŀ
; ����������������������������Ĵ � ��������������������������Ŀ
; � Device HWCP offset �����Ŀ � � �
; ����������������������������Ĵ � ����ij Table_3 (a) �
; � Device Desg offset ���Ŀ � � �
; ����������������������������Ĵ � � ����������������������������
; � "Reserved" � � �
; ������������������������������ � � ��������������������������Ŀ
; � � � �
; � ������ij Table_4 (a) �
; � � �
; � ����������������������������
; � ��������������������������Ŀ
; � � �
; ��������ij Table_5 (a) �
; � �
; ����������������������������
;
;
; N=Length of table_1, or the number of offsets contained in table_1.
; The offsets are pointers (two bytes) to the parameters value of the device.
; "Reserved" : a two byte memory reserved for future use of the "PARMS" option.
;
;
; TABLE_2 :
; ���������
;
; ����������������������������Ŀ
; � N = Length of devices name �
; ����������������������������Ĵ
; � Device name �
; ������������������������������
;
; N = Length of device name. Device length is always 8 byte long.
; Device Name : the name of the device (eg. LPT1, CON, PRN). The name
; is paded with spaces to make up the rest of the 8 characters.
;
;
;
; TABLE_3 :
; ���������
;
; ����������������������������Ŀ
; � N = Length of Id name. �
; ����������������������������Ĵ
; � Id Name �
; ������������������������������
;
; N = Length of id name. Id name length is always 8 byte long.
; Id Name : the name of the id (eg. EGA, VGA, 3812). The name
; is paded with spaces to make up the rest of the 8 character.
;
;
;
; TABLE_4 :
; ���������
;
; ����������������������������Ŀ
; � N = Length of table. �
; ����������������������������Ĵ
; � HWCP # 1 �
; ����������������������������Ĵ
; � HWCP # 2 �
; ����������������������������Ĵ
; � . �
; � . �
; � . �
; ����������������������������Ĵ
; � HWCP # 10 �
; ������������������������������
;
;
; N = Length of table in words. Or the number of HWCP's.
; HWCP # N : a hardware code page number converted to binary. The maximum
; number of pages allowed is 10.
;
;
;
; TABLE_5 :
; ���������
;
; ����������������������������Ŀ
; � N = Length of table. �
; ����������������������������Ĵ
; � Designate �
; ����������������������������Ĵ
; � Font �
; ������������������������������
;
; N = Lenght of table. 0 - nothing was specified
; 1 - Only a designate was specified.
; 2 - Designate and font were given. If the Desg field
; was left empty in the DEVICE command then the
; Designate field is filled with 0FFFFH.
; Designate, Font : Are the Desg. and Font binary numbers.
;
;------------------------------------------------------
;
;RESERVED MEMORY:
TABLE_1 DW ? ; Pointer at offsets.
TABLE_2 DW ? ; Pointer at device name.
TABLE_3 DW ? ; Pointer at id name.
TABLE_4 DW ? ; Pointer at hwcp.
TABLE_5 DW ? ; Pointer at desg and font.
;TABLE DB 290 DUP (?) ; Table of parsed parms. Max 4 devices.
DEVNUM DW ? ; Counter to number of devices.
RIGHT_FLAG DB ? ; Flag to indicate a left bracket.
DEV_ERR_FLG DB ? ; Device name error flag.
ID_ERR_FLG DB ? ; Id name error flag.
ERROR_FLAG DB ? ; Error flag_terminate program if set to 1.
COMMA_FLAG DB ? ; Indicate the number of commas incounterd.
HWCP_FLAG DB ? ; Flag for multiple hwcps.
DESG_FLAG DB ? ; Flag indicates desg. and font.
;Main part of program-links different sumbroutines together
PARSER PROC
PUSH AX ; ;;;;;;;;;;;;;;;;;;
PUSH BX ; ;
PUSH CX ; ; SAVE
PUSH DX ; ; ALL
PUSH DS ; ; REGISTERS.
PUSH ES ; ;
PUSH DI ; ;
PUSH SI ; ;;;;;;;;;;;;;;;;;;
LES SI,RH.RH0_BPBA ; Point at all after DEVICE=
; in the CONFIG.SYS file.
;Skip to end of file name, to the first DOS delimiter.
MOV DEVNUM,02H ; Number of devices counter.
GET_PARMS_A: CALL GET_CHAR ; Get command character in AL .
JZ EXIT_B ; No parms found.
CALL IS_DELIM ; If not a delimiter then.
JNE GET_PARMS_A ; Check next character.
MOV DI,OFFSET TABLE ; Get the table address.
ADD DI,02H ; Point at devices offsets.
MOV BX,DI ;
ADD BX,08H ; Point BX at parms offsets.
TAB2: CALL UPDATE_TABLE ; Update table pointers value.
CLR_DELIM: CALL GET_CHAR ; Get character into AL.
JZ EXIT_B ; No parms found.
CALL IS_ALPHA ; If alpha then assume.
JZ DEVICE ; A device name.
CALL IS_DELIM ; Is it a delimiter
JNE EXIT_A ; If not then error.
JMP CLR_DELIM ; Get next character.
DEVICE: MOV DEV_ERR_FLG,00H ; Set device error flag off;
CALL DEVICE_PARSE ; Call routine to parse device name.
CMP DEV_ERR_FLG,01H ; If error flag is
JZ EXIT_A ; set then exit.
CALL OFFSET_TABLE ; Update table.
ID_PARMS: CALL GET_CHAR ; Load a character in AL.
JZ EXIT_A ; Exit if end of line (error).
CMP AL,'(' ; If AL is a '(' then
JE ID ; Parse ID name.
CALL IS_ALPHA ; If an Alpha
JE ID ; Then parse ID name.
CALL IS_DIGIT ; If a digit
JE ID ; Then parse ID name.
CALL IS_DELIM ; If not a delimiter
JNE EXIT_A ; Then error, exit
JMP ID_PARMS ; Get another number
EXIT_B: CMP DEVNUM,02H ; If device number above 2 then
JA EXIT_C ; Exit parse.
JMP EXIT_A ; Else error, exit
ID: MOV ID_ERR_FLG,00H ; Set id error flag off.
CALL ID_PARSE ; Parse ID name.
CMP ID_ERR_FLG,01H ; Was error flag set, then
JE EXIT_A ; Print error message.
CALL OFFSET_TABLE ; Update table of offsets.
CALL HWCP_PARMS ; Get code page number
CMP ERROR_FLAG,01H ; If error, then
JE EXIT_A ; Print error message and exit
CMP ERROR_FLAG,02H ; If end of string
JE EXIT_H ; Then exit.
CALL DESG_PARMS ; Get designate number
CMP ERROR_FLAG,01H ; If error, then
JE EXIT_A ; Print error message and exit
JMP EXIT_H ; Then exit.
EXIT_A: MOV DI,OFFSET TABLE ; Load table offset
MOV DS:WORD PTR [DI],00H ; Set error to on.
STC ; Set carry flag
JMP EXIT_P ; Exit parse.
EXIT_H: MOV DI,OFFSET TABLE ; Load table offset.
ADD DS:WORD PTR [DI],01H ; Increment number of devices.
CMP DEVNUM,08H ; If 4 devices loaded
JE EXIT_C ; Then exit parse.
ADD DEVNUM,02H ; Increment the number of devices
ADD DI,DEVNUM ; Point at next devices offset.
MOV BX,TABLE_5 ; BX point at
ADD BX,06H ; end of previous table.
JMP TAB2 ; Get next device.
EXIT_C: CLC
EXIT_P: POP SI ; ;;;;;;;;;;;;;;;;;;
POP DI ; ;
POP ES ; ; RESTORE
POP DS ; ; ALL
POP DX ; ; REGISTERS.
POP CX ; ;
POP BX ; ;
POP AX ; ;;;;;;;;;;;;;;;;;;
RET
PARSER ENDP
;********************************************************
;** GET_CHAR : a routine to get next character pointed **
;** to by ES:SI into AL. **
;********************************************************
GET_CHAR PROC
MOV AL,ES:BYTE PTR [SI] ; Load character pointed to
CMP AL,09H ; by ES:[SI] in AL.
JE ZOFF ; If tab then O.K
CMP AL,20H ; Turn Z-flag on
JL TURN_Z_ON ; if character
ZOFF: INC SI ; is below
JMP GET_CHAR_X ; 20h.
; ( End of line
TURN_Z_ON: CMP AL,AL ; delimiters ).
GET_CHAR_X: RET
GET_CHAR ENDP
;********************************************************
;** IS_ALPHA : a routine to check the character in **
;** AL if it is an alpha character (a...z,A...Z). **
;** If character is lower case, convert to upper case. **
;********************************************************
IS_ALPHA PROC
PUSH AX ; Save value of AL
AND AL,0DFH ; Convert to upper case
CMP AL,'A' ; If <'A', then
JB IS_ALPHA_X ; NZ-flag is set, exit
CMP AL,'Z' ; If >'Z', then
JA IS_ALPHA_X ; NZ-flag is set, exit
CMP AL,AL ; Force Z-flag
POP DX ; Discard lower case.
JMP IA_X ; Exit.
IS_ALPHA_X: POP AX ; Restore value of AL
IA_X: RET
IS_ALPHA ENDP
;********************************************************
;** IS_DIGIT : a routine to check if the character in **
;** AL register is a digit (i.e. 1..9). **
;********************************************************
IS_DIGIT PROC
CMP AL,'0' ; If < '0' then
JB IS_NUM_X ; NZ-flag is set, exit
CMP AL,'9' ; If > '9' then
JA IS_NUM_X ; NZ-flag is set, exit
CMP AL,AL ; Set Z-flag to indecate digit
IS_NUM_X: RET
IS_DIGIT ENDP
;********************************************************
;** IS_DELIM : This routine check if the character in **
;** AL is a delimiter. ('+',' ',';',',','=',tab) **
;********************************************************
IS_DELIM PROC
CMP AL,' ' ; Test for space.
JE IS_DELIM_X ; Z-flag is set, exit
CMP AL,',' ; Test for comma.
JE IS_DELIM_X ; Z-flag is set, exit
CMP AL,';' ; Test for semicolon.
JE IS_DELIM_X ; Z-flag is set, exit
CMP AL,'=' ; Test for equal sign.
JE IS_DELIM_X ; Z-flag is set, exit
CMP AL,09h ; Test for TAB.
IS_DELIM_X: RET ; Exit
IS_DELIM ENDP
;********************************************************
;** DEVICE_PARSE : Parse the device driver name and **
;** store in table. Update offset. **
;********************************************************
DEVICE_PARSE PROC
MOV DI,TABLE_2
MOV DS:WORD PTR [DI],0008H ; Save dev name size.
ADD DI,02H ; Increment DI.
MOV CX,9 ; Set counter.
NEXT_C: CALL IS_ALPHA ; if Check then.
JZ SAVE_C ; Save it.
CALL IS_DIGIT ; if Digit then.
JZ SAVE_C ; Save it.
CMP AL,'-' ; If '-' then.
JZ SAVE_C ; Save it.
CALL IS_DELIM ; If a delimiter then.
JZ ADD_SPACE1 ; Pad with spaces.
CMP AL,':' ; If a colon
JE ADD_SPACE1 ; then end device parse
JMP ERR_DEV_PAR ; Else an error.
SAVE_C: DEC CX ; Decrement counter.
CMP CX,0 ; If counter zero then.
JE ERR_DEV_PAR ; Error.
MOV DS:BYTE PTR [DI],AL ; Save char in table.
INC DI ; Increment pointer.
CALL GET_CHAR ; Get another char.
JZ ERR_DEV_PAR
JMP NEXT_C ; Check char.
ERR_DEV_PAR: MOV DEV_ERR_FLG,01H ; Set error flag.
JMP DEV_PAR_X ; Exit.
ADD_SPACE1: DEC CX ; Check counter.
CMP CX,1
JL DEV_PAR_X ; Exit if already 8.
LL1: MOV DS:BYTE PTR [DI],' ' ; Pad name with spaces.
INC DI ; Increment pointer.
LOOP LL1 ; Loop again.
DEV_PAR_X: RET
DEVICE_PARSE ENDP
;********************************************************
;** ID_PARSE : Parse the id driver name and **
;** store in table. Update offset. **
;********************************************************
ID_PARSE PROC
MOV DI,TABLE_3
MOV DS:WORD PTR [DI],0008H ; Save dev name size.
ADD DI,02H ; Increment DI.
MOV RIGHT_FLAG,00H ; Clear flag.
MOV CX,9 ; Set counter.
NEXT_I: CALL IS_ALPHA ; If Check then.
JZ SAVE_I ; Save it.
CALL IS_DIGIT ; if Digit then.
JZ SAVE_I ; Save it.
CMP AL,'-' ; If '-' then.
JZ SAVE_I ; Save it.
CMP AL,'(' ; If '(' then.
JE RIG_BR_FLG ; Set flag.
CMP AL,')' ; If ')' then
JE BR_FLG_LEF ; Pad with spaces.
CALL IS_DELIM ; If a delimiter then.
JZ ADD_SPACE2 ; Pad with spaces.
JMP ERR_ID_PAR ; Else an error.
SAVE_I: DEC CX ; Decrement counter.
CMP CX,0 ; If counter zero then.
JLE ERR_ID_PAR ; Error.
MOV DS:BYTE PTR [DI],AL ; Save char in table.
INC DI ; Increment pointer.
CALL GET_CHAR ; Get another char.
JZ ADD_SPACE2 ; Exit routine.
JMP NEXT_I ; Check char.
ERR_ID_PAR: MOV ID_ERR_FLG,01H ; Set error falg on.
JMP ID_PAR_X ; Exit.
BR_FLG_LEF: CMP RIGHT_FLAG,01H ; If left bracket was
JNE ERR_ID_PAR ; found and no previous
JMP ADD_SPACE2 ; Bracket found, then error
RIG_BR_FLG: CMP RIGHT_FLAG,01H ; If more than one bracket
JE ERR_ID_PAR ; then error.
CMP CX,09 ; If '(' and already id
JB ERR_ID_PAR ; then error.
MOV RIGHT_FLAG,01H ; Set flag for.
CALL GET_CHAR ; Left brackets.
JZ ERR_ID_PAR ; If end of line,exit.
JMP NEXT_I ; Check character.
ADD_SPACE2: DEC CX ; Check counter.
CMP CX,1
JL ID_PAR_X ; Exit if already 8.
LL2: MOV DS:BYTE PTR [DI],' ' ; Pad name with spaces.
INC DI ; Increment pointer.
LOOP LL2 ; Loop again.
ID_PAR_X: RET
ID_PARSE ENDP
;********************************************************
;** HWCP_PARMS : Scane for the hardware code page, and **
;** parse it if found. Flag codes set to: **
;** ERROR_FLAG = 0 - parsing completed. No error. **
;** ERROR_FLAG = 1 - error found exit parse. **
;** ERROR_FLAG = 2 - end of line found, exit parse. **
;********************************************************
HWCP_PARMS PROC
MOV COMMA_FLAG,00H ; Set the comma flag off.
MOV ERROR_FLAG,00H ; Set the error flag off.
DEC SI ; Point at current char in Al.
CMP RIGHT_FLAG,01H ; If no left brackets then
JNE LEFT_BR ; Exit parse.
HWCP_1: CALL GET_CHAR ; Load character in AL.
JZ LEFT_BR ; Exit, if end of line.
CALL IS_DIGIT ; Check if digit, then
JE HP1 ; Parse hwcp parms.
CMP AL,',' ; If a comma
JE COMMA_1 ; Jump to comma_1
CMP AL,')' ; If a ')' then
JE RIGHT_BR ; end of current dev parms.
CMP AL,'(' ; If a '(' then
JE HWCP_2 ; There are multible hwcp.
CALL IS_DELIM ; Else, if not a delimiter
JNE EXIT_2 ; Then error, exit
JMP HWCP_1 ; Get another character.
LEFT_BR: CMP RIGHT_FLAG,01H ; If no left bracket
JE EXIT_2 ; Then error, exit
JMP RB1 ; Jump to rb1
COMMA_1: CMP COMMA_FLAG,01H ; If comma flag set
JE COM_2_HC ; Then exit hwcp parse.
MOV COMMA_FLAG,01H ; Else set comma flag.
JMP HWCP_1 ; Get another character.
HWCP_2: CMP RIGHT_FLAG,01H ; If left bracket not set
JNE EXIT_2 ; then error.
CALL MUL_HWCP ; else call multiple hwcp
ADD DI,02H ; routine. Increment DI
MOV TABLE_5,DI ; Desg. Table starts at end
CALL OFFSET_TABLE ; Update table of offsets.
JMP HP_X ; Exit.
HP1: JMP HWCP ; Jump too long.
COM_2_HC: MOV DI,TABLE_4 ; DI points at hwcp table
MOV DS:WORD PTR [DI],0000H ; Set number of pages to
MOV COMMA_FLAG,00H ; Zero and reset comma flag.
ADD DI,02H ; Increment DI.
MOV TABLE_5,DI ; Desg. Table starts at end
CALL OFFSET_TABLE ; Update table of offsets.
JMP HP_X ; of hwcp table. Exit.
RIGHT_BR: CMP RIGHT_FLAG,01H ; If left brackets not
JNE EXIT_2 ; Found then error.
RB1: MOV ERROR_FLAG,02H ; Set end of line flag.
MOV BX,TABLE_4 ; Point at hwcp table
ADD BX,02H ; Adjust pointer to desg
MOV TABLE_5,BX ; table, and save in table_5
MOV DI,TABLE_1 ; Point at table of offsets
ADD DI,08H ; Set at DESG offset
MOV DS:WORD PTR [DI],BX ; Update table.
JMP HP_X ; Exit
EXIT_2: MOV ERROR_FLAG,01H ; Set error flag.
JMP HP_X ; and exit.
HWCP: CMP RIGHT_FLAG,01H ; If left brackets not
JNE EXIT_2 ; Found then error.
CALL HWCP_PARSE ; Call parse one hwcp.
CMP ERROR_FLAG,01H ; If error flag set
JE HP_X ; Then exit, else
CALL OFFSET_TABLE ; Update table of offsets.
HP_X: RET
HWCP_PARMS ENDP
;********************************************************
;** HWCP_PARSE : Parse the hardware code page page **
;** number and change it from hex to binary. **
;********************************************************
HWCP_PARSE PROC
MOV DI,TABLE_4 ; Load address of hwcpages.
ADD DS:WORD PTR [DI],0001H ; Set count to 1
CALL GET_NUMBER ; Convert number to binary.
CMP ERROR_FLAG,01H ; If error then
JE HWCP_X ; Exit.
MOV DS:WORD PTR [DI+2],BX ; Else, save binary page number
ADD DI,04H ; Increment counter
MOV TABLE_5,DI ; Set pointer of designate num
HWCP_X: RET
HWCP_PARSE ENDP
;********************************************************
;** MUL_HWCP : Parse multiple hardware code pages **
;** and convert them from hex to binary numbers. **
;********************************************************
MUL_HWCP PROC
MOV DI,TABLE_4 ; Load offset of table_4
MOV BX,DI ; in DI and Bx.
MOV HWCP_FLAG,00H ; Set hwcp flag off.
MH1: CALL GET_CHAR ; Load character in AL.
JZ MH3 ; Exit if end of line.
CMP AL,')' ; If ')' then exit
JE MH2 ; end of parms.
CALL IS_DIGIT ; If a digit, then
JE MH4 ; Convert number to binary.
CALL IS_DELIM ; If not a delimiter
JNE MH3 ; then error, exit
JMP MH1 ; get another character.
MH2: CALL GET_CHAR ; Get next character
JMP MH_X ; and exit.
MH3: MOV ERROR_FLAG,01H ; Set error flag on.
JMP MH_X ; Exit.
MH4: ADD HWCP_FLAG,01H ; Set hwcp flag on (0 off)
ADD DI,02H ; Increment table pointer
PUSH BX ; Save Bx
CALL GET_NUMBER ; Convert number to binary.
MOV DS:WORD PTR [DI],BX ; Add number to table
POP BX ; Restore BX.
CMP ERROR_FLAG,01H ; If error then
JE MH_X ; Exit.
ADD DS:WORD PTR [BX],01H ; Increment hwcp count.
DEC SI ; Point at character in AL
JMP MH1 ; (delimeter or ')').
MH_X: RET
MUL_HWCP ENDP
;********************************************************
;** DESG_PARMS : Scane for the designate numbers, and **
;** parse it if found. Flag codes set to: **
;** ERROR_FLAG = 0 - parsing completed. No error. **
;** ERROR_FLAG = 1 - error found exit parse. **
;** ERROR_FLAG = 2 - end of line found, exit parse. **
;********************************************************
DESG_PARMS PROC
MOV DI,TABLE_1 ; Get offset of dev in DI
MOV BX,TABLE_5 ; & offset of desg. in BX.
ADD DI,08 ; Location of desg offset in table.
MOV DS:WORD PTR [DI],BX ; Update table.
MOV COMMA_FLAG,00H ; Set comma flag off.
cmp al,'('
je df
cmp al,')'
je right_br2
cmp al,','
jne desg_parm1
mov comma_flag,01h
DESG_PARM1: CALL GET_CHAR ; Get character in AL.
JZ EXIT_3 ; Error, if end of line
CALL IS_DIGIT ; If character is a digit
JE DESG ; Then convert to binary.
CMP AL,')' ; If a ')', then
JE RIGHT_BR2 ; end of parameters.
CMP AL,'(' ; If a '(' then
JE DF ; parse desg and font.
CMP AL,',' ; If a comma then
JE DP3 ; set flag.
CALL IS_DELIM ; If not a delimiter
JNE EXIT_3 ; then error.
JMP DESG_PARM1 ; Get another character.
RIGHT_BR2: CMP RIGHT_FLAG,01H ; IF no '(' encountered,
JNE EXIT_3 ; then error, exit
JMP DP_x ; Jump to DP1.
EXIT_3: MOV ERROR_FLAG,01H ; Set error flag on
JMP DP_X ; Exit.
DF: CMP RIGHT_FLAG,01H ; If no '(' encountered
JB EXIT_3 ; then error, exit
CALL DESG_FONT ; Parse desg and font.
JMP DP1 ; Jump to DP1.
DP2: CALL FIND_RIGHT_BR ; Check for ')'
JMP DP_X ; Exit.
DP3: CMP COMMA_FLAG,01H ; If comma flag set
JE DP2 ; then error
MOV COMMA_FLAG,01H ; Else set comma flag on.
JMP DESG_PARM1 ; Get another character.
DESG: MOV ERROR_FLAG,00H ; Set error flag off.
CALL DESG_PARSE ; Parse desg.
DP1: CMP ERROR_FLAG,01H ; If error flag on then
JE DP_X ; Exit,
CALL FIND_RIGHT_BR ; Else check for ')'
CALL OFFSET_TABLE ; Update table
DP_X: RET
DESG_PARMS ENDP
;********************************************************
;** DESG_FONT : Parse the designate and font numbers & **
;** change them from decimal to binary. **
;********************************************************
DESG_FONT PROC
MOV DI,TABLE_5 ; Get desg font table.
MOV COMMA_FLAG,00H ; Set comma flag off.
DF1: CALL GET_CHAR ; Load a character in AL.
JZ DF3 ; Error if end of line.
CMP AL,',' ; Check if a comma.
JE DF2 ; Set flag.
CALL IS_DIGIT ; If a digit, then
JE DF5 ; Convert number to binary.
CMP AL,')' ; If a ')' then
JE DF4 ; Exit.
CALL IS_DELIM ; If not a delimiter
JNE DF3 ; then error, exit
JMP DF1 ; Get another character.
DF2: CMP COMMA_FLAG,01H ; If comma flag on
JE DF3 ; then error, exit
MOV COMMA_FLAG,01H ; Set comma flag on
ADD DS:WORD PTR [DI],01H ; Increment desg counter.
MOV DS:WORD PTR [DI+2],0FFFFH ; Load ffffh for desg empty
JMP DF1 ; field.
DF3: MOV ERROR_FLAG,01H ; Set error flag on.
JMP DF_X ; Exit.
DF4: CMP DESG_FLAG,00H ; If desg flag off
JE DF3 ; then error, exit
JMP DF_X ; Else exit.
DF5: ADD DS:WORD PTR [DI],01H ; Increment desg font count.
CMP DESG_FLAG,01H ; If desg flag is on
JE DF6 ; then get font.
CMP COMMA_FLAG,01H ; if comma flag is on
JE DF6 ; then get font.
MOV DESG_FLAG,01H ; Set desg flag on
JMP DF7 ; Get desg number.
DF6: ADD DI,02H ; adjust pointer to font.
MOV DESG_FLAG,02H ; Set desg and font flag.
DF7: CALL GET_NUMBER ; Get a number & convert to
CMP ERROR_FLAG,01H ; binary.
JE DF_X ; If error flag set, Exit.
MOV DS:WORD PTR [DI+2],BX ; Store number in table.
CMP DESG_FLAG,02H ; If desg and font flag
JNE DF1 ; not set, then get char.
CALL FIND_RIGHT_BR ; Check for right bracket.
DF_X: RET
DESG_FONT ENDP
;********************************************************
;** DESG_PARSE : Parse the designate number and **
;** change it from decimal to binary. **
;********************************************************
DESG_PARSE PROC
MOV DI,TABLE_5 ; Load designate location
ADD DS:WORD PTR [DI],0001H ; Update table count.
CALL GET_NUMBER ; Get the ascii number and
CMP ERROR_FLAG,01H ; conver it to binary
JE DESG_X ; If error then exit
MOV DS:WORD PTR [DI+2],BX ; Else, save desg number
DESG_X: RET
DESG_PARSE ENDP
;********************************************************
;** GET_NUMBER : Convert the number pointed to by SI **
;** to a binary number and store it in BX **
;********************************************************
GET_NUMBER PROC
MOV CX,0AH ; Set multiplying factor
XOR BX,BX ; Clear DX
NEXT_NUM: SUB AL,30H ; Conver number to binary
CBW ; Clear AH
XCHG AX,BX ; Switch ax and bx to mul
MUL CX ; already converted number by 10.
JO ERR_NUM ; On over flow jump to error.
ADD BX,AX ; Add number to total.
JC ERR_NUM ; On over flow jump to error.
XOR AX,AX ; Clear AX (clear if al=0a).
CALL GET_CHAR ; Get next character
JZ GET_NUM_X ; Exit, if end of line.
CALL IS_DIGIT ; Call is digit.
JNZ GET_NUM_X ; Exit if not a number.
JMP NEXT_NUM ; Loop.
ERR_NUM: MOV ERROR_FLAG,01H ; Set error code to 1.
GET_NUM_X: RET
GET_NUMBER ENDP
;********************************************************
;** UPDATE_TABLE : This routine set up pointers to the **
;** different offsets of the different tables **
;********************************************************
UPDATE_TABLE PROC
MOV DS:WORD PTR [DI],BX ; Offset of offsets
MOV TABLE_1,BX ; Table_1 points at offsets
MOV DI,BX ;
ADD BX,0CH ;
MOV DS:WORD PTR [DI+2],BX ; Offset of DEVICE name.
MOV TABLE_2,BX ; Table_2 point at device name.
ADD BX,0AH ;
MOV DS:WORD PTR [DI+4],BX ; Offset of ID name.
MOV TABLE_3,BX ; Table_3 point at ID name.
ADD BX,0AH ;
MOV DS:WORD PTR [DI+6],BX ; Offset of HWCP pages.
MOV TABLE_4,BX ; Table_4 point at HWCP pages.
RET
UPDATE_TABLE ENDP
;********************************************************
;** OFFSET_TABLE : This routine set up pointers of **
;** tables number one and two. **
;********************************************************
OFFSET_TABLE PROC
MOV DI,TABLE_1 ; Increment the number
ADD DS:WORD PTR [DI],01H ; of parms foun. (ie. id,hwcp
RET ; and desg)
OFFSET_TABLE ENDP
;********************************************************
;** FIND_RIGHT_BR :This routine scane the line for a **
;** ')' if cannot find it turns error flag on **
;********************************************************
FIND_RIGHT_BR PROC
FBR1: CMP AL,')' ; If a right bracket
JE FBR_X ; then exit.
CMP AL,' ' ; If not a space
JNE FBR2 ; Then error.
CALL GET_CHAR ; Get a character
JZ FBR2 ; If end of line then exit.
JMP FBR1 ; Else get another character.
FBR2: MOV ERROR_FLAG,01H ; Set error flag on
FBR_X: MOV AL,20H ; Erase character from AL.
RET
FIND_RIGHT_BR ENDP
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
;; ++++++++++++++++++++++++
;; ++ INIT Command ++
;; ++++++++++++++++++++++++
;;
;;==== Command Code 0 - Initialization ======
;;
;; messages returned :
;;
;; msg_bad_syntax -- syntax error from parser, no driver installation
;; msg_no_init -- device cannot be initialised
;; msg_insuff_mem -- insufficient memory
;;
;; layout : the initialization is done in two stages :
;;
;; ++++++++++++++++++++++++
;; ++ INIT Stage 1 ++ to examine and extract the
;; ++++++++++++++++++++++++ parameters defined for the
;; device_id in DEVICE command,
;; according to the printer
;; description table for the
;; device_id.
;;
;; ++++++++++++++++++++++++
;; ++ INIT Stage 2 ++ to set the BUFfer for the LPTn
;; ++++++++++++++++++++++++ or PRN according to device_id's
;; parameters
;;
;;
;;
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
DEV_NUM dw ? ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Tables for the deivce_id parameters in the order of device_id in the
; PARSE table
; === the tables serves as the link between LPTn to be defined in the 2nd
; stage, and the device_id that is processed in the first stage.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; device ID indicators :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DID_MAX EQU 4 ;; device entris exepcted in PARSE
;; not more than 16. ;; table
;;
DID_STATUS DW 0 ;; status of parsing device id
;; = 0 : all Device-ID bad
;; -- see DID_BIT
;;
DID_MATCH DW 0 ;; this DID has device_name matched
;;
DID_FAIL DW 0 ;; to fail the good DID_STATUS and
;; the matched name. (due to
;; inconsistency among the same LPTn
;; or between PRN and LPT1.)
;;
;; (DID_STATUS) AND (DID_MATCH) XOR (DID_FAIL) determines the success of DID
;; initialization
;;
DID_ONE EQU 00001H ;; first device-ID
DID_TWO EQU 00002H ;; second "
DID_THREE EQU 00004H ;; third "
DID_FOUR EQU 00008H ;; fourth "
;;maximun number of device_id = 16 ;;
;;
DID_BIT LABEL WORD ;;
DW DID_ONE ;;
DW DID_TWO ;;
DW DID_THREE ;;
DW DID_FOUR ;;
;;maximun number of device_id = 16 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; device paramters according to the
;; device_id defined in DEVICE and the
;; parameters defined for the device_id
;; in the printer description table.
;;
HRMAX LABEL word ;; number of hwcp+cart slots supported
DW 0 ;; did = 1
DW 0 ;; did = 2
DW 0 ;; did = 3
DW 0 ;; did = 4
;upto max DID_MAX ;;
;;
CTMAX LABEL word ;; number of cart slots supported
DW 0 ;; did = 1
DW 0 ;; did = 2
DW 0 ;; did = 3
DW 0 ;; did = 4
;upto max DID_MAX ;;
;;
RMMAX LABEL word ;; number of ram-slots supported
DW 0 ;; did = 1
DW 0 ;; did = 2
DW 0 ;; did = 3
DW 0 ;; did = 4
;upto max DID_MAX ;;
;;
RBUMAX LABEL word ;; number of ram-designate slots
DW 0 ;; did = 1
DW 0 ;; did = 2
DW 0 ;; did = 3
DW 0 ;; did = 4
;upto max DID_MAX ;;
;;
DESCO LABEL word ;; offset to the description table
;; where the device_id is defined.
DW -1 ;; did = 1
DW -1 ;; did = 2
DW -1 ;; did = 3
DW -1 ;; did = 4
;upto max DID_MAX ;;
;;
FSIZE LABEL word ;; font size of the device
DW 0 ;; did = 1
DW 0 ;; did = 2
DW 0 ;; did = 3
DW 0 ;; did = 4
;upto max DID_MAX ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hard/RAM slots table in the order of DEVICE parameters
;
; number of entries in all HARD_SLn is determined by the max. {HSLOTS}, and
; number of entries in all RAM_SLn is determined by the max. {RSLOTS}
;
; -- they are initialized according to the device_id defined in the DEVICE.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
HARD_SLA LABEL word ;; index in the order of device in
DW OFFSET (HARD_SL1) ;; the PARSE-talbes
DW OFFSET (HARD_SL2) ;;
DW OFFSET (HARD_SL3) ;;
DW OFFSET (HARD_SL4) ;;
; up to DID_MAX ;;
;;
RAM_SLA LABEL word ;;
DW OFFSET (RAM_SL1) ;;
DW OFFSET (RAM_SL2) ;;
DW OFFSET (RAM_SL3) ;;
DW OFFSET (RAM_SL4) ;;
; up to DID_MAX ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; ++++++++++++++++++++++++
;; ++ INIT Command ++
;; ++++++++++++++++++++++++
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
INIT PROC NEAR ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; parse the initialization parameters in DEVICE command
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
CMP BUF.BFLAG,BF_PRN ;; since PRN is the FIRST device header
JNE NOT_PRN ;;
;;
;;
MOV AX,OFFSET CODE_END ;; defined only once for each DEVICE
XOR CX,CX ;;
MOV CL,4 ;;
SHR AX,CL ;;
PUSH CS ;;
POP CX ;;
ADD AX,CX ;;
INC AX ;; leave 16 bytes,room for resident_end
MOV RESIDENT_END,AX ;;
;;
CALL PARSER ;; call only once, for PRM
;;
JMP PROCESS_TABLE ;;
;;
NOT_PRN : ;;
CMP DEV_NUM,1 ;;
;;
JNB PROCESS_TABLE ;;
;;
JMP SYNTAX_ERROR ;;
;;
;;
;;
;;
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
;; ++++++++++++++++++++++++
;; ++ INIT Stage 1 ++
;; ++++++++++++++++++++++++
;;
;; INIT - FIRST STAGE :
;;
;; == test and extract if the parameters on device-id is valid
;; == determine the DID_STATUS according to the validity of the parameters
;; == procedure(s) called -- DID_EXTRACT
;;
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
PROCESS_TABLE : ;;
;;
PUSH CS ;;
POP ES ;; PSE points to Device offsets
MOV DI,OFFSET(table) ;; ES:[DI]
MOV DX,PSE.PAR_DEV_NUM ;;
MOV DEV_NUM,DX ;;
;;
CMP DEV_NUM,0 ;;
JNZ NO_SYNTAX_ERR ;;
;;
XOR AX,AX ;;
MOV AH,09H ;;
MOV DX,OFFSET MSG_BAD_SYNTAX;;
INT 21H ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SYNTAX_ERROR : ;; set the request header status
;; according to the STATE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV AX, RESIDENT_END ;;
PUSH CS ;;
POP CX ;; CX=CS
SUB AX,Cx ;; additional segment required.
CS_LOOP1: ;;
CMP AX,1000H ;;
JB CS_LPEND1 ;;
ADD CX,1000H ;;
SUB AX,1000H ;;
JMP CS_LOOP1 ;;
;;
CS_LPEND1: ;;
SHL AX,1 ;;
SHL AX,1 ;;
SHL AX,1 ;;
SHL AX,1 ;;
;;
LES DI,dword ptr buf.rh_ptro ;; get Request Header address
; MOV RH.RH0_ENDO,AX ;;
MOV RH.RH0_ENDO,0 ;;
MOV RH.RH0_ENDS,CX ;;
MOV RH.RHC_STA,stat_cmderr ;; set status in request header
;;
JMP INIT_RETurn ;;
;;
;;
NO_SYNTAX_ERR : ;;
;;
CMP DX,DID_MAX ;;
JNA NEXT_DID ;;
;;
MOV INIT_CHK,0001H ;; ERROR 0001
JMP BAD_DID ;; more than supported no. of device
;;
NEXT_DID: ;;
PUSH DI ;; pointer to PAR_OT (table 1)
AND DX,DX ;;
JNZ SCAN_DESC ;;
JMP END_DID ;; DI = offset to the 1st PARSE table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SCAN_DESC: ;;
MOV DI,PSE.PAR_OFF ;; points to the nth device
;;
;; find the description for the
;;device-id
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV CX,PRINTER_DESC_NUM ;;
MOV SI, OFFSET(PRINTER_DESC_TBL); offset to the description table
PUSH CS ;;
POP DS ;;
; $SEARCH ;;
$$DO1:
PUSH CX ;; save device count
PUSH SI ;; pointer to printer-descn's offset
MOV SI,CS:WORD PTR[SI] ;;
AND CX,CX ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $LEAVE Z ;; LEAVE if no more device description
JZ $$EN1
PUSH DI ;; save offset to PAR_DEVOT
MOV DI,PSE.PAR_DIDO ;;
MOV CX,PSE.PAR_DIDL ;; length of parsed device name
LEA DI,PSE.PAR_DID ;; pointer to parse device name
;;
PUSH SI ;;
LEA SI,[SI].TYPEID ;; offset to name of device-id
REPE CMPSB ;;
POP SI ;;
POP DI ;; get back offset to PAR_DEVOT
;;;;;;;;;;;;;;;;;;;;;;;;
; $EXITIF Z ;; EXIT if name matched
JNZ $$IF1
;;
CALL DID_EXTRACT ;; get the parameters
;;
POP SI ;; balance push-pop
POP CX ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ORELSE ;; try next description :
JMP SHORT $$SR1
$$IF1:
;;
POP SI ;; of printer_descn offset table
INC SI ;;
INC SI ;; next offset to PRINTER_DESCn
;;
POP CX ;; one description less
DEC CX ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ENDLOOP ;; DEVICE-ID not defined in
JMP SHORT $$DO1
$$EN1:
;; printer_desc;
;;
MOV AX,INIT_CHK ;;
AND AX,AX ;;
JNZ UNCHANGED ;;
MOV INIT_CHK,0004H ;; ERROR 0004
UNCHANGED: ;;
POP SI ;; balance push-pop
POP CX ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ENDSRCH ;; End of scanning printer_desc
$$SR1:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
POP DI ;;
INC DI ;;
INC DI ;; points to next device in PART_OT
DEC DX ;;
;;
JMP NEXT_DID ;;
;;
END_DID : ;;
POP DI ;;
BAD_DID : ;;
;;
MOV AX,DID_STATUS ;;
AND AX,AX ;;
JNZ DEF_BUFFER ;;
;;
JMP END_LPT ;;
;;
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
;; ++++++++++++++++++++++++
;; ++ INIT Stage 2 ++
;; ++++++++++++++++++++++++
;;
;; INIT -- SECOND STAGE :
;;
;; == match the device_name extracted in stage 1 with the name of PRN or
;; LPTn
;;
;; == if the PRN/LPTn has never been defined before, then set up the BUF
;; for the PRN/LPTn if the DID_STATUS is good; otherwise message will
;; be generated indicating it cannot be initilized.
;;
;; == if there is PRN, LPT1 is also setup, and vice vera. IF both PRN and
;; LPT1 are on the DEVICE command, or there are multiple entries for
;; the same LPTn, the consistency is checked. It they are inconsistent
;; the associated LPTn or PRN is forced to fail by : DID_FAIL.
;;
;; == if the device_name on the DEVICE command is not one of the supported
;; PRN or LPTn, then DID_MATCH bit will not be set. An error message
;; will be generated for the device_name indicating it cannot be
;; initialized.
;;
;; == procedure(s) called : CHK_DID .. check DID parameters for device
;; whose name matched.
;; DEV_CHECK .. if device-name duplicated, or
;; there are both PRN/LPT1 : check
;; for consistent parameters.
;;
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DEF_BUFFER : ;;
PUSH CS ;;
POP ES ;; PSE points to Device offsets
MOV DI,OFFSET(table) ;; ES:[DI]
xor cx,cx ;; device order in parse table
;SEARCH ;;
$$DO7:
PUSH DI ;; pointer to PAR_OT
PUSH CX ;; save device count
MOV DI,PSE.PAR_OFF ;; " " PAR_DEVOT
cmp cx,dev_num ;;
;;
;LEAVE NB ;; LEAVE if no more device entry
jb MORE_DEVICE ;;
JMP $$EN7
MORE_DEVICE : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; more parsed_device to be checked
PUSH DI ;; save offset to PAR_DEVOT
MOV DI,PSE.PAR_DNMO ;;
MOV CX,PSE.PAR_DNML ;; length of parsed device name
LEA DI,PSE.PAR_DNM ;; pointer to parse device name
;;
LDS SI,DWORD PTR BUF.DEV_HDRO ; get the offset to device-n header
LEA SI,HP.DH_NAME ;; " offset to name of device-n
REPE CMPSB ;;
POP DI ;; get back offset to PAR_DEVOT
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
;EXITIF Z ;; EXIT if name matched
JZ NAME_MATCHED ;;
;;
JMP MORE_PARSED_DEVICE ;;
;;
NAME_MATCHED : ;;
;;
POP CX ;; the DID order
PUSH BX ;;
MOV BX,CX ;;
ADD BX,BX ;;
MOV AX,DID_BIT[BX] ;;
OR DID_MATCH,AX ;; this DID matched
POP BX ;;
PUSH CX ;;
;;
LEA SI,BUF.PAR_EXTRACTO ;; was the LPT1/PRN defined before ?
MOV AX,CS:[SI].PAR_DNMO ;;
CMP AX,0FFFFH ;;
;;
JNE DEV_COMPARE ;; DI = PAR_DEVOT
;;-----------------------------------
;;
;; no device previousely defined
MOV AX,PSE.PAR_DNMO ;;
MOV CS:[SI].PAR_DNMO,AX ;; define device parameters for LPTn
;;
MOV AX,PSE.PAR_DIDO ;;
MOV CS:[SI].PAR_DIDO,AX ;;
;;
MOV AX,PSE.PAR_HWCPO ;;
MOV CS:[SI].PAR_HWCPO,AX ;;
;;
MOV AX,PSE.PAR_DESGO ;;
MOV CS:[SI].PAR_DESGO,AX ;;
;;
MOV AX,PSE.PAR_PARMO ;;
MOV CS:[SI].PAR_PARMO,AX ;;
;;
;;---------------------------------
CALL CHK_DID ;; define the STATE according to
;; DID_STATUS
JMP MORE_PARSED_DEVICE ;;
;;
DEV_COMPARE : ;;-------------------------------
;; e.g. LPT1 and PRN shares one BUF.
;; or duplicated device name
CALL DEV_CHECK ;;
;;
CMP BUF.STATE,CPSW ;;
JNE DEV_COMPARE_FAIL ;;
;;
JMP MORE_PARSED_DEVICE ;;
;;
DEV_COMPARE_FAIL : ;;
;;
POP CX ;;
POP DI ;; balance push-pop
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;$ORELSE ;;
JMP END_LPT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MORE_PARSED_DEVICE : ;; name does not match
;;
POP CX ;;
INC CX ;;
POP DI ;;
INC DI ;;
INC DI ;; points to next device in PART_OT
;;
jmp $$DO7 ;;
;$ENDLOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$$EN7: ;; no device found for LPTn
;;
POP CX ;;
POP DI ;; balance push-pop
;;
CMP BUF.STATE,CPSW ;;
JE END_LPT ;; for LPT1/PRN pair
;;
MOV BUF.STATE,NORMAL ;; no device defined for the LPTn
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; End of defining LPTn Buffer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;$ENDSRCH ;;
END_LPT : ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set the request header status
;; according to the STATE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV AX, RESIDENT_END ;;
PUSH CS ;;
POP CX ;; CX=CS
SUB AX,Cx ;; additional segment required.
CS_LOOP2: ;;
CMP AX,1000H ;;
JB CS_LPEND2 ;;
ADD CX,1000H ;;
SUB AX,1000H ;;
JMP CS_LOOP2 ;;
;;
CS_LPEND2: ;;
SHL AX,1 ;;
SHL AX,1 ;;
SHL AX,1 ;;
SHL AX,1 ;;
;;
LES DI,dword ptr buf.rh_ptro ;; get Request Header address
MOV RH.RH0_ENDO,AX ;;
MOV RH.RH0_ENDS,CX ;;
XOR AX,AX ;; clear error code to be returned
MOV CX,BUF.STATE ;;
CMP CX,CPSW ;;
JE MATCH_GOOD ;;
MOV AX,STAT_CMDERR ;;
;;
MATCH_GOOD : ;;
MOV RH.RHC_STA,AX ;; set status in request header
;;
BUF_END : ;;
;;
CMP BUF.BFLAG,BF_LPT1 ;;
JNE BUF_MESSAGES ;;
;;
CMP BUF.STATE,CPSW ;;
JNE BUF_MESSAGES ;;
;; set PRN to the same setting as LPT1
PUSH BX ;;
;;
LEA SI,BUF.RNORMO ;;
LEA CX,BUF.BUFEND ;;
SUB CX,SI ;;
MOV BX,BUF.PRN_BUFO ;; where PRN buffer is
LEA DI,BUF.RNORMO ;;
PUSH CS ;;
POP ES ;;
PUSH CS ;;
POP DS ;;
REP MOVSB ;;
;;
POP BX ;;
;;
BUF_MESSAGES : ;;
CMP BUF.BFLAG,BF_LPT3 ;; generate error message is this is
je last_round ;; the last LPTn
Jmp INIT_RETURN ;;
;; ERROR messages will be generated
;; at the end of initialization of all
;; the LPT devices
last_round : ;;
MOV AX,RESIDENT_END ;;
ADD AX,STACK_SIZE ;;
MOV RESIDENT_END,AX ;;
PUSH CS ;;
POP CX ;; CX=CS
SUB AX,Cx ;; additional segment required.
CS_LOOP3: ;;
CMP AX,1000H ;;
JB CS_LPEND3 ;;
ADD CX,1000H ;;
SUB AX,1000H ;;
JMP CS_LOOP3 ;;
;;
CS_LPENd3: ;;
SHL AX,1 ;;
SHL AX,1 ;;
SHL AX,1 ;;
SHL AX,1 ;;
;;
MOV RH.RH0_ENDO,AX ;; STACK !!!!!
MOV STACK_ALLOCATED,0 ;; from now on, internal stack is used
;;
MOV AX,DID_STATUS ;; what is the DID combination ?
AND AX,DID_MATCH ;;
XOR AX,DID_FAIL ;;
;;
AND AX,AX ;;
JNZ CODE_STAYED ;;
; MOV RH.RH0_ENDO,0 ;; none of the devices are good
;;
;;
CODE_STAYED : ;;
MOV DI,OFFSET TABLE ;;
push CS ;;
POP ES ;;
;;
XOR CX,CX ;;
MSG_LOOP : ;;
CMP CX,DEV_NUM ;;
JNB INIT_RETURN ;;
SHR AX,1 ;;
JC MSG_NEXT ;;
;; this device in parse table is bad
PUSH DI ;;
PUSH CX ;;
PUSH AX ;;
;;
MOV DI,PSE.PAR_OFF ;;
MOV SI,PSE.PAR_DNMO ;;
;;
PUSH CS ;;
POP ES ;;
PUSH CS ;;
POP DS ;;
;;
MOV CX,8 ;;
LEA SI,[SI].PAR_DNM ;;
;;
MOV DI,SI ;;
ADD DI,7 ;; skip backward the blanks
MOV AL,20H ;;
STD ;;
REPE SCASB ;;
CLD ;;
;;
MOV DI, OFFSET MSG_NO_INIT_P;;
MOV DX,DI ;; for INT 21H
XOR AX,AX ;;
MOV AH,09H ;;
INT 21H ;;
;;
;;
MOV DI, OFFSET MSG_NO_INIT ;;
MOV DX,DI ;; for INT 21H
;;
INC CX ;;
;;
PUSH CX ;; remaining name that is non blank
MOV AX,CX ;;
MOV CX,8 ;;
SUB CX,AX ;;
ADD DI,CX ;;
MOV DX,DI ;;
POP CX ;;
REP MOVSB ;;
;;
;;
XOR AX,AX ;;
MOV AH,09H ;;
INT 21H ;;
;;
POP AX ;;
POP CX ;;
POP DI ;;
;;
MSG_NEXT : ;;
INC CX ;;
INC DI ;;
INC DI ;;
JMP MSG_LOOP ;;
;;
;;
INIT_RETURN : ;;
;;
;;
RET ;;
;;
INIT ENDP ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Call by INIT to extract parameters for the deivce_id
;;
;; on rntry :
;; ES:[DI] PARSE Table 2, offsets of all parameters
;; DS:[SI] Printer Description table whose TYPEID matched
;; DX "inverse" order of devices in the PARSE tables
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
DID_EXTRACT PROC ;;
;;
PUSH DX ;;
;;-----------------------------
;; define the DID_parameters
PUSH BX ;;
;;
MOV BX,DEV_NUM ;;
SUB BX,DX ;; order in the Parse table
add bx,bx ;; double to index [bx]
MOV DX,BX ;;
;;
MOV AX,DS:[SI].FONTSZ ;;
MOV FSIZE[BX],AX ;; size of font buffer to be created
;;
MOV AX,DS:[SI].HSLOTS ;;
CMP AX,HARDSL_MAX ;;
JNA LESS_HARDSL ;;
MOV INIT_CHK, 0010H ;; ERROR 0010H
POP BX ;;
JMP END_MATCH_BAD ;;
LESS_HARDSL : ;;
CMP AX,DS:[SI].HWCPMIN ;;
JNB VALID_HARDSL ;;
MOV INIT_CHK, 0012H ;; ERROR 0012H
POP BX ;;
JMP END_MATCH_BAD ;;
VALID_HARDSL : ;;
MOV HRMAX[BX],AX ;;
MOV CTMAX[BX],AX ;; will be reduced by the no. of hwcp
;;
MOV AX,DS:[SI].RSLOTS ;;
CMP AX,RAMSL_MAX ;;
JNA LESS_RAMSL ;;
MOV INIT_CHK, 0011H ;; ERROR 0011H
POP BX ;;
JMP END_MATCH_BAD ;;
LESS_RAMSL : ;;
MOV RMMAX[BX],AX ;; see also designate
;;
MOV DESCO[BX],SI ;;
;;
POP BX ;;
;;----------------------------------
;;
PUSH CX ;;
;;
HWCPgt: PUSH DI ;; get the hwcp
;;
MOV DI,PSE.PAR_HWCPO ;;
MOV CX,PSE.PAR_HWCPL ;; no. of hwcp
AND CX,CX ;;
JNZ chk_hwcp ;;
push bx ;;
mov bx,dx ;;
MOV HRMAX[BX],CX ;;
MOV CX,DS:[SI].HWCPMIN ;;
SUB CTMAX[BX],CX ;; what is left becomes cartridge slot
pop bx ;;
JMP DESIGN ;;
;; hwcp to be defined
chk_hwcp: MOV AX,DS:[SI].HSLOTS ;; defined in printer_desc
CMP CX,AX ;;
JA BAD_MATCH2 ;;
CMP CX,HARDSL_MAX ;;
JNA HWCP_GOOD ;; jump if system error
MOV INIT_CHK,0003H ;; ERROR 0003
JMP END_MATCH ;;
BAD_MATCH2: ;;
MOV INIT_CHK,0002H ;; ERROR 0002
JMP END_MATCH ;;
;;
HWCP_GOOD: ;; there are sufficient hard-slot for
;; HWCP
PUSH SI ;; printer description table of TYPEID
PUSH BX ;;
;;
MOV BX,DX ;;
MOV AX,CTMAX[BX] ;;
;;
PUSH CX ;; calculate what is left for cart_slot
CMP CX,DS:[SI].HWCPMIN ;;
JNB MORE_THAN_HWCPMIN ;;
MOV CX,DS:[SI].HWCPMIN ;;
MORE_THAN_HWCPMIN : ;;
SUB AX,CX ;;
POP CX ;;
mov HRMAX[BX],CX ;;
;;
MOV CTMAX[BX],AX ;; no of cart-slot for designate
MOV SI,HARD_SLA[BX] ;; get the corresponding hard-slots
;;
POP BX ;;
;;
push bx ;;
push dx ;;
mov bx,si ;;
mov dx,cx ;;
mov reserved1,dx ;; IF THERE IS ANY REPETITIVE HWCP
mov reserved2,bx ;; IF THERE IS ANY REPETITIVE HWCP
;;
FILL_HWCP: ;;
AND CX,CX ;;
JZ DESIGN_P ;;
INC DI ;; next code page in PARSE table
INC DI ;;
MOV AX,ES:[DI] ;; get code page value
;;
;; IF THERE IS ANY REPETITIVE HWCP
push dx ;;
push bx ;;
hwcp_norep : ;;
cmp ax,cs:[bx].slt_cp ;;
jne hwcp_repnext ;;
pop bx ;;
pop dx ;;
pop dx ;;
pop bx ;;
pop si ;;
jmp end_match ;;
;;
hwcp_repnext: ;;
inc bx ;;
inc bx ;;
inc bx ;;
inc bx ;;
dec dx ;;
jnz hwcp_norep ;;
pop bx ;;
pop dx ;;
;;
MOV CS:[SI].SLT_CP,AX ;;
MOV AX,CS:[SI].SLT_AT ;; get the attributes
OR AX,AT_OCC ;; occupied
OR AX,AT_HWCP ;; hwcp slot
MOV CS:[SI].SLT_AT,AX ;;
INC SI ;;
INC SI ;; next slot
INC SI ;; next slot
INC SI ;; next slot
DEC CX ;;
JMP FILL_HWCP ;;
DESIGN_P: ;;
pop dx ;;
pop bx ;;
POP SI ;;
;;---------------------
DESIGN: POP DI ;; get the designate no.
PUSH DI ;;
;;
MOV DI,PSE.PAR_DESGO ;;
MOV AX,PSE.PAR_DESGL ;;
CMP AX,1 ;;
JA END_MATCH ;; there should have no font entry
AND AX,AX ;;
JZ DEF_RBUFMAX ;;
;;
MOV AX,PSE.PAR_DESG ;;
AND AX,AX ;;
JZ DEF_RBUFMAX ;;
;;
CMP CS:[SI].CLASS,1 ;;
JNE DESIG_NOt_CLASS1 ;;
;;
PUSH BX ;; if there is any cartridge slot ?
PUSH AX ;;
MOV BX,DX ;;
MOV AX,ctmax[BX] ;;
AND AX,AX ;;
POP AX ;;
POP BX ;;
JZ END_MATCH ;; fail, as there is no physical RAM.
;;
CMP AX,HARDSL_MAX ;; is the designate more than max ?
JA END_MATCH ;;
;;
;;
JMP DEF_RBUFMAX ;;
;;
;;
;;
DESIG_NOT_CLASS1 : ;;
PUSH BX ;; if there is any physical RAM slot ?
PUSH AX ;;
MOV BX,DX ;;
MOV AX,RMMAX[BX] ;;
AND AX,AX ;;
POP AX ;;
POP BX ;;
JZ END_MATCH ;; fail, as there is no physical RAM.
;;
;;
CMP AX,RAMSL_MAX ;; is the designate more than max ?
JA END_MATCH ;;
;;
DEF_RBUFMAX : ;;
PUSH BX ;;
MOV BX,DX ;;
MOV RBUMAX[BX],AX ;;
POP BX ;;
;;
;;
PARAM : ;;
;PARM: POP DI ;;
; PUSH DI ;;
;; MOV DI,PSE.PAR_PARMO ;;
;;
;,--------------------------
;; GOOD device_id parameters
shr dx,1 ;;
MOV AX,DID_ONE ;;
MOV CX,DX ;;
AND CX,CX ;;
JZ NO_SHL ;;
SHL AX,CL ;;
NO_SHL: OR DID_STATUS,AX ;; is defined
;;-------------------------
END_MATCH: POP DI ;; end of extract
POP CX ;;
END_MATCH_BAD : ;;
POP DX ;;
;;
RET ;;
;;
DID_EXTRACT ENDP ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Called by INIT to define the STATE and BUF for the LPTn according to
;; the DID_STATUS. Create font buffer if requested through the "desi*nate"
;;
;; at entry : CX = device order in parse table
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CHK_DID PROC ;;
;;
push cx ;;
push di ;;
push dx ;;
;;
MOV AX,DID_STATUS ;;
;;
PUSH CX ;; order 0 to m
POP DI ;;
ADD DI,DI ;; indexing : [DI]
;;
INC CX ;;
SHR AX,CL ;; is the device parameter valid ?
;;
JC DEFINE_BUFFER ;;
JMP LPT_FAIL ;;--------------------------
;;
DEFINE_BUFFER : ;;
;; good device parameters as determined
MOV AX,DESCO[DI] ;;
MOV BUF.PDESCO,AX ;;
;;
PUSH DI ;;
MOV DI,AX ;;
MOV AX,CS:[DI].CLASS ;;
MOV BUF.PCLASS,AX ;;
POP DI ;;
;;
MOV AX,HARD_SLA[DI] ;; in the DID_EXTRACT
MOV BUF.HARDSO,AX ;;
;;
MOV AX,RAM_SLA[DI] ;;
MOV BUF.RAMSO,AX ;;
;;
MOV AX,HRMAX[DI] ;;
MOV BUF.HARDMX,AX ;;
;;
MOV AX,CTMAX[DI] ;;
MOV BUF.HCARMX,AX ;;
;;
ADD AX,HRMAX[DI] ;; defore "designate"
MOV BUF.HSLMX,AX ;;
;;
;;
MOV AX,RMMAX[DI] ;;
MOV BUF.RAMMX,AX ;;
;;
XOR AX,AX ;;
PUSH CX ;; calculate the max. length of control
MOV CX,2 ;; sequence that is allowed for the
CMP BUF.PCLASS,1 ;; room reserved for physical slots.
JNE CTL_LOOP ;;
MOV CX,1 ;; class 1 printer has one control seq.
CTL_LOOP : ;;
ADD AX,CTL_MAX ;;
DEC AX ;; leave one byte for the length
DEC CX ;;
JNZ CTL_LOOP ;;
MOV BUF.FSELMAX,AX ;;
POP CX ;;
;;
MOV AX,FSIZE[DI] ;;
MOV BUF.FTSZPA,AX ;; FTSIZE in paragraph
;;
PUSH AX ;;
;;
MOV DX,4 ;;
FT_PARA: ;;
ADD AX,AX ;;
DEC DX ;;
JNZ FT_PARA ;; font size
MOV BUF.FTSIZE,AX ;; font size in bytes (used with.RBUFMX)
;;
POP DX ;; FTSIZE in paragraph
;;
MOV CX,RBUMAX[DI] ;; create font buffer per .RBUFMX and
MOV BUF.RBUFMX,CX ;; assume sufficient memory for all the
;; "designate request"
PUSH CX ;;
;;
CMP BUF.PCLASS,1 ;; always create font buffer for class1
JNE CLASS_NOT_1 ;;
;;
AND CX,CX ;;
JZ CLASS1_NOCX ;;
ADD CX,BUF.HARDMX ;;
MOV BUF.HSLMX,CX ;;
JMP CLASS_NOT_1 ;;
;;
CLASS1_NOCX: ;;
MOV CX,BUF.HSLMX ;;
;;
CLASS_NOT_1 : ;;
AND CX,CX ;;
JZ MULTIPLE_DONE ;;
MOV AX,RESIDENT_END ;;
MULTIPLE_FT : ;;
ADD AX,DX ;; allocate the font buffers at the end
DEC CX ;; of the resident codes
JNZ MULTIPLE_FT ;;
;;
;;
MOV CX,RESIDENT_END ;;
MOV BUF.FTSTART,CX ;;
MOV RESIDENT_END,AX ;;
;;
;;
MULTIPLE_DONE : ;;
POP CX ;; designate requested
;;
CMP BUF.PCLASS,1 ;;
JNE DEF_RBUF ;;
;; CLASS 1
CMP BUF.HARDMX,0 ;;
JE DEFBUF_DONE ;;
;;
PUSH CX ;; STACKS...
PUSH SI ;;
PUSH DS ;;
PUSH ES ;;
PUSH DI ;;
PUSH DX ;;
;;
MOV DX,BUF.HARDMX ;;
PUSH DX ;; STACK +1 -- # of HWCP
;;
PUSH CS ;;
POP DS ;;
MOV BUF.RBUFMX,0 ;;
MOV SI,BUF.PDESCO ;;
MOV SI,CS:[SI].SELH_O ;;
XOR CX,CX ;;
MOV CL,CS:BYTE PTR [SI] ;;
INC CX ;; including the length byte
;;
MOV DI,BUF.FTSTART ;; control template
DEF_FTBUF: ;; fill the font buffer with the
PUSH DI ;;
POP ES ;;
XOR DI,DI ;;
;;
PUSH CX ;;
PUSH SI ;;
REP MOVSB ;;
POP SI ;;
POP CX ;;
;;
PUSH ES ;;
POP DI ;;
ADD DI,BUF.FTszpa ;;
DEC DX ;;
JNZ DEF_FTBUF ;;
;;
POP DX ;; STACK -1
;;
MOV SI,BUF.HARDSO ;;
MOV DI,BUF.FTSTART ;; define the HWCP values
DEF_FThwcp : ;;
PUSH DI ;;
POP ES ;;
MOV DI,CTL5202_OFFS ;; offset to the HWCP words
;;
MOV AX,CS:[SI].SLT_CP ;;
MOV ES:WORD PTR [DI],AX ;;
;;
INC SI ;;
INC SI ;;
INC SI ;;
INC SI ;;
;;
PUSH ES ;;
POP DI ;;
ADD DI,BUF.FTSZPA ;;
DEC DX ;;
JNZ DEF_FThwcp ;;
;;
POP DX ;;
POP DI ;;
POP ES ;;
POP DS ;;
POP SI ;;
POP CX ;;
;;
JMP DEFBUF_DONE ;;
;;
;;
DEF_RBUF : ;;
MOV BUF.RSLMX,CX ;; the no. of ram slots supported
CMP CX,RMMAX[DI] ;;
JNB DEFBUF_DONE ;;
MOV AX,RMMAX[DI] ;;
MOV BUF.RSLMX,AX ;; the max. of .RAMMX and .RBUFMX
;;
DEFBUF_DONE : ;;
MOV BUF.STATE,CPSW ;; the LPTn is CPSW ----- STATE
;;
CMP BUF.BFLAG,BF_PRN ;;
JNE RET_CHK_DID ;;
MOV AX,DID_BIT[DI] ;;
MOV BUF.DID_PRN,AX ;;
;;
;;
JMP RET_CHK_DID ;;
;;
LPT_FAIL: ;;
;;
MOV BUF.STATE,NORMAL ;; the LPTn is NORMAL --- STATE
;;
;;
RET_CHK_DID: ;;
;;
pop dx ;;
pop di ;;
pop cx ;;
;;
RET ;;
;;
CHK_DID ENDP ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Called by INIT to check for consistency between duplicated device name and
;; between PRN and LPT1
;;
;; at entry : DI = pointer to PAR_DEVOT
;; BUF.STATE = any state
;; CX = DID order
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
DEV_CHECK PROC ;;
;;
LEA SI,BUF.PAR_EXTRACTO ;;
;;
PUSH CX ;;
;;
PUSH SI ;; compare device id
PUSH DI ;;
mov SI,[SI].PAR_DIDO ;;
MOV DI,PSE.PAR_DIDO ;;
MOV CX,PSE.PAR_DNML ;;
INC CX ;; including length
INC CX ;;
REPE CMPSB ;;
POP DI ;;
POP SI ;;
Jz hwcp_check ;;
mov init_chk,0021h ;; error 0021h
Jmp FORCE_LPT_BAD ;;
;;
hwcp_check : ;;
PUSH SI ;; compare HWCP
PUSH DI ;;
mov SI,[SI].PAR_HWCPO ;;
MOV DI,PSE.PAR_HWCPO ;;
MOV AX,PSE.PAR_HWCPL ;;
MOV CX,2 ;;
SHL AX,CL ;; multiply by two
INC AX ;; including length
INC AX ;;
MOV CX,AX ;;
REPE CMPSB ;;
POP DI ;;
POP SI ;;
Jz desig_check ;;
mov init_chk,0022h ;; error 0022h
Jmp FORCE_LPT_BAD ;;
;;
desig_check : ;;
PUSH SI ;; compare DESIGNATE
PUSH DI ;;
mov SI,[SI].PAR_DESGO ;;
MOV DI,PSE.PAR_DESGO ;;
MOV AX,PSE.PAR_DESGL ;;
MOV CX,2 ;;
SHL AX,CL ;; multiply by two
INC AX ;; including length
INC AX ;;
MOV CX,AX ;;
REPE CMPSB ;;
POP DI ;;
POP SI ;;
Jz param_check ;;
mov init_chk,0023h ;; error 0023h
Jmp FORCE_LPT_BAD ;;
;;
param_check : ;;
PUSH SI ;; compare parameters
PUSH DI ;;
mov SI,[SI].PAR_PARMO ;;
MOV DI,PSE.PAR_PARMO ;;
MOV CX,PSE.PAR_PARML ;;
INC CX ;; including length
INC CX ;;
REPE CMPSB ;;
POP DI ;;
POP SI ;;
JZ M_END ;;
mov init_chk,0024h ;; error 0024h
;;
FORCE_LPT_BAD : ;; the second set of parameters is
MOV BUF.STATE,NORMAL ;; bad
;;
CMP BUF.BFLAG,BF_LPT1 ;;
JNE M_END ;;
;;
;; since LPT1 is bad, force PRN to bad
push bx ;; force prn to be bad too
mov bx,buf.prn_bufo ;;
MOV BUF.STATE,NORMAL ;;
pop bx ;;
;;
mov AX,BUF.DID_PRN ;; if PRN was not good, DID_PRN = 0
OR DID_FAIL,AX ;;
;;
;;
M_END: ;; force the good did_status to fail if
;; STATE is bad
POP CX ;;
PUSH CX ;; order 0 to m
MOV AX,DID_STATUS ;;
;;
INC CX ;;
SHR AX,CL ;;
POP CX ;;
JNC DEV_CHECK_RET ;; already failed
;;
CMP BUF.STATE,CPSW ;;
JE DEV_CHECK_RET ;;
;;
PUSH BX ;;
MOV BX,CX ;;
ADD BX,BX ;;
MOV AX,DID_BIT[BX] ;;
OR DID_FAIL,AX ;; force DID to fail
POP BX ;;
;;
;;
DEV_CHECK_RET : ;;
;;
RET ;;
;;
;;
DEV_CHECK ENDP ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
CSEG ENDS
END
|