This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
DRIVER.ASM
1296 lines (1182 loc) · 30.5 KB
/
DRIVER.ASM
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
PAGE 64,132 ;
; SCCSID = @(#)driver.asm 4.13 85/10/15
; SCCSID = @(#)driver.asm 4.13 85/10/15
;
; External block device driver
; Hooks into existing routines in IBMBIO block driver via Int 2F mpx # 8.
; This technique minimizes the size of the driver.
;
; Revised Try_h: to test for flagheads as msg was being displayed on FormFactor
; this caused the FormFactor to be set in the Head
; Revised the # of sectors/cluster for F0h to 1
;==============================================================================
;REVISION HISTORY:
;AN000 - New for DOS Version 4.00 - J.K.
;AC000 - Changed for DOS Version 4.00 - J.K.
;AN00x - PTM number for DOS Version 4.00 - J.K.
;==============================================================================
;AN001 - d55 Unable the fixed disk accessibility of DRIVER.SYS. 7/7/87 J.K.
;AN002 - p196 Driver.sys does not signal init. failure 8/17/87 J.K.
;AN003 - p267 "No driver letter..." message 8/19/87 J.K.
;AN004 - p268 "Too many parameter..." message 8/20/87 J.K.
;AN005 - p300 "Bad 1.44MB BPB information..." 8/20/87 J.K.
;AN006 - p490 Driver should reject identical parms 8/28/87 J.K.
;AN007 - p921 Parser.ASM problem 9/18/87 J.K.
;AN008 - d493 New init request structure 2/25/88 J.K.
;==============================================================================
code segment byte public
assume cs:code,ds:code,es:code
;AN000;
.xlist
include SYSMSG.INC ;equates and macros
.list
MSG_UTILNAME <DRIVER>
iTEST = 0
;---------------------------------------------------
;
; Device entry point
;
DSKDEV LABEL WORD
DW -1,-1 ; link to next device
DW 0000100001000000B ; bit 6 indicates DOS 3.20 driver
DW STRATEGY
DW DSK$IN
DRVMAX DB 1
;
; Various equates
;
CMDLEN equ 0 ;LENGTH OF THIS COMMAND
UNIT equ 1 ;SUB UNIT SPECIFIER
CMD equ 2 ;COMMAND CODE
STATUS equ 3 ;STATUS
MEDIA equ 13 ;MEDIA DESCRIPTOR
TRANS equ 14 ;TRANSFER ADDRESS
COUNT equ 18 ;COUNT OF BLOCKS OR CHARACTERS
START equ 20 ;FIRST BLOCK TO TRANSFER
EXTRA equ 22 ;Usually a pointer to Vol Id for error 15
CONFIG_ERRMSG equ 23 ;AN009; To set this field to Non-zero
; to display "Error in CONFIG.SYS..."
PTRSAV DD 0
STRATP PROC FAR
STRATEGY:
MOV WORD PTR CS:[PTRSAV],BX
MOV WORD PTR CS:[PTRSAV+2],ES
RET
STRATP ENDP
DSK$IN:
push es
push bx
push ax
les bx,cs:[ptrsav]
cmp byte ptr es:[bx].cmd,0
jnz Not_Init
jmp DSK$INIT
not_init:
; Because we are passing the call onto the block driver in IBMBIO, we need to
; ensure that the unit number corresponds to the logical (DOS) unit number, as
; opposed to the one that is relevant to this device driver.
mov al,byte ptr cs:[DOS_Drive_Letter]
mov byte ptr es:[bx].UNIT,al
mov ax,0802H
int 2fH
;
; We need to preserve the flags that are returned by IBMBIO. YUK!!!!!
;
pushf
pop bx
add sp,2
push bx
popf
exitp proc far
DOS_Exit:
pop ax
POP BX
POP ES
RET ;RESTORE REGS AND RETURN
EXITP ENDP
include msbds.inc ; include BDS structures
;include versiona.inc
BDS DW -1 ;Link to next structure
DW -1
DB 1 ;Int 13 Drive Number
DB 3 ;Logical Drive Letter
FDRIVE:
DW 512 ;Physical sector size in bytes
DB -1 ;Sectors/allocation unit
DW 1 ;Reserved sectors for DOS
DB 2 ;No. allocation tables
DW 64 ;Number directory entries
DW 9*40 ;Number sectors (at 512 bytes ea.)
DB 00000000B ;Media descriptor, initially 00H.
DW 2 ;Number of FAT sectors
DW 9 ;Sector limit
DW 1 ;Head limit
DW 0 ;Hidden sector count
dw 0 ;AN000; Hidden sector count (High)
dw 0 ;AN000; Number sectors (low)
dw 0 ;AN000; Number sectors (high)
DB 0 ; TRUE => Large fats
OPCNT1 DW 0 ;Open Ref. Count
DB 2 ;Form factor
FLAGS1 DW 0020H ;Various flags
DW 80 ;Number of cylinders in device
RecBPB1 DW 512 ; default is that of 3.5" disk
DB 2
DW 1
DB 2
DW 70h
DW 2*9*80
DB 0F9H
DW 3
DW 9
DW 2
DW 0
dw 0 ;AN000;
dw 0 ;AN000;
dw 0 ;AN000;
db 6 dup (0) ;AC000;
TRACK1 DB -1 ;Last track accessed on this drive
TIM_LO1 DW -1 ;Keep these two contiguous (?)
TIM_HI1 DW -1
VOLID1 DB "NO NAME ",0 ;Volume ID for this disk
VOLSER dd 0 ;AN000;
FILE_ID db "FAT12 ",0 ;AN000;
DOS_Drive_Letter db ? ; Logical drive associated with this unit
ENDCODE LABEL WORD ; Everything below this is thrown away
; after initialisation.
DskDrv dw offset FDRIVE ; "array" of BPBs
;AN000; For system parser;
FarSW equ 0 ; Near call expected
DateSW equ 0 ; Check date format
TimeSW equ 0 ; Check time format
FileSW equ 0 ; Check file specification
CAPSW equ 0 ; Perform CAPS if specified
CmpxSW equ 0 ; Check complex list
NumSW equ 1 ; Check numeric value
KeySW equ 0 ; Support keywords
SwSW equ 1 ; Support switches
Val1SW equ 1 ; Support value definition 1
Val2SW equ 1 ; Support value definition 2
Val3SW equ 0 ; Support value definition 3
DrvSW equ 0 ; Support drive only format
QusSW equ 0 ; Support quoted string format
;---------------------------------------------------
;.xlist
assume ds:nothing ;AN007;!!!Parse.ASM sometimes assumes DS
; to access its own variable!!!
include PARSE.ASM ;together with PSDATA.INC
assume ds:code ;AN007;
;.list
;Control block definitions for PARSER.
;---------------------------------------------------
Parms label byte
dw Parmsx ;AN000;
db 0 ;AN000;No extras
Parmsx label byte ;AN000;
db 0,0 ;AN000;No positionals
db 5 ;AN000;5 switch control definitions
dw D_Control ;AN000;/D
dw T_Control ;AN000;/T
dw HS_Control ;AN000;/H, /S
dw CN_Control ;AN000;/C, /N
dw F_Control ;AN000;/F
db 0 ;AN000;no keywords
D_Control label word ;AN000;
dw 8000h ;AN000;numeric value
dw 0 ;AN000;no functions
dw Result_Val ;AN000;result buffer
dw D_Val ;AN000;value defintions
db 1 ;AN000;# of switch in the following list
Switch_D label byte ;AN000;
db '/D',0 ;AN000;
D_Val label byte ;AN000;
db 1 ;AN000;# of value defintions
db 1 ;AN000;# of ranges
db 1 ;AN000;Tag value when match
; dd 0,255 ;AN000;
dd 0,127 ;AN001;Do not allow a Fixed disk.
Result_Val label byte ;AN000;
db ? ;AN000;
Item_Tag label byte ;AN000;
db ? ;AN000;
Synonym_ptr label word ;AN000;
dw ? ;AN000;es:offset -> found Synonym
RV_Byte label byte ;AN000;
RV_Word label word ;AN000;
RV_Dword label dword ;AN000;
dd ? ;AN000;value if number, or seg:off to string
T_Control label word ;AN000;
dw 8000h ;AN000;numeric value
dw 0 ;AN000;no functions
dw Result_Val ;AN000;result buffer
dw T_Val ;AN000;value defintions
db 1 ;AN000;# of switch in the following list
Switch_T label byte ;AN000;
db '/T',0 ;AN000;
T_Val label byte ;AN000;
db 1 ;AN000;# of value defintions
db 1 ;AN000;# of ranges
db 1 ;AN000;Tag value when match
dd 1,999 ;AN000;
HS_Control label word ;AN000;
dw 8000h ;AN000;numeric value
dw 0 ;AN000;no function flag
dw Result_Val ;AN000;Result_buffer
dw HS_VAL ;AN000;value definition
db 2 ;AN000;# of switch in following list
Switch_H label byte ;AN000;
db '/H',0 ;AN000;
Switch_S label byte ;AN000;
db '/S',0 ;AN000;
HS_Val label byte ;AN000;
db 1 ;AN000;# of value defintions
db 1 ;AN000;# of ranges
db 1 ;AN000;Tag value when match
dd 1,99 ;AN000;
CN_Control label word ;AN000;
dw 0 ;AN000;no match flags
dw 0 ;AN000;no function flag
dw Result_Val ;AN000;no values returned
dw NoVal ;AN000;no value definition
; db 2 ;AN000;# of switch in following list
db 1 ;AN001;
Switch_C label byte ;AN000;
db '/C',0 ;AN000;
;Switch_N label byte ;AN000;
; db '/N',0 ;AN000;
Noval db 0 ;AN000;
F_Control label word ;AN000;
dw 8000h ;AN000;numeric value
dw 0 ;AN000;no function flag
dw Result_Val ;AN000;Result_buffer
dw F_VAL ;AN000;value definition
db 1 ;AN000;# of switch in following list
Switch_F label byte ;AN000;
db '/F',0 ;AN000;
F_Val label byte ;AN000;
db 2 ;AN000;# of value definitions (Order dependent)
db 0 ;AN000;no ranges
db 4 ;AN000;# of numeric choices
F_Choices label byte ;AN000;
db 1 ;AN000;1st choice (item tag)
dd 0 ;AN000;0
db 2 ;AN000;2nd choice
dd 1 ;AN000;1
db 3 ;AN000;3rd choice
dd 2 ;AN000;2
db 4 ;AN000;4th choice
dd 7 ;AN000;7
;AN000;System messages handler data
;AN000;Put the data here
.sall
MSG_SERVICES <MSGDATA>
;AN000;Place the messages here
MSG_SERVICES <DRIVER.CL1, DRIVER.CL2, DRIVER.CLA>
;AN000;Put messages handler code here.
MSG_SERVICES <LOADmsg,DISPLAYmsg,CHARmsg>
.xall
;
; Sets ds:di -> BDS for this drive
;
SetDrive:
push cs
pop ds
mov di,offset BDS
ret
;
; Place for DSK$INIT to exit
;
ERR$EXIT:
MOV AH,10000001B ;MARK ERROR RETURN
lds bx, cs:[ptrsav]
mov byte ptr ds:[bx.MEDIA], 0 ;AN002; # of units
mov word ptr ds:[bx.CONFIG_ERRMSG], -1 ;AN009;Show IBMBIO error message too.
JMP SHORT ERR1
Public EXIT
EXIT: MOV AH,00000001B
ERR1: LDS BX,CS:[PTRSAV]
MOV WORD PTR [BX].STATUS,AX ;MARK OPERATION COMPLETE
RestoreRegsAndReturn:
POP DS
POP BP
POP DI
POP DX
POP CX
POP AX
POP SI
jmp dos_exit
drivenumb db 5
cyln dw 80
heads dw 2
ffactor db 2
slim dw 9
Switches dw 0
Drive_Let_Sublist label dword
db 11 ;AN000;length of this table
db 0 ;AN000;reserved
dw D_Letter;AN000;
D_Seg dw ? ;AN000;Segment value. Should be CS
db 1 ;AN000;DRIVER.SYS has only %1
db 00000000b ;AN000;left align(in fact, Don't care), a character.
db 1 ;AN000;max field width 1
db 1 ;AN000;min field width 1
db ' ' ;AN000;character for pad field (Don't care).
D_Letter db "A"
if iTEST
Message:
push ax
push ds
push cs
pop ds
mov ah,9
int 21h
pop ds
pop ax
ret
extrn nodrive:byte,loadokmsg:byte,letter:byte, badvermsg:byte
endif
if iTEST
%OUT Testing On
initmsg db "Initializing device driver",13,10,"$"
stratmsg db "In strategy of driver",10,13,"$"
dskinmsg db "In DSKIN part of driver",10,13,"$"
outinitmsg db "Out of init code ",10,13,"$"
exitmsg db "Exiting from driver",10,13,"$"
parsemsg db "Parsing switches",10,13,"$"
errmsg db "Error occurred",10,13,"$"
linemsg db "Parsed line",10,13,"$"
int2fokmsg db "****************Int2f loaded**************",10,13,"$"
mediamsg db "Media check ok",10,13,"$"
getbpbmsg db "getbpb ok",10,13,"$"
iookmsg db "Successful I/O",10,13,"$"
parseokmsg db "Parsing done fine",10,13,"$"
nummsg db "Number read is "
number db "00 ",10,13,"$"
drvmsg db "Process drive "
driven db "0",10,13,"$"
cylnmsg db "Process cylinder ",10,13,"$"
slimmsg db "Process sec/trk ",10,13,"$"
hdmsg db "Process head "
hdnum db "0",10,13,"$"
ffmsg db "Process form factor "
ffnum db "0",10,13,"$"
nxtmsg db "Next switch ",10,13,"$"
msg48tpi db "Got a 48 tpi drive",10,13,"$"
ENDIF
DSK$INIT:
PUSH SI
PUSH AX
PUSH CX
PUSH DX
PUSH DI
PUSH BP
PUSH DS
LDS BX,CS:[PTRSAV] ;GET POINTER TO I/O PACKET
MOV AL,BYTE PTR DS:[BX].UNIT ;AL = UNIT CODE
MOV AH,BYTE PTR DS:[BX].MEDIA ;AH = MEDIA DESCRIP
MOV CX,WORD PTR DS:[BX].COUNT ;CX = COUNT
MOV DX,WORD PTR DS:[BX].START ;DX = START SECTOR
LES DI,DWORD PTR DS:[BX].TRANS
PUSH CS
POP DS
ASSUME DS:CODE
cld
push cs ;AN000; Initialize Segment of Sub list.
pop [D_Seg] ;AN000;
call SYSLOADMSG ;AN000; linitialize message handler
jnc GoodVer ;AN000; Error. Do not install driver.
mov cx, 0 ;AN000; No substitution
mov dh, -1 ;AN000; Utility message
call Show_Message ;AN000; Show message
jmp err$exitj2 ;AN000; and exit
;; check for correct DOS version
; mov ah,30h
; int 21H
; cmp ax,expected_version
; je GoodVer
; cmp al,DOSVER_HI
; jnz BadDOSVer
; cmp ah,DOSVER_LO
; jz GoodVer
;BadDOSVer:
; Mov dx,offset BadVerMsg
; call message
; jmp err$exitj2 ; do not install driver
GoodVer:
mov ax,0800H
int 2fH ; see if installed
cmp al,0FFH
jnz err$exitj2 ; do not install driver if not present
lds bx,[ptrsav]
mov si,word ptr [bx].count ; get pointer to line to be parsed
mov ax,word ptr [bx].count+2
mov ds,ax
call Skip_Over_Name ; skip over file name of driver
mov di,offset BDS ; point to BDS for drive
push cs
pop es ; es:di -> BDS
Call ParseLine
jc err$exitj2
LDS BX,cs:[PTRSAV]
mov al,byte ptr [bx].extra ; get DOS drive letter
mov byte ptr es:[di].DriveLet,al
mov cs:[DOS_Drive_Letter],al
add al,"A"
; mov cs:[letter],al ; set up for printing final message
mov cs:[D_Letter], al ;AN000;
call SetDrvParms ; Set up BDS according to switches
jc err$exitj2
mov ah,8 ; Int 2f multiplex number
mov al,1 ; install the BDS into the list
push cs
pop ds ; ds:di -> BDS for drive
mov di,offset BDS
int 2FH
lds bx,dword ptr cs:[ptrsav]
mov ah,1
mov cs:[DRVMAX],ah
mov byte ptr [bx].media,ah
mov ax,offset ENDCODE
mov word ptr [bx].TRANS,AX ; set address of end of code
mov word ptr [bx].TRANS+2,CS
mov word ptr [bx].count,offset DskDrv
mov word ptr [bx].count+2,cs
push dx
push cs
pop ds
mov si, offset Drive_Let_SubList ;AC000;
mov ax, LOADOK_MSG_NUM ;load ok message
mov cx, 1 ;AN000; 1 substitution
mov dh, -1 ;AN000; utility message
call Show_Message
; mov dx,offset loadokmsg
; call message
pop dx
jmp EXIT
err$exitj2:
stc
jmp err$exit
;
; Skips over characters at ds:si until it hits a `/` which indicates a switch
; J.K. If it hits 0Ah or 0Dh, then will return with SI points to that character.
Skip_Over_Name:
call scanblanks
loop_name:
lodsb
cmp al,CR ;AN003;
je End_SkipName ;AN003;
cmp al,LF ;AN003;
je End_SkipName ;AN003;
cmp al,'/'
jnz loop_name
End_SkipName: ;AN003;
dec si ; go back one character
RET
;ParseLine:
; push di
; push ds
; push si
; push es
;Next_Swt:
;IF iTEST
; mov dx,offset nxtmsg
; call message
;ENDIF
; call ScanBlanks
; lodsb
; cmp al,'/'
; jz getparm
; cmp al,13 ; carriage return
; jz done_line
; CMP AL,10 ; line feed
; jz done_line
; cmp al,0 ; null string
; jz done_line
; mov ax,-2 ; mark error invalid-character-in-input
; stc
; jmp short exitparse
;
;getparm:
; call Check_Switch
; mov cs:Switches,BX ; save switches read so far
; jnc Next_Swt
; cmp ax,-1 ; mark error number-too-large
; stc
; jz exitparse
; mov ax,-2 ; mark invalid parameter
; stc
; jmp short exitparse
;
;done_line:
; test cs:Switches,flagdrive ; see if drive specified
; jnz okay
; push dx
; mov ax, 2
; call Show_Message
; mov dx,offset nodrive
; call message
; pop dx
; mov ax,-3 ; mark error no-drive-specified
; stc
; jmp short exitparse
;
;okay:
; call SetDrive ; ds:di points to BDS now.
; mov ax,cs:Switches
; and ax,fChangeline+fNon_Removable ; get switches for Non_Removable and Changeline
; or ds:[di].flags,ax
; xor ax,ax ; everything is fine
;
;;
;; Can detect status of parsing by examining value in AX.
;; 0 ==> Successful
;; -1 ==> Number too large
;; -2 ==> Invalid character in input
;; -3 ==> No drive specified
;
; clc
;exitparse:
; pop es
; pop si
; pop ds
; pop di
; ret
ParseLine proc near
;In) DS:SI -> Input string
; ES = CS
; ES:DI -> BDS table inside this program
;
;Out)
; if successfule, then { AX will be set according to the switch
; flag value. BDS.Flag, Drivenumb, cylin,
; slim, heads ffactor are set }
; else
; {
; If (no drive specified) then { display messages };
; Set carry;
; }
;
;Subroutine to be called:
; SYSPARSE:NEAR, SHOW_MESSAGE:NEAR, GET_RESULT:NEAR
;
;Logic:
;{ While (Not end_of_Line)
; {
; SYSPARSE ();
; if (no error) then
; GET_RESULT ()
; else
; Set carry;
; };
;
; if (carry set) then Exit; /* Initialization failed */
; if (No drive number entered) /* Drive number is a requirement */
; then { Show_Message ();
; exit;
; };
;
assume ds:nothing ;AN000;make sure
push di ;AN000;save BDS pointer
mov di, offset PARMS ;AN000;now, es:di -> parse control definition
SysP_While: ;AN000;
xor cx, cx ;AN004; I don't have positionals.
xor dx, dx ;AN000;
call SYSPARSE ;AN000;
cmp ax, $P_RC_EOL ;AN000;end of line?
je SysP_End ;AN000;
cmp ax, $P_NO_ERROR ;AN000;no error?
jne SysP_Fail ;AN000;
call Get_Result ;AN000;
jmp SysP_While ;AN000;
SysP_End: ;AN000;
test Switches, FLAGDRIVE ;AN000;drive number specified?
jnz SysP_Ok ;AN000;Drive number is a requirement
push ds ;AN000;
mov ax, NODRIVE_MSG_NUM ;AN000;no drive specification
mov cx, 0 ;AN000;no substitutions
mov dh, -1 ;AN000;utility message
call Show_Message ;AN000;
pop ds ;AN000;
jmp short SysP_Err ;AN003;
SysP_Fail: ;AN000;
mov dh, 2 ;AN000; parse error
mov cx, 0 ;AN000;
call Show_Message ;AN000; Show parse error
SysP_Err: ;AN003;
stc ;AN000;
jmp short PL_Ret ;AN000;
SysP_Ok: ;AN000;
clc ;AN000;
PL_Ret: ;AN000;
pop di ;AN000;restore BDS pointer
ret ;AN000;
ParseLine endp
;
Get_Result proc near
;In) A successful result of SYSPARSE in Result_Val
; es = cs, ds = command line segment
;Out)
; Switches set according to the user option.
; Drivenumb, Cyln, Heads, Slim, ffactor set if specified.
;Logic)
; Switch (Synonym_Ptr)
; { case Switch_D: Switches = Switches | FLAGDRIVE; /* Set switches */
; Drivenumb = Reg_DX.Value_L;
; break;
;
; case Switch_T: Switches = Switches | Flagcyln;
; Cyln = Reg_DX.Value_L;
; break;
;
; case Switch_H: Switches = Switches | Flagheads;
; Heads = Reg_DX.Value_L;
; break;
;
; case Switch_S: Switches = Switches | FlagSecLim;
; Slim = Reg_DX.Value_L;
; break;
;
; case Switch_C: Switches = Switches | fChangeline;
; break;
;
;; case Switch_N: Switches = Switches | fNon_Removable;
;; break;
;
; case Switch_F: Switches = Switches | Flagff;
; Reg_DX = (Reg_DX.ITEM_Tag - 1)*5;/*Get the offset of
; /*the choice.
; ffactor = byte ptr (F_Choices + DX + 1);
; /*Get the value of it */
; break;
;
; }
;
mov ax, Synonym_Ptr ;AN000;
push ax ;AN006; save Synonym_ptr
cmp ax, offset Switch_D ;AN000;
jne Stch_T ;AN000;
or Switches, FLAGDRIVE ;AN000;
mov al, RV_Byte ;AN000;
mov Drivenumb, al ;AN000;
jmp GR_Ret ;AN000;
Stch_T: ;AN000;
cmp ax, offset Switch_T ;AN000;
jne Stch_H ;AN000;
or Switches, FLAGCYLN ;AN000;
mov ax, RV_Word ;AN000;
mov Cyln, ax ;AN000;
jmp GR_Ret ;AN000;
Stch_H: ;AN000;
cmp ax, offset Switch_H ;AN000;
jne Stch_S ;AN000;
or Switches, FLAGHEADS ;AN000;
mov ax, RV_Word ;AN000;
mov Heads, ax ;AN000;
jmp GR_Ret ;AN000;
Stch_S: ;AN000;
cmp ax, offset Switch_S ;AN000;
jne Stch_C ;AN000;
or Switches, FLAGSECLIM ;AN000;
mov ax, RV_Word ;AN000;
mov Slim, ax ;AN000;
jmp GR_Ret ;AN000;
Stch_C: ;AN000;
cmp ax, offset Switch_C ;AN000;
; jne Stch_N ;AN000;
jne Stch_F ;AN001;
or Switches, fCHANGELINE ;AN000;
jmp GR_Ret ;AN000;
;Stch_N: ;AN000;
; cmp ax, offset Switch_N ;AN000;
; jne Stch_F ;AN000;
; or Switches, fNON_REMOVABLE ;AN000;
; jmp GR_Ret ;AN000;
Stch_F: ;AN000;
cmp ax, offset Switch_F ;AN000;
jne GR_Not_Found_Ret ;AN000;error in SYSPARSE
or Switches, FLAGFF ;AN000;
push si ;AN004;
mov si, offset F_Choices ;AN000;
xor ax, ax ;AN000;
mov al, Item_Tag ;AN000;
dec al ;AN000;
mov cl, 5 ;AN000;
mul cl ;AN000;
add si, ax ;AN000;
mov al, byte ptr es:[si+1] ;AN000;get the result of choices
mov ffactor, al ;AN000;set form factor
pop si ;AN004;
GR_Ret: ;AN000;
pop ax ;AN006; Restore Synonym ptr
push di ;AN006; Save di
push ax ;AN006;
pop di ;AN006;
mov byte ptr es:[di], ' ' ;AN006;We don't have this switch any more.
pop di ;AN006;
jmp short Gr_Done_Ret ;AN006;
GR_Not_Found_Ret:
pop ax ;AN006;adjust stack
GR_Done_Ret:
ret ;AN000;
Get_Result endp
;
; Scans an input line for blank or tab characters. On return, the line pointer
; will be pointing to the next non-blank character.
;
ScanBlanks:
lodsb
cmp al,' '
jz ScanBlanks
cmp al,9 ; Tab character
jz ScanBlanks
dec si
ret
;
; Gets a number from the input stream, reading it as a string of characters.
; It returns the number in AX. It assumes the end of the number in the input
; stream when the first non-numeric character is read. It is considered an error
; if the number is too large to be held in a 16 bit register. In this case, AX
; contains -1 on return.
;
;GetNum:
; push bx
; push dx
; xor ax,ax
; xor bx,bx
; xor dx,dx
;
;next_char:
; lodsb
; cmp al,'0' ; check for valid numeric input
; jb num_ret
; cmp al,'9'
; ja num_ret
; sub al,'0'
; xchg ax,bx ; save intermediate value
; push bx
; mov bx,10
; mul bx
; pop bx
; add al,bl
; adc ah,0
; xchg ax,bx ; stash total
; jc got_large
; cmp dx,0
; jz next_char
;got_large:
; mov ax,-1
; jmp short get_ret
;
;num_ret:
; mov ax,bx
; dec si ; put last character back into buffer
;
;get_ret:
; pop dx
; pop bx
; ret
;
; Processes a switch in the input. It ensures that the switch is valid, and
; gets the number, if any required, following the switch. The switch and the
; number *must* be separated by a colon. Carry is set if there is any kind of
; error.
;
;Check_Switch:
; lodsb
; and al,0DFH ; convert it to upper case
; cmp al,'A'
; jb err_swtch
; cmp al,'Z'
; ja err_swtch
; mov cl,cs:switchlist ; get number of valid switches
; mov ch,0
; push es
; push cs
; pop es ; set es:di -> switches
; push di
; mov di,1+offset switchlist ; point to string of valid switches
; repne scasb
; pop di
; pop es
; jnz err_swtch
; mov ax,1
; shl ax,cl ; set bit to indicate switch
; mov bx,cs:switches
; or bx,ax ; save this with other switches
; mov cx,ax
; test ax,7cH ; test against switches that require number to follow
; jz done_swtch
; lodsb
; cmp al,':'
; jnz reset_swtch
; call ScanBlanks
; call GetNum
; cmp ax,-1 ; was number too large?
; jz reset_swtch
;IF iTEST
; push ax
; add al,'0'
; add ah,'0'
; mov cs:number,ah
; mov cs:number+1,al
; mov dx,offset nummsg
; call message
; pop ax
;ENDIF
; call Process_Num
;
;done_swtch:
; ret
;
;reset_swtch:
; xor bx,cx ; remove this switch from the records
;err_swtch:
; stc
; jmp short done_swtch
;
; This routine takes the switch just input, and the number following (if any),
; and sets the value in the appropriate variable. If the number input is zero
; then it does nothing - it assumes the default value that is present in the
; variable at the beginning.
;
;Process_Num:
; push ds
; push cs
; pop ds
; test Switches,cx ; if this switch has been done before,
; jnz done_ret ; ignore this one.
; test cx,flagdrive
; jz try_f
; mov drivenumb,al
;IF iTEST
; add al,"0"
; mov driven,al
; mov dx,offset drvmsg
; call message
;ENDIF
; jmp short done_ret
;
;try_f:
; test cx,flagff
; jz try_t
; mov ffactor,al
;IF iTEST
; add al,"0"
; mov ffnum,al
; mov dx,offset ffmsg
; call message
;ENDIF
;
;try_t:
; cmp ax,0
; jz done_ret ; if number entered was 0, assume default value
; test cx,flagcyln
; jz try_s
; mov cyln,ax
;IF iTEST
; mov dx,offset cylnmsg
; call message
;ENDIF
; jmp short done_ret
;
;try_s:
; test cx,flagseclim
; jz try_h
; mov slim,ax
;IF iTEST
; mov dx,offset slimmsg
; call message
;ENDIF
; jmp short done_ret
;
;; Switch must be one for number of Heads.
;try_h:
; test cx,flagheads
; jz done_ret
; mov heads,ax
;IF iTEST
; add al,"0"
; mov hdnum,al
; mov dx,offset hdmsg
; call message
;ENDIF
;
;done_ret:
; pop ds
; ret
;
; SetDrvParms sets up the recommended BPB in each BDS in the system based on
; the form factor. It is assumed that the BPBs for the various form factors