5 ;*****************************************************************************
6 ;*****************************************************************************
7 ;UTILITY NAME: FORMAT.COM
9 ;MODULE NAME: FORINIT.SAL
17 ; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
18 ; ôInit_Input_OutputÃÄÄÄÄ´Preload_Messages³
19 ; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
20 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
21 ; ³ ôCheck_For_FS_SwitchÃÄÄ´Parse_For_FS_Switch³
22 ; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
23 ; ³ ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
24 ; ³ ³ À´EXEC_FS_Format³
25 ; ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
26 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
27 ; ³ À´Parse_Command_Line ÃÄÄÄ´Interpret_Parse³
28 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
29 ; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
30 ; ôValidate_Target_DriveôCheck_Target_Drive³
31 ; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
32 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
33 ; ³ ôCheck_For_Network³
34 ; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
35 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
36 ; ³ À´Check_Translate_Drive³
37 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
43 ; Change List: AN000 - New code DOS 3.3 spec additions
44 ; AC000 - Changed code DOS 3.3 spec additions
45 ;*****************************************************************************
46 ;*****************************************************************************
48 data segment public para
'DATA'
54 ;These should stay togather
55 ; --------------------------------------- ; ;AN000;
56 FS_String_Buffer db 13 dup(" ") ; ;AN000;
57 FS_String_End db "FMT.EXE",0 ; ;AN000;
58 Len_FS_String_End equ
$ - FS_String_End
; ;AN000;
60 ;----------------------------------------
62 Vol_Label_Count db 80h
;an000; dms;max. string length
63 Vol_Label_Len db 00h ;an000; dms;len. entered
64 Vol_Label_Buffer db 80h
dup(0) ; ;AN000;
65 Vol_Label_Buffer_Length equ
$ - Vol_Label_Buffer
; ;AN000;
67 Command_Line_Buffer db 80h
dup(0) ; ;AN000;
68 Command_Line_Length equ
$ - Command_Line_Buffer
; ;AN000;
69 Fatal_Error db 0 ; ;AN000;
75 code segment public para
'CODE'
76 assume
cs:code,ds:data,es:data
80 ;*****************************************************************************
82 ;*****************************************************************************
96 ;*****************************************************************************
98 ;*****************************************************************************
101 Public FS_String_Buffer
104 Public Vol_Label_Count
105 Public Vol_Label_Buffer
107 Public Command_Old_Ptr
111 ;*****************************************************************************
113 ;*****************************************************************************
120 ;*****************************************************************************
121 ; External Routine Declarations
122 ;*****************************************************************************
125 Extrn Main_Routine
:Near
126 Extrn SysLoadMsg
:Near
127 Extrn Get_11_Characters
:Near
128 Extrn ControlC_Handler
:Near
129 Extrn SysDispMsg
:Near
130 Extrn SysLoadMsg
:Near
132 IF FSExec
;/FS: conditional assembly ;an018; dms;
134 Extrn EXEC_FS_Format
:Near
136 ENDIF
;/FS: conditional assembly end ;an018;dms;
138 Extrn GetDeviceParameters
:Near
140 ;*****************************************************************************
141 ; External Data Declarations
142 ;*****************************************************************************
146 Extrn ExitStatus
:Byte
148 Extrn DriveLetter
:Byte
151 Extrn NumSectors
:Word
154 Extrn CommandFile
:Byte
155 Extrn MsgNeedDrive
:Byte
156 Extrn MsgBadVolumeID
:Byte
157 Extrn MsgBadDrive
:Byte
158 Extrn MsgAssignedDrive
:Byte
159 Extrn MsgNetDrive
:Byte
160 Extrn Parse_Error_Msg
:Byte
161 Extrn Extended_Error_Msg
:Byte
163 Extrn MsgSameSwitch
:Byte
164 Extrn Org_AX
:word ;an000; dms;AX on prog. entry
165 Extrn DeviceParameters
:Byte ;an000; dms;
166 Extrn FAT_Flag
:Byte ;an000; dms;
167 Extrn Sublist_MsgParse_Error
:Dword ;an000; dms;
170 code segment public para
'CODE'
172 ;*****************************************************************************
173 ;Routine name: Main_Init
174 ;*****************************************************************************
176 ;Description: Main control routine for init section
178 ;Called Procedures: Message (macro)
181 ; Validate_Target_Drive
188 ;Change History: Created 5/1/87 MT
195 ; Setup I/O (CALL Init_Input_Output)
197 ; Check target drive letter (CALL Validate_Target_Drive)
199 ; Set up Control Break (CALL Hook_CNTRL_C)
206 ;*****************************************************************************
208 Procedure Main_Init
; ;AN000;
211 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
212 DOS_Call GetCurrentPSP
;Get PSP segment address
213 mov PSP_Segment
,bx ;Save it for later
214 mov Fatal_Error
,No
;Init the error flag ;AN000;
215 call Init_Input_Output
;Setup messages and parse ;AN000;
216 cmp Fatal_Error
,Yes
;Error occur? ;AN000;
217 ; $IF NE ;Nope, keep going ;AN000;
219 call Validate_Target_Drive
;Check drive letter ;AN000;
220 cmp Fatal_Error
,Yes
;Error occur? ;AN000;
221 ; $IF NE ;Nope, keep going ;AN000;
223 call Hook_CNTRL_C
;Set CNTRL -Break hook ;AN000;
224 cmp Fatal_Error
,Yes
;Error occur? ;AN000;
225 ; $IF NE ;Nope, keep going ;AN000;
227 call Main_Routine
;Go do the real program ;AN000;
234 mov al,ExitStatus
;Get Errorlevel ;AN000;
235 DOS_Call Exit
;Exit program ;AN000;
236 int 20h
;If other exit fails ;AN000;
238 Main_Init endp
; ;AN000;
240 ;*****************************************************************************
241 ;Routine name: Init_Input_Output
242 ;*****************************************************************************
244 ;Description: Initialize messages, Parse command line, allocate memory as
245 ; needed. If there is a /FS switch, go handle it first as
246 ; syntax of IFS format may be different from FAT format.
248 ;Called Procedures: Preload_Messages
249 ; Parse_For_FS_Switch
252 ;Change History: Created 4/1/87 MT
254 ;Input: PSP command line at 81h and length at 80h
257 ;Output: Fatal_Error = YES/NO
262 ; Load messages (CALL Preload_Messages)
264 ; See if EXEC another file system (CALL Parse_For_FS_Switch)
265 ; IF !FATAL_Error (in this case means FS was found and exec'd)
266 ; CALL Parse_Command_Line
268 ; CALL Interpret_Parse
273 ;*****************************************************************************
275 Procedure Init_Input_Output
; ;AN000;
277 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
278 call Preload_Messages
;Load up message retriever ;AN000;
280 IF FSExec
;/FS: conditional assembly ;an018; dms;
282 cmp Fatal_Error
,YES
;Quit? ;AN000;
283 ; $IF NE ;Nope, keep going ;AN000;
285 call Check_For_FS_Switch
;Specify FS other than FAT? ;AN000;
287 ENDIF
;/FS: conditional assembly end ;an018;dms;
289 cmp Fatal_Error
,YES
;drive is invalid for format? ;an000;
292 call Parse_Command_Line
;Parse in command line input ;AN000;
293 cmp Fatal_Error
,YES
;Quit? ;AN000;
294 ; $IF NE ;Nope, keep going ;AN000;
296 call Determine_FAT_Non_FAT
;see if drive was non_FAT ;an000;
297 call Check_For_Invalid_Drive
;Drive joined? ;an000;
303 IF FSExec
;/FS: conditional assembly ;an018; dms;
308 ENDIF
;/FS: conditional assembly end ;an018;dms;
312 Init_Input_Output endp
; ;AN000;
314 ;*****************************************************************************
315 ;Routine name: Preload_Messages
316 ;*****************************************************************************
318 ;Description: Preload messages using common message retriever routines.
320 ;Called Procedures: SysLoadMsg
323 ;Change History: Created 5/1/87 MT
325 ;Input: Fatal_Error = NO
327 ;Output: Fatal_Error = YES/NO
332 ; Preload All messages (Call SysLoadMsg)
334 ; Display SysLoadMsg error message
338 ;*****************************************************************************
340 Procedure Preload_Messages
; ;AN000;
342 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
343 call SysLoadMsg
;Preload the messages ;AN000;
344 ; $IF C ;Error? ;AN000;
346 call SysDispMsg
;Display preload msg ;AN000;
347 mov Fatal_Error
, YES
;Indicate error exit ;AN000;
352 Preload_Messages endp
; ;AN000;
357 IF FSExec
;/FS: conditional assembly ;an018; dms;
360 ;*****************************************************************************
361 ;Routine name: Check_For_FS_Switch
362 ;*****************************************************************************
364 ;Description: Parse to see if /FS switch entered, and if so, go EXEC the
365 ; asked for file system. Set Fatal_Error = YES if FS found
366 ; If we do find /FS, we need to build a string of xxxxxfmt.exe,0
367 ; where xxxxx is the first 5 characters or less of /FS:xxxxx
369 ;Called Procedures: Parse_For_FS_Switch
372 ;Change History: Created 6/21/87 MT
374 ;Input: Fatal_Error = NO
376 ;Output: Fatal_Error = YES/NO
382 ; Parse for /FS switch (CALL Parse_For_FS_Switch)
385 ; Point at what was entered on /FS:xxxxx
387 ; LEAVE end of entered string
388 ; Got good char, move into path
389 ; ENDDO already got 5 chars (max in xxxxxfmt.exe)
390 ; Tack on the rest of the string (fmt.exe,0)
391 ; Go exec the needed format (CALL EXEC_FS_Format)
395 ;*****************************************************************************
397 Procedure Check_For_FS_Switch
; ;AN000;
399 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
400 call Parse_For_FS_Switch
;See if /FS entered ;AN000;
401 cmp Fatal_Error
,YES
;Bad stuff entered?? ;AN000;
402 ; $IF NE ;Nope, cruise onward ;AN000;
404 cmp Switch_String_Buffer
.Switch_Pointer
,offset Switch_FS_Control
.Keyword
; ;AN000;
405 ; $IF E ;We got the switch ;AN000;
407 mov Switch_FS_Control
.Keyword
,20h
;an000; dms;remove switch from table
408 test SwitchMap
,Switch_FS
;Have this already? ;AN002;
409 ; $IF Z ;Nope ;AN002;
411 push ds ;Get addressibility ;AN000;
412 pop es ; " " " " ;AN000;
414 assume
ds:nothing
,es:data ; ;AN000;
416 mov ax,Switch_String_Buffer
.Switch_String_Seg
;Get the entered FS ;AN000;
418 mov si,es:Switch_String_Buffer
.Switch_String_Off
; ;AN000;
419 mov cx,FS_String_Max_Length
; ;AN000;
420 mov di,offset
es:FS_String_Buffer
; ;AN000;
421 ; $DO ;Move whatever user entered ;AN000;
423 cmp byte ptr [si],ASCIIZ_End
;End of the string? ;AN000;
424 ; $LEAVE E ;Yep ;AN000;
426 movsb ;Put character in buffer ;AN000;
427 dec cx ;Dec character counter
428 cmp cx,0 ;Nope, reached max # chars? ;AN000;
429 ; $ENDDO E ;Yes ;AN000;
432 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
433 mov cx,Len_FS_String_End
;Tack the FMT.EXE onto it ;AN000;
434 mov si,offset
es:FS_String_End
;DI still points at string ;AN000;
435 rep movsb ;We now have Asciiz path! ;AN000;
436 call EXEC_FS_Format
;Go try to EXEC it..... ;AN000;
440 Message msgSameSwitch
; ;AN002;
441 mov Fatal_Error
,Yes
; ;AN002;
450 Check_For_FS_Switch endp
; ;AN000;
452 ;*****************************************************************************
453 ;Routine name: Parse_For_FS_Switch
454 ;*****************************************************************************
456 ;Description: Copy the command line. Parse the new command line (Parse routines
457 ; destroy the data being parsed, so need to work on copy so that
458 ; complete command line can be passed to child format).
459 ; The only thing we care about is if the /FS: switch exists, so
460 ; parse until end of command line found. If there was an error,
461 ; and it occurred on the /FS switch, then give parse error,
462 ; otherwise ignore the parse error, because it might be something
463 ; file system specific that doesn't meet DOS syntax rules. Also
464 ; check for drive letter, as it is alway required.
466 ;Called Procedures: Message (macro)
471 ;Change History: Created 5/1/87 MT
473 ;Input: Command line at 80h in PSP
477 ;Output: Fatal_Error = YES/NO
481 ; Copy command line to buffer
483 ; Parse command line (Call SysParse)
486 ; IF drive letter not found (This assumes drive letter before switches)
491 ;*****************************************************************************
493 Procedure Parse_For_FS_Switch
; ;AN000;
495 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
496 mov Drive_Letter_Buffer
.Drive_Number
,Init
; ;AN000;
497 mov cx,PSP_Segment
;Get segment of PSP ;AN000;
498 mov ds,cx ; " " " " ;AN000;
501 mov si,Command_Line_Parms
;Point at command line ;AN000;
502 mov di,offset
data:Command_Line_Buffer
;Where to put a copy of it ;AN000;
503 mov cx,Command_Line_Length
;How long was input? ;AN000;
504 repnz movsb ;Copy it ;AN000;
505 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
507 xor dx,dx ;Required for SysParse call ;AN000;
508 mov si,offset Command_Line_Buffer
;Pointer to parse line ;AN000;
509 mov di,offset Switch_FS_Table
;Pointer to control table ;AN000;
510 ; $DO ;Setup parse call ;AN000;
512 call SysParse
;Go parse ;AN000;
513 cmp ax,End_Of_Parse
;Check for end of parse ;AN000;
514 ; $LEAVE E,OR ;Exit if it is end, or ;AN000;
516 cmp ax,Operand_Missing
; exit if positional missing ;AN000;
517 ; $LEAVE E ;In other words, no drive letter;AN000;
519 cmp Switch_String_Buffer
.Switch_Pointer
,offset Switch_FS_Control
.Keyword
;AN000;
520 ; $ENDDO E ;Exit if we find /FS ;AN000;
523 cmp Drive_Letter_Buffer
.Drive_Type
,Type_Drive
;Check for drive letter found;AN000;
524 ; $IF NE ;Did we not find one? ;AN000;
526 MESSAGE msgNeedDrive
;Must enter drive letter ;AN000;
527 mov Fatal_Error
,Yes
;Indicate error on exit ;AN000;
532 Parse_For_FS_Switch endp
; ;AN000;
535 ENDIF
;/FS: conditional assembly end ;an018;dms;
538 ;*****************************************************************************
539 ;Routine name: Parse_Command_Line
540 ;*****************************************************************************
542 ;Description: Parse the command line. Check for errors, and display error and
543 ; exit program if found. Use parse error messages except in case
544 ; of no parameters, which has its own message
546 ;Called Procedures: Message (macro)
550 ;Change History: Created 5/1/87 MT
552 ;Input: Fatal_Error = NO
555 ;Output: Fatal_Error = YES/NO
561 ; Assume Fatal_Error = NO on entry
563 ; EXITIF Fatal_Error = YES,OR (This can be set by Interpret_Parse)
564 ; Parse command line (CALL SysParse)
565 ; EXITIF end of parsing command line
566 ; Figure out last thing parsed (Call Interpret_Parse)
569 ; LEAVE parse error,OR
570 ; See what was parsed (Call Interpret_Parse)
571 ; LEAVE if interpret error such as bad volume label
573 ; Display parse error message and print error operand
577 ;*****************************************************************************
579 Procedure Parse_Command_Line
; ;AN000;
581 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
583 mov cx,PSP_Segment
;Get segment of PSP ;AN000;
584 mov ds,cx ; " " " " ;AN000;
586 assume
ds:nothing
,es:data
588 xor cx,cx ;Parse table @DI ;AN000;
589 xor dx,dx ;Parse line @SI ;AN000;
590 mov si,Command_Line_Parms
;Pointer to parse line ;AN000;
591 mov word ptr es:Command_Old_Ptr
,si
592 mov di,offset
es:Command_Line_Table
;Pointer to control table ;AN000;
593 ; $SEARCH ;Loop until all parsed ;AN000;
595 cmp es:Fatal_Error
,Yes
;Interpret something bad? ;AN000;
596 ; $EXITIF E,OR ;If so, don't parse any more ;AN000;
598 call SysParse
;Go parse ;AN000;
599 cmp ax,End_Of_Parse
;Check for end of parse ;AN000;
600 ; $EXITIF E ;Is it? ;AN000;
604 ; $ORELSE ;Not end ;AN000;
607 cmp ax,0 ;Check for parse error ;AN000;
608 ; $LEAVE NE ;Stop if there was one ;AN000;
610 mov word ptr es:Command_Old_Ptr
,si
611 call Interpret_Parse
;Go find what we parsed ;AN000;
612 ; $ENDLOOP ;Parse error, see what it was ;AN000;
615 mov byte ptr ds:[si],0
618 mov di,offset
es:Sublist_MsgParse_Error
619 mov ax,word ptr es:Command_Old_Ptr
620 mov word ptr es:[di+2],ax
621 mov word ptr es:[di+4],ds
624 PARSE_MESSAGE
;Display parse error ;AN000;
625 mov es:Fatal_Error
,YES
;Indicate death! ;AN000;
631 Parse_Command_Line endp
; ;AN000;
633 ;*****************************************************************************
634 ;Routine name: Interpret_Parse
635 ;*****************************************************************************
637 ;Description: Set the SwitchMap field with the switches found on the
638 ; command line. Get the drive letter. /FS will be handled before
639 ; here, will not be seen in this parse or accepted. Also, if /V
640 ; see if volume label entered and verify it is good, setting up
641 ; FCB for later create
643 ;Called Procedures: Get_11_Characters
645 ;Change History: Created 5/1/87 MT
647 ;Input: Fatal_Error = NO
649 ;Output: SwitchMap set
651 ; DriveNum set A=0,B=1 etc...
652 ; Command_Line = YES/NO
653 ; Fatal_Error = YES/NO
658 ; IF Drive letter parsed
659 ; Drive = Parsed drive number -1
660 ; DriveLetter = (Parsed drive number - 1) +'A'
663 ; or SwitchMap,Switch_1
666 ; or SwitchMap,Switch_4
669 ; or SwitchMap,Switch_8
672 ; or SwitchMap,Switch_S
675 ; or SwitchMap,Switch_BACKUP
678 ; or SwitchMap,Switch_B
681 ; or SwitchMap,Switch_T
682 ; TrackCnt = entered value
685 ; or SwitchMap,Switch_N
686 ; NumSectors = entered value
689 ; or SwitchMap,Switch_SELECT
692 ; or SwitchMap,Switch_V
694 ; Build ASCIIZ string for next call (CALL Build_String)
695 ; Verify DBCS and setup FCB (CALL Get_11_Characters)
698 ; Invalid label message
704 ; or SwitchMap,Switch_AUTOTEST
708 ; or SwitchMap,Switch_F
709 ; or Size_Map,Item_Tag
711 ; IF /Z (only if assembled)
712 ; or SwitchMap,Switch_Z
715 ;*****************************************************************************
717 Procedure Interpret_Parse
; ;AN000;
719 push ds ;Save segment ;AN000;
720 push si ;Restore SI for parser ;AN000;
723 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
724 cmp byte ptr Drive_Letter_Buffer
.Drive_Type
,Type_Drive
;Have drive letter? ;AN000;
725 ; $IF E ;Yes, save info ;AN000;
727 mov al,Drive_Letter_Buffer
.Drive_Number
;Get drive entered ;AN000;
728 dec al ;Make it 0 based ;AN000;
729 mov Drive
,al ; " " " " ;AN000;
730 add al,'A' ;Make it a drive letter ;AN000;
731 mov DriveLetter
,al ;Save it ;AN000;
734 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_1_Control
.Keyword
;;AN000;
737 mov Switch_1_Control
.Keyword
,20h
;an000; dms;remove switch from table
738 or SwitchMap
,Switch_1
; ;AN000;
741 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_4_Control
.Keyword
;;AN000;
744 mov Switch_4_Control
.Keyword
,20h
;an000; dms;remove switch from table
745 or SwitchMap
,Switch_4
; ;AN000;
748 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_8_Control
.Keyword
;;AN000;
751 mov Switch_8_Control
.Keyword
,20h
;an000; dms;remove switch from table
752 or SwitchMap
,Switch_8
; ;AN000;
755 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_S_Control
.Keyword
;;AN000;
758 mov Switch_S_Control
.Keyword
,20h
;an000; dms;remove switch from table
759 or SwitchMap
,Switch_S
; ;AN000;
762 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_Backup_Control
.Keyword
;AN000;
765 mov Switch_Backup_Control
.Keyword
,20h
;an000; dms;remove switch from table
766 or SwitchMap
,Switch_Backup
; ;AN000;
769 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_Select_Control
.Keyword
;AN000;
772 mov Switch_Select_Control
.Keyword
,20h
;an000; dms;remove switch from table
773 or SwitchMap
,Switch_Select
; ;AN000;
776 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_B_Control
.Keyword
;AN000;
779 mov Switch_B_Control
.Keyword
,20H
780 or SwitchMap
,Switch_B
; ;AN000;
783 cmp Switch_Num_Buffer
.Switch_Num_Pointer
,offset
es:Switch_T_Control
.Keyword
;AN000;
786 mov Switch_T_Control
.Keyword
,20h
;an000; dms;remove switch from table
787 mov Switch_Num_Buffer
.Switch_Num_Pointer
,0 ;Init for next switch ;AN008;
788 test SwitchMap
,Switch_T
;Don't allow if switch already ;AN002;
789 ; $IF Z ; entered ;AN002;
791 or SwitchMap
,Switch_T
; ;AN000;
792 mov ax,Switch_Num_Buffer
.Switch_Number_Low
;Get entered tracks ;AN000;
793 mov TrackCnt
,ax ;1024 or less, so always dw ;AN000;
797 Message msgSameSwitch
; ;AN002;
798 mov Fatal_Error
,Yes
; ;AN002;
803 cmp Switch_Num_Buffer
.Switch_Num_Pointer
,offset Switch_N_Control
.Keyword
;AN000;
806 mov Switch_N_Control
.Keyword
,20h
;an000; dms;remove switch from table
807 mov Switch_Num_Buffer
.Switch_Num_Pointer
,0 ;Init for next switch ;AN008;
808 test SwitchMap
,Switch_N
;Make sure switch not already ;AN002;
809 ; $IF Z ; entered ;AN002;
811 or SwitchMap
,Switch_N
; ;AN000;
812 mov ax,Switch_Num_Buffer
.Switch_Number_Low
;Get entered tracks ;AN000;
813 xor ah,ah ;clear high byte ;an000;
814 mov NumSectors
,ax ;Save tracks per sector ;AN000;
818 Message msgSameSwitch
; ;AN002;
819 mov Fatal_Error
,Yes
; ;AN002;
824 cmp Switch_String_Buffer
.Switch_String_Pointer
,offset Switch_V_Control
.Keyword
;AN000;
825 ; $IF E ;If /v and haven't already done ;AN000;
827 mov Switch_String_Buffer
.Switch_String_Pointer
,0 ;Init for next switch ;AN008;
828 mov Switch_V_Control
.Keyword
,20h
;an000; dms;remove switch from table
829 test SwitchMap
,Switch_V
; it - Only allow one /V entry ;AN002;
832 or SwitchMap
,Switch_V
;Set /v indicator ;AN000;
833 mov si,Switch_String_Buffer
.Switch_String_Seg
;Get string address ;;AN000;
838 mov si,es:Switch_String_Buffer
.Switch_String_Off
; ;AN000;
839 cmp byte ptr ds:[si],None
;Is there a string there? ;AN000;
840 ; $IF NE ;Yep ;AN000;
843 mov di,offset
es:Vol_Label_Buffer
;Point at buffer to move string;AN000;
844 mov cx,Label_Length
+1 ;Max length of string ;AN000;
845 rep movsb ;This will copy string & always ;AN000;
846 ; leave ASCIIZ end in buffer, ; ;
847 ; which is init'd to 13 dup(0) ; ;
848 mov si,offset
es:Vol_Label_Buffer
;Point at string ;AN000;
849 Set_Data_Segment
;Set DS,ES to Data segment ;AN000;
850 mov Command_Line
,YES
;Set flag indicating vol label ;AN000;
851 call Get_11_Characters
;Check DBCS and build FCB ;AN000;
852 ; $IF C ;Bad DBCS setup ;AN000;
854 Message msgBadVolumeID
;Tell user ;AN000;
855 mov es:Fatal_Error
,YES
;Indicate time to quit ;AN000;
863 Message msgSameSwitch
; ;AN002;
864 mov Fatal_Error
,Yes
; ;AN002;
869 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_Autotest_Control
.Keyword
;AN000;
872 mov Switch_Autotest_Control
.Keyword
,20h
;an000; dms;remove switch from table
873 or SwitchMap
,Switch_Autotest
; ;AN000;
879 cmp Switch_Buffer
.Switch_Pointer
,offset Switch_Z_Control
.Keyword
;an000; dms;/Z switch?
880 ; $IF E ; ;an000; dms;yes
882 mov Switch_Z_Control
.Keyword
,20h
;an000; dms;remove switch from table
883 or SwitchMap
,Switch_Z
; ;an000; dms;signal switch found
884 ; $ENDIF ; ;an000; dms;
889 cmp Switch_String_Buffer
.Switch_Pointer
,offset Switch_F_Control
.Keyword
; ;AN000;
892 mov Switch_F_Control
.Keyword
,20h
;an000; dms;remove switch from table
893 mov Switch_String_Buffer
.Switch_Pointer
,0 ;an000; dms; clear out ptr for next iteration
894 mov Switch_Num_Buffer
.Switch_Num_Pointer
,0 ;Init for next switch ;AN008;
895 test SwitchMap
,Switch_F
; it - do this because SysParse ;AN002;
896 ; $IF Z ; reuses string buffer each time;AN002;
898 or SwitchMap
,Switch_F
; ;AN000;
899 mov al,Switch_String_Buffer
.Switch_String_Item_Tag
; Indicate what size;AN000;
900 or SizeMap
,al ; ;AN000;
904 Message msgSameSwitch
; ;AN002;
905 mov Fatal_Error
,Yes
; ;AN002;
910 pop di ;Restore parse regs ;AN000;
916 Interpret_Parse endp
; ;AN000;
920 ;*****************************************************************************
921 ;Routine name: Validate_Target_Drive
922 ;*****************************************************************************
924 ;Description: Control routine for validating the specified format target drive.
925 ; If any of the called routines find an error, they will print
926 ; message and terminate program, without returning to this routine
928 ;Called Procedures: Check_Target_Drive
930 ; Check_Translate_Drive
932 ;Change History: Created 5/1/87 MT
934 ;Input: Fatal_Error = NO
936 ;Output: Fatal_Error = YES/NO
941 ; CALL Check_Target_Drive
943 ; CALL Check_For_Network
945 ; CALL Check_Translate_Drive
949 ;*****************************************************************************
951 Procedure Validate_Target_Drive
; ;AN000;
953 call Check_Target_Drive
;See if valid drive letter ;AN000;
954 cmp Fatal_Error
,YES
;Can we continue? ;AN000;
955 ; $IF NE ;Yep ;AN000;
957 call Check_For_Network
;See if Network drive letter ;AN000;
958 cmp Fatal_Error
,YES
;Can we continue? ;AN000;
959 ; $IF NE ;Yep ;AN000;
961 call Check_Translate_Drive
;See if Subst, Assigned ;AN000;
962 ; $ENDIF ;- Fatal_Error passed back ;AN000;
968 Validate_Target_Drive endp
; ;AN000;
970 ;*****************************************************************************
971 ;Routine name: Check_Target_Drive
972 ;*****************************************************************************
974 ;Description: Check to see if valid DOS drive by checking if drive is
975 ; removable. If error, the drive is invalid. Save default
978 ;Called Procedures: Message (macro)
980 ;Change History: Created 5/1/87 MT
982 ;Input: Fatal_Error = NO
984 ;Output: BIOSFile = default drive letter
985 ; DOSFile = default drive letter
986 ; CommandFile = default drive letter
987 ; Fatal_Error = YES/NO
992 ; Get default drive (INT 21h, AH = 19h)
993 ; Convert it to drive letter
994 ; Save into BIOSFile,DOSFile,CommandFile
995 ; See if drive removable (INT 21h, AX=4409h IOCtl)
996 ; IF error - drive invalid
997 ; Display Invalid drive message
1001 ;*****************************************************************************
1003 Procedure Check_Target_Drive
; ;AN000;
1005 DOS_Call Get_Default_Drive
;Find the current drive ;AC000;
1006 add al,'A' ;Convert to drive letter ; ;
1007 mov BIOSFile
,al ;Put it into path strings ; ;
1008 mov DOSFile
,al ; " " " " ; ;
1009 mov CommandFile
,al ; " " " " ; ;
1010 mov bl,Drive
;Set up for next call ;AN000;
1011 inc bl ;A=1,B=2 for IOCtl call ;AN000;
1012 mov al,09h ;See if drive is local ;AC000;
1013 DOS_Call IOCtl
;-this will fail if bad drive ;AC000;
1014 ; $IF C ;CY means invalid drive ;AC000;
1016 Extended_Message
;Print message ;AC000;
1017 mov Fatal_Error
,Yes
;Indicate error ;AN000;
1020 ret ;And we're outa here ;AN000;
1022 Check_Target_Drive endp
; ;AN000;
1024 ;*****************************************************************************
1025 ;Routine name: Check_For_Network
1026 ;*****************************************************************************
1028 ;Description: See if target drive isn't local, or if it is a shared drive. If
1029 ; so, exit with error message. The IOCtl call is not checked for
1030 ; an error because it is called previously in another routine, and
1031 ; invalid drive is the only error it can generate. That condition
1032 ; would not get this far
1034 ;Called Procedures: Message (macro)
1036 ;Change History: Created 5/1/87 MT
1041 ;Output: Fatal_Error = YES/NO
1045 ; See if drive is local (INT 21h, AX=4409 IOCtl)
1047 ; Display network message
1050 ; IF 8000h bit set on return
1051 ; Display assign message
1056 ;*****************************************************************************
1058 Procedure Check_For_Network
; ;AN000;
1060 mov bl,Drive
;Drive is 0=A, 1=B ; ;
1061 inc bl ;Get 1=A, 2=B for IOCtl call ; ;
1062 mov al,09h ;See if drive is local or remote;AC000;
1063 DOS_CALL IOCtl
;We will not check for error ;AC000;
1064 test dx,Net_Check
;if (x & 1200H)(redir or shared); ;
1065 ; $IF NZ ;Found a net drive ;AC000;
1067 Message MsgNetDrive
;Tell 'em ;AC000;
1068 mov Fatal_Error
,Yes
;Indicate bad stuff ;AN000;
1069 ; $ELSE ;Local drive, now check assign ;AN000;
1072 test dx,Assign_Check
;8000h bit is bad news ; ;
1073 ; $IF NZ ;Found it ;AC000;
1075 Message MsgAssignedDrive
;Tell error ;AC000;
1076 mov Fatal_Error
,Yes
;Indicate bad stuff ;AN000;
1083 Check_For_Network endp
; ;AN000;
1085 ;*****************************************************************************
1086 ;Routine name: Check_Translate_Drive
1087 ;*****************************************************************************
1089 ;Description: Do a name translate call on the drive letter to see if it is
1090 ; assigned by SUBST or ASSIGN
1092 ;Called Procedures: Message (macro)
1094 ;Change History: Created 5/1/87 MT
1099 ;Output: Fatal_Error = YES/NO
1103 ; Put drive letter in ASCIIZ string "d:\",0
1104 ; Do name translate call (INT 21)
1106 ; Display assigned message
1110 ;*****************************************************************************
1112 Procedure Check_Translate_Drive
; ;AN000;
1114 mov bl,Drive
;Get drive ; ;
1115 add byte ptr [TranSrc
],bl ;Make string "d:\" ; ;
1116 mov si,offset TranSrc
;Point to translate string ; ;
1117 push ds ;Set ES=DS (Data segment) ; ;
1118 pop es ; " " " " ; ;
1119 mov di,offset Command_Line_Buffer
;Point at output buffer ; ;
1120 DOS_Call xNameTrans
;Get real path ;AC000;
1121 mov bl,byte ptr [TranSrc
] ;Get drive letter from path ; ;
1122 cmp bl,byte ptr Command_Line_Buffer
;Did drive letter change? ; ;
1123 ; $IF NE ;If not the same, it be bad ;AC000;
1125 Message MsgAssignedDrive
;Tell user ;AC000;
1126 mov Fatal_Error
,Yes
;Setup error flag ;AN000;
1131 Check_Translate_Drive endp
; ;AN000;
1133 ;*****************************************************************************
1134 ;Routine name: Hook_CNTRL_C
1135 ;*****************************************************************************
1137 ;Description: Change the interrupt handler for INT 13h to point to the
1138 ; ControlC_Handler routine
1140 ;Called Procedures: None
1142 ;Change History: Created 4/21/87 MT
1151 ; Point at ControlC_Handler routine
1152 ; Set interrupt handler (INT 21h, AX=2523h)
1154 ;*****************************************************************************
1156 Procedure Hook_CNTRL_C
; ;AN000;
1158 mov al,23H
;Specify CNTRL handler ; ;
1159 mov dx, offset ControlC_Handler
;Point at it ; ;
1160 push ds ;Save data seg ; ;
1161 push cs ;Point to code segment ; ;
1163 DOS_Call Set_Interrupt_Vector
;Set the INT 23h handler ;AC000;
1164 pop ds ;Get Data degment back ; ;
1167 Hook_CNTRL_C endp
; ;AN000;
1169 ;=========================================================================
1170 ; Check_For_Invalid_Drive : This routine checks the AX received by
1171 ; FORMAT on its entry. This value will
1172 ; tell us if we are attempting to format
1175 ; Inputs : Org_AX - AX on entry to FORMAT
1177 ; Outputs : Fatal_Error - Yes if AL contained FFh
1178 ;=========================================================================
1180 Procedure Check_For_Invalid_Drive
;an000; dms;
1182 push ax ;an000; dms;save ax
1183 cmp FAT_Flag
,Yes
;an000; dms;FAT system?
1184 ; $if e ;an000; dms;yes
1186 mov ax,Org_AX
;an000; dms;get its org. value
1187 cmp al,0ffh ;an000; dms;Invalid drive?
1188 ; $if e ;an000; dms;yes
1190 mov Fatal_Error
,YES
;an000; dms;flag an error
1191 mov ax,Invalid_Drive
;an000; dms;error message
1192 Extended_Message
;an000; dms;tell error
1193 ; $endif ;an000; dms;
1195 ; $endif ;an000; dms;
1200 Check_For_Invalid_Drive endp
;an000; dms;
1203 ;=========================================================================
1204 ; Determine_FAT_Non_FAT - This routine determines whether or
1205 ; not a device is formatted to a FAT
1206 ; specification versus a Non-FAT
1209 ; Inputs : DX - Pointer to device parameters buffer
1211 ; Outputs : DeviceParameters - buffer containing BPB.
1214 ;=========================================================================
1216 Procedure Determine_FAT_Non_FAT
;an012; dms;
1218 push ax ;an012; dms;save regs
1219 push dx ;an012; dms;
1221 lea dx, deviceParameters
;an012; dms;point to buffer
1222 mov deviceParameters
.DP_SpecialFunctions
, 0 ;an012; dms;get default BPB
1223 call GetDeviceParameters
;an012; dms;make the call
1224 ; $if nc ;an012; dms;no error occurred
1226 cmp byte ptr DeviceParameters
.DP_BPB
.BPB_NumberOfFATS
,00h ;an012; dms;non-FAT system?
1227 ; $if e ;an012; dms;yes
1229 mov FAT_Flag
,No
;an012; dms;signal system non-FAT
1230 mov ax,5f07h
;an012; dms;allow access to disk
1231 mov dl,Drive
;an012; dms;get 0 based driver number
1232 int 21h
;an012; dms;allow access to the drive
1233 ; $else ;an012; dms;FAT system
1236 mov FAT_Flag
,Yes
;an012; dms;flag FAT system
1237 ; $endif ;an012; dms;
1239 ; $endif ;an012; dms;
1242 pop dx ;an012; dms;restore regs
1247 Determine_FAT_Non_FAT endp
;an012; dms;