3 ;*****************************************************************************
4 ;*****************************************************************************
6 ;UTILITY NAME: FORMAT.COM
8 ;MODULE NAME: FORLABEL.SAL
13 ;³ÚÄÄÄÄÄ¿ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿|ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
14 ;À´VolIDôGet_New_LabelÃÄ´Get_11_CharactersôChange_Blanks³
15 ; ÀÄÄÄÄÄÙÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
19 ; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
20 ; ôCheck_DBCS_OverrunôCheck_DBCS_Character³
21 ; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
25 ;*****************************************************************************
26 ;*****************************************************************************
28 data segment public para
'DATA'
31 code segment public para
'CODE'
32 assume
cs:code,ds:data
44 ;*****************************************************************************
46 ;*****************************************************************************
54 Label_Buffer_length equ 80h
55 Create_Worked equ
0 ;an024;
59 ;*****************************************************************************
60 ; External Data Declarations
61 ;*****************************************************************************
65 Extrn Switch_String_Buffer
:Byte
67 Extrn MsgBadCharacters
:Byte
68 Extrn MsgLabelPrompt
:Byte
69 Extrn MsgBadVolumeID
:Byte
72 Extrn Vol_Label_Count
:Byte
75 Extrn Command_Line
:Byte
76 Extrn Vol_Label_Buffer
:Byte
80 code segment public para
'CODE'
82 ;************************************************************************************************
84 ;************************************************************************************************
86 ;Description: Get volume id from command line /V:xxxxxxx if it is there, or
87 ; else prompt user for volume label, parse the input. At this
88 ; point setup the FCB and create the volume label. If failure,
89 ; prompt user that they entered bad input, and try again.
91 ; Note: This routine in 3.30 and prior used to check for /V
92 ; switch. Volume labels are always required now, so /V
93 ; is ignored, except to get volume label on command line.
95 ;Called Procedures: Message (macro)
98 ;Change History: Created 5/1/87 MT
101 ; Command_Line = YES/NO
109 ; IF /V switch entered
110 ; IF /v:xxxxx form not entered
111 ; CALL Get_New_Label ;Return string in Volume_Label
114 ; CALL Get_New_Label ;Return string in Volume_Label
117 ; Create volume label
119 ; Display Bad Character message
120 ; CALL Get_New_Label ;Return string in Volume_Label
124 ;*****************************************************************************
126 Procedure Volid
; ;AN000;
128 push ds ;Save registers ;AN000;
129 push si ; " " " " ;AN000;
130 test SwitchMap
,Switch_V
;Was /V entered ;AN000;
131 ; $IF NZ ;Yes, see if label entered also ;AN000;
133 cmp Command_Line
,YES
;Is there a string there? ;AN000;
134 ; $IF NE ;Nope ;AN000;
136 call Get_New_Label
;Go get volume label from user ;AN000;
139 ; $ELSE ;Label not entered on cmd line ;AN000;
142 call Get_New_Label
;Go get label from user ;AN000;
145 mov dl,drive
;Get drive number A=0 ;AN000;
146 inc dl ;Make it 1 based ;AN000;
147 mov DelDrive
,dl ;Put into FCBs ;AN000;
148 mov VolDrive
,dl ; ;AN000;
149 mov dx,offset DelFCB
;Point at FCB to delete label ;AN000;
150 DOS_Call FCB_Delete
;Do the delete ;AN000;
151 mov dx,offset VolFCB
;Point at FCB for create ;AN000;
152 DOS_CALL FCB_Create
;Go create it ;AN000;
153 cmp dl,Create_Worked
;See if the create worked ;an024;
156 mov dx,offset VolFCB
;Point to the FCB created ;an022; dms;
157 DOS_Call FCB_Close
;Close the newly created FCB ;an022; dms;
161 pop si ;Restore registers ;AN000;
162 pop ds ; " " " " ;AN000;
167 ;*****************************************************************************
168 ;Routine name: Get_New_Label
169 ;*****************************************************************************
171 ;Description: Prompts, inputs and verifies a volume label string. Continues
172 ; to prompt until valid vol label is input
174 ;Called Procedures: Message (macro)
178 ;Change History: Created 3/18/87 MT
182 ;Output: Volume_Label holds
188 ; Display new volume label prompt
191 ; Build Asciiz string with label, pointer DS:SI (CALL Build_String)
192 ; Call Get_11_Characters (Error returned CY)
194 ; LEAVE no error (NC)
195 ; Display label error
198 ;*****************************************************************************
200 Procedure Get_New_Label
; ;AN000;
202 ; $DO ;Loop until we get good one ;AN000;
204 Message msgLabelPrompt
;Prompt to input Vol label ;AN000;
205 mov ax,(Std_Con_Input_Flush
shl 8) + 0 ;an000; dms;clean out input
207 mov dx,offset Vol_Label_Count
;an000; dms;beginning of buffer
208 mov ah,Std_Con_String_Input
;an000; dms;get input
210 mov ax,(Std_Con_Input_Flush
shl 8) + 0 ;an000; dms; clean out input
212 ; $IF NC ;Read ok if NC, Bad sets CY ;AN000;
214 mov si,offset Vol_Label_Buffer
;Get pointer to string ;AN000;
215 call Get_11_Characters
;Handle DBCS stuff on input ;AN000;
216 ; $ENDIF ;Ret CY if error ;AN000;
218 ; $LEAVE NC ;Done if NC ;AN000;
220 Message MsgCRLF
;next line ;an020; dms;
221 Message msgBadVolumeID
;Tell user error ;AN000;
222 ; $ENDDO ;Try again ;AN000;
225 Message MsgCRLF
;an000; dms;next line
228 Get_New_Label endp
; ;AN000;
230 ;*****************************************************************************
231 ;Routine name: Get_11_Characters
232 ;*****************************************************************************
234 ;Description: Handle DBCS considerations, and build FCB to create vol label
237 ;Called Procedures: Change_Blanks
242 ;Change History: Created 5/12/87 MT
244 ;Input: DS:SI = Asciiz string containing volume label input
245 ; Command_Line = YES/NO
247 ;Output: Volname will contain an 8.3 volume label in FCB
248 ; CY set on invalid label
253 ; Scan line replacing all DBCS blanks with SBCS (CALL_Change_Blanks)
254 ; Skip over leading blanks (Call Skip_Blanks)
255 ; IF leading blanks ,AND
257 ; Indicate invalid label (STC)
259 ; See if DBCS character at 11th byte (CALL Check_DBCS_Overrun)
260 ; IF DBCS character at 11th byte
261 ; Indicate invalid label (STC)
263 ; Put string into FCB (CALL Copy_FCB_STRING)
269 ;*****************************************************************************
271 Procedure Get_11_Characters
; ;AN000;
273 call Change_Blanks
;Change DBCS blanks to SBCS ;AN000;
274 call Skip_Blanks
;Skip over leading blanks ;AN000;
275 ; $IF C,AND ;Find leading blanks? ;AN000;
277 cmp Command_Line
,YES
;Is this command line input? ;AN000;
280 stc ;Indicate error (CY set) ;AN000;
281 ; $ELSE ;Leading blanks ok ;AN000;
284 call Check_DBCS_Overrun
;Is DBCS char at 11th byte? ;AN000;
287 stc ;Indicate invalid label ;AN000;
288 ; $ELSE ;No, good characters ;AN000;
291 call Copy_FCB_String
;Put string into FCB ;AN000;
292 clc ;Indicate everything A-OK! ;AN000;
299 Get_11_Characters endp
; ;AN000;
301 ;*****************************************************************************
302 ;Routine name: Change_Blanks
303 ;*****************************************************************************
305 ;Description: Replace all DBCS blanks with SBCS blanks, end string with
306 ; Asciiz character if one doesn't already exist
308 ;Called Procedures: Check_DBCS_Character
310 ;Change History: Created 6/12/87 MT
312 ;Input: DS:SI = String containing volume label input
314 ;Output: DS:SI = ASCIIZ string with all DBCS blanks replaced with 2 SBCS blanks
320 ; Save pointer to string
322 ; LEAVE End of string (0)
323 ; See if DBCS character (Check_DBCS_Character)
324 ; IF CY (DBCS char found)
325 ; IF first byte DBCS blank, AND
326 ; IF second byte DBCS blank
327 ; Convert to SBCS blanks
329 ; Point to next byte to compensate for DBCS character
332 ; Tack on ASCIIZ character to string
333 ; Restore pointer to string
335 ;*****************************************************************************
337 Procedure Change_Blanks
; ;AN000;
339 push si ;Save pointer to string ;AN000;
343 ; $DO ;Do while not CR ;AN000;
345 cmp byte ptr [si],Asciiz_End
;Is it end of string? ;AN000;
346 ; $LEAVE E,OR ;All done if so ;AN000;
348 cmp byte ptr [si],CR
;Is it CR? ;AN000;
349 ; $LEAVE E,OR ;Exit if yes,end of label ;AN000;
351 inc cx ;Count the character ;AN000;
352 cmp cx,Label_Buffer_Length
;Reached max chars? (80h) ;AN000;
353 ; $LEAVE E ;Exit if so ;AN000;
355 mov al,byte ptr [si] ;Get char to test for DBCS ;AN000;
356 call Check_DBCS_Character
;Test for dbcs lead byte ;AN000;
357 ; $IF C ;We have a lead byte ;AN000;
359 cmp byte ptr [si],DBCS
;Is it a lead blank? ;AN000;
360 ; $IF E,AND ;If a dbcs char ;AN000;
362 cmp byte ptr [si+1],DBCS_Blank
;Is it an Asian blank? ;AN000;
363 ; $IF E ;If an Asian blank ;AN000;
365 mov byte ptr [si+1],Blank
;set up moves ;AN000;
366 mov byte ptr [si],Blank
; to replace ;AN000;
369 inc si ;Point to dbcs char ;AN000;
370 ; $ENDIF ;End lead byte test ;AN000;
372 inc si ;Point to si+1 ;AN000;
373 ; $ENDDO ;End do while ;AN000;
376 mov byte ptr [si],Asciiz_End
;Mark end of string ;AN000;
377 pop ax ;Restore regs ;AN000;
380 ret ;return to caller ;AN000;
382 Change_Blanks endp
; ;AN000;
384 ;*****************************************************************************
385 ;Routine name: Skip_Blanks
386 ;*****************************************************************************
388 ;Description: Scan ASCIIZ string for leading blanks, return pointer to first
389 ; non-blank character. Set CY if blanks found
391 ;Called Procedures: None
393 ;Change History: Created 6/12/87 MT
395 ;Input: DS:SI = ASCIIZ string containing volume label input
397 ;Output: DS:SI = Input string starting at first non-blank character
398 ; CY set if blanks found
405 ; Save original pointer, DI register
407 ; Look at character from string
408 ; LEAVE End of string (0)
409 ; IF character is blank,OR
410 ; IF character is tab
418 ; Cmp string pointer to original pointer
425 ;*****************************************************************************
427 Procedure Skip_Blanks
; ;AN000;
429 push di ;Preserve DI, just in case ;AN000;
430 push si ;Save pointer to string ;AN000;
431 ; $DO ;Look at entire ASCIIZ string ;AN000;
433 cmp byte ptr [si],ASCIIZ_End
;End of string? ;AN000;
434 ; $LEAVE E ;Yep, exit loop ;AN000;
436 cmp byte ptr [si],Blank
;Find a blank? ;AN000;
437 ; $IF E,OR ;Yes ;AN000;
439 cmp byte ptr [si],TAB
;Is it tab? ;AN000;
443 inc si ;Bump pointer to next character ;AN000;
444 clc ;Indicate found blank ;AN000;
445 ; $ELSE ;Not blank or tab ;AN000;
448 stc ;Force exit ;AN000;
451 ; $ENDDO C ;Go look at next character ;AN000;
454 pop di ;Get back original pointer ;AN000;
455 cmp di,si ;Are they the same? ;AN000;
456 ; $IF NE ;If not equal blanks were found ;AN000;
459 ; $ELSE ;No leading blanks found ;AN000;
462 clc ;Clear CY ;AN000;
465 pop di ;Restore DI ;AN000;
468 Skip_Blanks endp
; ;AN000;
471 ;*****************************************************************************
472 ;Routine name: Copy_FCB_String
473 ;*****************************************************************************
475 ;Description: Build an 11 character string in the FCB from ASCIIZ string
476 ; If nothing entered, than terminated with 0. Also add drive
479 ;Called Procedures: None
481 ;Change History: Created 6/12/87 MT
483 ;Input: DS:SI = String containing volume label input
485 ;Output: VOLNAM is filled in with Volume label string
493 ; Init VolNam to blanks
495 ; LEAVE if character is end of ASCIIZ string
496 ; Mov character to FCB
498 ; ENDDO all 11 chars done
500 ;*****************************************************************************
502 Procedure Copy_FCB_String
; ;AN000;
506 push si ;Save pointer to string ;AN000;
507 cld ;Set string direction to up ;AN000;
508 mov di,offset Volnam
;Init FCB field to blanks ;AN000;
509 mov al,Blank
; " " " " ;AN000;
510 mov cx,Label_Length
; " " " " ;AN000;
511 rep stosb ; " " " " ;AN000;
512 pop si ;Get back pointer to string ;AN000;
513 mov di,offset VolNam
;Point at FCB field ;AN000;
514 xor cx,cx ;Init counter ;AN000;
515 ; $DO ;Copy characters over ;AN000;
517 cmp byte ptr [si],ASCIIZ_End
;End of String? ;AN000;
518 ; $LEAVE E ;Yes, don't copy - leave blanks ;AN000;
520 movsb ;Nope, copy character ;AN000;
521 inc cx ;Bump up count ;AN000;
522 cmp cx,Label_Length
;Have we moved 11? ;AN000;
523 ; $ENDDO E ;Quit if so ;AN000;
530 Copy_FCB_String endp
; ;AN000;
533 ;*****************************************************************************
534 ;Routine name: Check_DBCS_Overrun
535 ;*****************************************************************************
537 ;Description: Check 11th byte, if the string is that long, to see
538 ; if it is a DBCS character that is split down the middle. Must
539 ; scan entire string to properly find DBCS characters, due to
540 ; the fact a second byte of a DBCS character can fall into
541 ; the range of the first byte environment vector, and thus look
542 ; like a DBCS char when it really isn't
544 ;Called Procedures: Check_DBCS_Character
546 ;Change History: Created 6/12/87 MT
548 ;Input: DS:SI = String containing volume label input
550 ;Output: CY set if DBCS character at bytes 11-12 in string
552 ;*****************************************************************************
554 Procedure Check_DBCS_Overrun
; ;AN000;
556 push si ;Save pointer ;AN000;
557 push ax ;Save registers ;AN000;
558 push cx ; " " " " ;AN000;
559 mov cx,si ;Get start of string ;AN000;
560 add cx,Label_Length
;Find where to check for overrun;AN000;
562 Check_DBCS_OverRun_Cont: ;Scan string for DBCS chars ;AN000;
564 cmp byte ptr [si],ASCIIZ_End
;End of string? ;AN000;
565 je DBCS_Good_Exit
;Yep ;AN000;
567 mov al,[si] ;Get character for routine ;AN000;
568 call Check_DBCS_Character
;See if DBCS leading character ;AN000;
569 ; $if c ;DBCS if CY set ;AN000;
571 inc si ;Next byte to handle DBCS ;AN000;
572 cmp si,cx ;Is DBCS char spanning 11-12? ;AN000;
573 ; $if e ;truncate string
575 mov byte ptr [si-1],20h
;blank it out
576 mov byte ptr [si],20h
;blank it out
577 jmp DBCS_Good_Exit
;exit
580 ; $else ;Not DBCS character ;an000; dms;
583 mov al,[si] ;Get character for routine ;an000; dms;
584 call Scan_For_Invalid_Char
;See if invalid vol ID char ;an000; dms;
585 jc DBCS_Bad_Exit
;Bad char entered - exit ;an000; dms;
586 ; $endif ; ;an000; dms;
589 inc si ;Point to next character ;an000; dms;
590 jmp Check_DBCS_OverRun_Cont
;Continue looping ;an000; dms;
594 clc ;Signal no error ;an000; dms;
595 jmp DBCS_Exit
;Exit routine ;an000; dms;
597 DBCS_Bad_Exit: ;an000; dms;
599 stc ;Signal error ;an000; dms;
601 DBCS_Exit: ;an000; dms;
603 pop cx ;Restore registers ;AN000;
604 pop ax ; " " " " ;AN000;
605 pop si ;Restore string pointer ;AN000;
608 Check_DBCS_Overrun endp
; ;AN000;
610 ;*****************************************************************************
611 ;Routine name: Check_DBCS_Character
612 ;*****************************************************************************
614 ;Description: Check if specified byte is in ranges of DBCS vectors
616 ;Called Procedures: None
618 ;Change History: Created 6/12/87 MT
620 ;Input: AL = Character to check for DBCS lead character
621 ; DBCS_Vector = YES/NO
623 ;Output: CY set if DBCS character
630 ; IF DBCS vector not found
631 ; Get DBCS environmental vector (INT 21h
632 ; Point at first set of vectors
635 ; LEAVE End of DBCS vectors
636 ; EXITIF Character > X1,AND (X1,Y1) are environment vectors
637 ; EXITIF Character < Y1
638 ; STC (DBCS character)
640 ; Inc pointer to next set of vectors
642 ; CLC (Not DBCS character)
646 ;*****************************************************************************
648 Procedure Check_DBCS_Character
; ;AN000;
650 push ds ;Save registers ;AN000;
651 push si ; " " " " ;AN000;
652 push ax ; " " " " ;AN000;
653 push ds ; " " " " ;AN000;
654 pop es ;Establish addressability ;AN000;
655 cmp byte ptr es:DBCS_VECTOR
,Yes
;Have we set this yet? ;AN000;
656 push ax ;Save input character ;AN000;
657 ; $IF NE ;Nope ;AN000;
659 mov al,0 ;Get DBCS environment vectors ;AN000;
660 DOS_Call Hongeul
; " " " " ;AN000;
661 mov byte ptr es:DBCS_VECTOR
,YES
;Indicate we've got vector ;AN000;
662 mov es:DBCS_Vector_Off
,si ;Save the vector ;AN000;
664 mov es:DBCS_Vector_Seg
,ax ; ;AN000;
665 ; $ENDIF ; for next time in ;AN000;
667 pop ax ;Restore input character ;AN000;
668 mov si,es:DBCS_Vector_Seg
;Get saved vector pointer ;AN000;
670 mov si,es:DBCS_Vector_Off
; ;AN000;
671 ; $SEARCH ;Check all the vectors ;AN000;
673 cmp word ptr ds:[si],End_Of_Vector
;End of vector table? ;AN000;
674 ; $LEAVE E ;Yes, done ;AN000;
676 cmp al,ds:[si] ;See if char is in vector ;AN000;
677 ; $EXITIF AE,AND ;If >= to lower, and ;AN000;
679 cmp al,ds:[si+1] ; =< than higher range ;AN000;
680 ; $EXITIF BE ; then DBCS character ;AN000;
682 stc ;Set CY to indicate DBCS ;AN000;
683 ; $ORELSE ;Not in range, check next ;AN000;
686 add si,DBCS_Vector_Size
;Get next DBCS vector ;AN000;
687 ; $ENDLOOP ;We didn't find DBCS char ;AN000;
690 clc ;Clear CY for exit ;AN000;
693 pop ax ;Restore registers ;AN000;
694 pop si ; " " " " ;AN000;
695 pop ds ;Restore data segment ;AN000;
698 Check_DBCS_Character endp
; ;AN000;
700 ;=========================================================================
701 ; Scan_For_Invalid_Char : This routine scans the bad character table
702 ; to determine if the referenced character is
705 ; Inputs : Bad_Char_Table - Table of bad characters
706 ; Bad_Char_Table_Len - Length of table
707 ; AL - Character to be searched for
709 ; Outputs : CY - Bad character
710 ; NC - Character good
711 ;=========================================================================
713 Procedure Scan_For_Invalid_Char
;an000; dms;
715 push ax ;an000; dms;save ax
716 push cx ;an000; dms;save cx
717 push di ;an000; dms;save di
719 lea di,Bad_Char_Table
;an000; dms;point to bad character table
720 mov cx,Bad_Char_Table_Len
;an000; dms;get its length
721 repnz scasb ;an000; dms;scan the table
722 cmp cx,0000h ;an000; dms;did we find the character
723 ; $if e ;an000; dms;no - a good character
725 clc ;an000; dms;flag a good character
726 ; $else ;an000; dms;yes - a bad character
729 stc ;an000; dms;flag a bad character
730 ; $endif ;an000; dms;
733 pop di ;an000; dms;restore di
734 pop cx ;an000; dms;restore cx
735 pop ax ;an000; dms;restore ax
739 Scan_For_Invalid_Char endp
;an000; dms;
744 data segment public para
'DATA'
746 Bad_Char_Table
label byte ;an000; dms;table of invalid vol ID chars
764 Bad_Char_Table_Len equ $-Bad_Char_Table;an000; dms;length of table
766 DBCS_Vector_Off dw 0 ;
767 DBCS_Vector_Seg dw 0 ;