     1                                  
     2                                  ;*****************************************************************************
     3                                  ;*****************************************************************************
     4                                  ;
     5                                  ;UTILITY NAME: FORMAT.COM
     6                                  ;
     7                                  ;MODULE NAME: FORLABEL.SAL
     8                                  ;
     9                                  ;		Interpret_Parse
    10                                  ;			|
    11                                  ;*			|
    12                                  ;=======================|=================== ===============
    13                                  ;==VolID==Get_New_Label===Get_11_Characters===Change_Blanks=
    14                                  ; ====================== ===================================
    15                                  ;					    ==============
    16                                  ;					    ==Skip_Blanks=
    17                                  ;					    ==============
    18                                  ;					    ===========================================
    19                                  ;					    ==Check_DBCS_Overrun==Check_DBCS_Character=
    20                                  ;					    ===========================================
    21                                  ;					    ==================
    22                                  ;					    ==Copy_FCB_String=
    23                                  ;					     =================
    24                                  ;*****************************************************************************
    25                                  ;*****************************************************************************
    26                                  
    27                                  section data public align=16 class=DATA
    28                                  ; (no prior section) ; data	ends
    29                                  
    30                                  section code public align=16 class=CODE
    31                                  	assume	cs:code,ds:data
    32                                  ; (no prior section) ; code	ends
    33                                  
    34                                  [list -]
   134                              <1> 
    36                                  %include "formacro.mac"
     1                              <1> ;
     2                              <1> ;******************************************************************************
     3                              <1> ; Message Macro Definitions
     4                              <1> ;******************************************************************************
     5                              <1> ;
     6                              <1> 
     7                              <1>       EXTRN Display_Interface:near
     8                              <1> 
     9                              <1> 
    10                              <1> ; NASM original macros
    11                              <1> 
    12                              <1> ;-----------------------------------------------------------------------------
    13                              <1> 
    14                              <1> %imacro Message 1.nolist
    15                              <1>         mov     dx,offset %1 wrt data
    16                              <1>         call    Display_Interface
    17                              <1> %endmacro
    18                              <1> 
    19                              <1> ;-----------------------------------------------------------------------------
    20                              <1> 
    21                              <1> %imacro Parse_Message 0.nolist
    22                              <1>         push    ds
    23                              <1>         mov     dx,data
    24                              <1>         mov     ds,dx
    25                              <1>         mov     word ptr [Parse_Error_Msg],ax
    26                              <1>         mov     dx,offset Parse_Error_Msg       ;                               ;AN000;
    27                              <1>         call    Display_Interface               ;                               ;AN000;
    28                              <1>         pop     ds                              ;
    29                              <1> %endmacro
    30                              <1> 
    31                              <1> ;-----------------------------------------------------------------------------
    32                              <1> 
    33                              <1> %imacro Extended_Message 0.nolist
    34                              <1>         push    ds
    35                              <1>         mov     dx,data
    36                              <1>         mov     ds,dx
    37                              <1>         mov     word ptr [Extended_Error_Msg],ax
    38                              <1>         mov     dx,offset Extended_Error_Msg wrt data
    39                              <1>         call    Display_Interface               ;                               ;AN000;
    40                              <1>         pop     ds
    41                              <1> %endmacro
    42                              <1> 
    43                              <1> ;
    44                              <1> ;*****************************************************************************
    45                              <1> ; General Macro's
    46                              <1> ;*****************************************************************************
    47                              <1> ;
    48                              <1> 
    49                              <1> %imacro Procedure 1.nolist
    50                              <1> %1    proc
    51                              <1> Public  %1
    52                              <1> %endmacro
    53                              <1> 
    54                              <1> ;-----------------------------------------------------------------------------
    55                              <1> 
    56                              <1> %imacro DOS_Call 1.nolist
    57                              <1>         mov     ah, %1
    58                              <1>         int     21h
    59                              <1> %endmacro
    60                              <1> ;-----------------------------------------------------------------------------
    61                              <1> 
    62                              <1> %imacro Popff 0.nolist
    63                              <1>         jmp strict short $+3
    64                              <1>         iret
    65                              <1>         push cs
    66                              <1>         call near $-2
    67                              <1> %endmacro
    68                              <1> 
    69                              <1> ;-----------------------------------------------------------------------------
    70                              <1> 
    71                              <1> %imacro Set_Data_Segment 0.nolist
    72                              <1>         push    ax
    73                              <1>         mov     ax,data                         ;Point to data segment
    74                              <1>         mov     ds,ax                           ;
    75                              <1>         push    ds
    76                              <1>         pop     es
    77                              <1>         pop     ax
    78                              <1> assume  ds:data,es:data
    79                              <1> %endmacro
    80                              <1> 
    81                              <1> ; end of NASM original macros
    37                                  %include "syscall.mac"
     1                              <1> ;	SCCSID = @(#)syscall.asm	1.1 85/04/10
     2                              <1> ;BREAK <system call definitions>
     3                              <1> ;SUBTTL	system call definitions
     4                              <1> ;PAGE
     5                              <1> 
     6                              <1> Abort				EQU 0	;  0	  0
     7                              <1> Std_Con_Input			EQU 1	;  1	  1
     8                              <1> Std_Con_Output			EQU 2	;  2	  2
     9                              <1> Std_Aux_Input			EQU 3	;  3	  3
    10                              <1> Std_Aux_Output			EQU 4	;  4	  4
    11                              <1> Std_Printer_Output		EQU 5	;  5	  5
    12                              <1> Raw_Con_IO			EQU 6	;  6	  6
    13                              <1> Raw_Con_Input			EQU 7	;  7	  7
    14                              <1> Std_Con_Input_No_Echo		EQU 8	;  8	  8
    15                              <1> Std_Con_String_Output		EQU 9	;  9	  9
    16                              <1> Std_Con_String_Input		EQU 10	; 10	  A
    17                              <1> Std_Con_Input_Status		EQU 11	; 11	  B
    18                              <1> Std_Con_Input_Flush		EQU 12	; 12	  C
    19                              <1> Disk_Reset			EQU 13	; 13	  D
    20                              <1> Set_Default_Drive		EQU 14	; 14	  E
    21                              <1> FCB_Open			EQU 15	; 15	  F
    22                              <1> FCB_Close			EQU 16	; 16	 10
    23                              <1> Dir_Search_First		EQU 17	; 17	 11
    24                              <1> Dir_Search_Next 		EQU 18	; 18	 12
    25                              <1> FCB_Delete			EQU 19	; 19	 13
    26                              <1> FCB_Seq_Read			EQU 20	; 20	 14
    27                              <1> FCB_Seq_Write			EQU 21	; 21	 15
    28                              <1> FCB_Create			EQU 22	; 22	 16
    29                              <1> FCB_Rename			EQU 23	; 23	 17
    30                              <1> Get_Default_Drive		EQU 25	; 25	 19
    31                              <1> Set_DMA 			EQU 26	; 26	 1A
    32                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
    33                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    34                              <1> ;									   ;
    35                              <1> Get_Default_DPB 		EQU 31	; 31	 1F
    36                              <1> ;									   ;
    37                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    38                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
    39                              <1> FCB_Random_Read 		EQU 33	; 33	 21
    40                              <1> FCB_Random_Write		EQU 34	; 34	 22
    41                              <1> Get_FCB_File_Length		EQU 35	; 35	 23
    42                              <1> Get_FCB_Position		EQU 36	; 36	 24
    43                              <1> Set_Interrupt_Vector		EQU 37	; 37	 25
    44                              <1> Create_Process_Data_Block	EQU 38	; 38	 26
    45                              <1> FCB_Random_Read_Block		EQU 39	; 39	 27
    46                              <1> FCB_Random_Write_Block		EQU 40	; 40	 28
    47                              <1> Parse_File_Descriptor		EQU 41	; 41	 29
    48                              <1> Get_Date			EQU 42	; 42	 2A
    49                              <1> Set_Date			EQU 43	; 43	 2B
    50                              <1> Get_Time			EQU 44	; 44	 2C
    51                              <1> Set_Time			EQU 45	; 45	 2D
    52                              <1> Set_Verify_On_Write		EQU 46	; 46	 2E
    53                              <1> ; Extended functionality group
    54                              <1> Get_DMA 			EQU 47	; 47	 2F
    55                              <1> Get_Version			EQU 48	; 48	 30
    56                              <1> Keep_Process			EQU 49	; 49	 31
    57                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
    58                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    59                              <1> ;									   ;
    60                              <1> Get_DPB 			EQU 50	; 50	 32
    61                              <1> ;									   ;
    62                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    63                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
    64                              <1> Set_CTRL_C_Trapping		EQU 51	; 51	 33
    65                              <1> Get_InDOS_Flag			EQU 52	; 52	 34
    66                              <1> Get_Interrupt_Vector		EQU 53	; 53	 35
    67                              <1> Get_Drive_Freespace		EQU 54	; 54	 36
    68                              <1> Char_Oper			EQU 55	; 55	 37
    69                              <1> International			EQU 56	; 56	 38
    70                              <1> ;   Directory Group
    71                              <1> MKDir				EQU 57	; 57	 39
    72                              <1> RMDir				EQU 58	; 58	 3A
    73                              <1> CHDir				EQU 59	; 59	 3B
    74                              <1> ;   File Group
    75                              <1> Creat				EQU 60	; 60	 3C
    76                              <1> Open				EQU 61	; 61	 3D
    77                              <1> Close				EQU 62	; 62	 3E
    78                              <1> Read				EQU 63	; 63	 3F
    79                              <1> Write				EQU 64	; 64	 40
    80                              <1> Unlink				EQU 65	; 65	 41
    81                              <1> LSeek				EQU 66	; 66	 42
    82                              <1> CHMod				EQU 67	; 67	 43
    83                              <1> IOCtl				EQU 68	; 68	 44
    84                              <1> XDup				EQU 69	; 69	 45
    85                              <1> XDup2				EQU 70	; 70	 46
    86                              <1> Current_Dir			EQU 71	; 71	 47
    87                              <1> ;    Memory Group
    88                              <1> Alloc				EQU 72	; 72	 48
    89                              <1> Dealloc 			EQU 73	; 73	 49
    90                              <1> Setblock			EQU 74	; 74	 4A
    91                              <1> ;    Process Group
    92                              <1> Exec				EQU 75	; 75	 4B
    93                              <1> Exit				EQU 76	; 76	 4C
    94                              <1> WaitProcess			EQU 77	; 77	 4D
    95                              <1> Find_First			EQU 78	; 78	 4E
    96                              <1> ;   Special Group
    97                              <1> Find_Next			EQU 79	; 79	 4F
    98                              <1> ; SPECIAL SYSTEM GROUP
    99                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   100                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   101                              <1> ;									   ;
   102                              <1> Set_Current_PDB 		EQU 80	; 80	 50
   103                              <1> Get_Current_PDB 		EQU 81	; 81	 51
   104                              <1> Get_In_Vars			EQU 82	; 82	 52
   105                              <1> SetDPB				EQU 83	; 83	 53
   106                              <1> ;									   ;
   107                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   108                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   109                              <1> Get_Verify_On_Write		EQU 84	; 84	 54
   110                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   111                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   112                              <1> ;									   ;
   113                              <1> Dup_PDB 			EQU 85	; 85	 55
   114                              <1> ;									   ;
   115                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   116                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   117                              <1> Rename				EQU 86	; 86	 56
   118                              <1> File_Times			EQU 87	; 87	 57
   119                              <1> AllocOper			EQU 88	; 88	 58
   120                              <1> ; Network extention system calls
   121                              <1> GetExtendedError		EQU 89	; 89	 59
   122                              <1> CreateTempFile			EQU 90	; 90	 5A
   123                              <1> CreateNewFile			EQU 91	; 91	 5B
   124                              <1> LockOper			EQU 92	; 92	 5C Lock and Unlock
   125                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   126                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   127                              <1> ;									   ;
   128                              <1> ServerCall			EQU 93	; 93	 5D CommitAll, ServerDOSCall,
   129                              <1> 					;	    CloseByName, CloseUser,
   130                              <1> 					;	    CloseUserProcess,
   131                              <1> 					;	    GetOpenFileList
   132                              <1> ;									   ;
   133                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   134                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   135                              <1> UserOper			EQU 94	; 94	 5E Get and Set
   136                              <1> AssignOper			EQU 95	; 95	 5F On, Off, Get, Set, Cancel
   137                              <1> xNameTrans			EQU 96	; 96	 60
   138                              <1> PathParse			EQU 97	; 97	 61
   139                              <1> GetCurrentPSP			EQU 98	; 98	 62
   140                              <1> Hongeul 			EQU 99	; 99	 63
   141                              <1> ECS_CALL			EQU 99	; 99	 63  ;; DBCS support
   142                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   143                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   144                              <1> ;									   ;
   145                              <1> Set_Printer_Flag		EQU 100 ; 100	 64
   146                              <1> ;									   ;
   147                              <1> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
   148                              <1> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   149                              <1> GetExtCntry			EQU 101 ; 101	 65
   150                              <1> GetSetCdPg			EQU 102 ; 102	 66
   151                              <1> ExtHandle			EQU 103 ; 103	 67
   152                              <1> Commit				EQU 104 ; 104	 68
   153                              <1> GetSetMediaID			EQU 105 ; 105	 69
   154                              <1> IFS_IOCTL			EQU 107 ; 107	 6B
   155                              <1> ExtOpen 			EQU 108 ; 108	 6C
   156                              <1> ;
   157                              <1> ;
   158                              <1> Set_Oem_Handler 		EQU 248 ; 248	 F8
   159                              <1> OEM_C1				EQU 249 ; 249	 F9
   160                              <1> OEM_C2				EQU 250 ; 250	 FA
   161                              <1> OEM_C3				EQU 251 ; 251	 FB
   162                              <1> OEM_C4				EQU 252 ; 252	 FC
   163                              <1> OEM_C5				EQU 253 ; 253	 FD
   164                              <1> OEM_C6				EQU 254 ; 254	 FE
   165                              <1> OEM_C7				EQU 255 ; 255	 FF
    38                                  %include "forequ.mac"
     1                              <1> ;                               ;     ;
     2                              <1> 
     3                              <1> NO      equ     0
     4                              <1> YES     equ     ~ NO
     5                              <1> FSExec  equ     NO                              ;an018; dms;conditional assembly
     6                              <1> ShipDisk equ    NO                              ;an000; dms;ship disk flag
     7                              <1> 
     8                              <1> Boot_ID equ   0AA55h
     9                              <1> DOS_Found equ   0
    10                              <1> 
    11                              <1> Not_Include     equ     0
    12                              <1> Do_Include         equ     1
    13                              <1> 
    14                              <1> INIT    equ     0
    15                              <1> 
    16                              <1> FAT12_File_System equ 01h
    17                              <1> FAT16_File_System equ 04h
    18                              <1> New_File_System equ 06h
    19                              <1> 
    20                              <1> FS_String_Max_Length    equ     5
    21                              <1> 
    22                              <1> Paragraph_Size  equ     16                      ;                               ;AN005;
    23                              <1> Len_FS_String_Buffer    equ     13
    24                              <1> 
    25                              <1> Net_Check equ   1200h
    26                              <1> Assign_Check equ 8000h
    27                              <1> 
    28                              <1> Found_Yes equ   1
    29                              <1> Found_No equ    0
    30                              <1> 
    31                              <1> Asciiz_End equ  0
    32                              <1> DBCS    equ     81h
    33                              <1> DBCS_Blank equ  40h
    34                              <1> DBCS_Vector_Size equ 2
    35                              <1> End_Of_Vector equ 0
    36                              <1> 
    37                              <1> 
    38                              <1> Blank   equ     " "
    39                              <1> 
    40                              <1> Label_Length equ 11
    41                              <1> CR      equ     13
    42                              <1> 
    43                              <1> DBCS_VECTOR equ NO
    44                              <1> 
    45                              <1> ;Limits
    46                              <1> BIG_FAT_THRESHOLD equ 4086
    47                              <1> 
    48                              <1> ;-------------------------------------------------------------------------------
    49                              <1> 
    50                              <1> 
    51                              <1> 
    52                              <1> 
    53                              <1> 
    54                              <1> DRNUM   EQU     5CH
    55                              <1> 
    56                              <1> 
    57                              <1> 
    58                              <1> ; Exit status defines
    59                              <1> ExitOK  equ     0
    60                              <1> ExitCtrlC equ   3
    61                              <1> ExitFatal equ   4
    62                              <1> ExitNo  equ     5
    63                              <1> 
    64                              <1> 
    65                              <1> ;-------------------------------------------------------------------------------
    66                              <1> ; These are the data structures which we will need
    67                              <1> 
    68                              <1> 
    69                              <1> Media_ID struc
    70 00000000 ????                <1> Media_ID_Info_Level dw ?
    71 00000002 ????????            <1> Media_ID_Serial_Number dd ?
    72 00000006 <res Bh>            <1> Media_ID_Volume_Label db 11 dup(?)
    73 00000011 ????????????????    <1> Media_ID_File_System db 8 dup(?)
    74                              <1> Media_ID ends
    75                              <1> 
    76                              <1> 
    77                              <1> Relative_Sector_Buffer  struc                   ;                               ;AN000;
    78                              <1> 
    79 00000000 ????                <1> Start_Sector_Low        dw      ?               ;Low word of RBA sector         ;AN000;
    80 00000002 ????                <1> Start_Sector_High       dw      ?               ;High word of RBA sector        ;AN000;
    81 00000004 ????                <1> Number_Sectors          dw      ?               ;Number of sectors              ;AN000;
    82 00000006 ????                <1> Buffer_Offset           dw      ?               ;Address of data buffer         ;AN000;
    83 00000008 ????                <1> Buffer_Segment          dw      ?               ;                               ;AN000;
    84                              <1> 
    85                              <1> Relative_Sector_Buffer ends                     ;                               ;AN000;
    86                              <1> 
    87                              <1> 
    88                              <1> ;Per system file data structure
    89                              <1> 
    90                              <1> a_FileStructure struc
    91 00000000 ????                <1> fileHandle DW   ?
    92 00000002 ????                <1> fileSizeInParagraphs DW ?
    93 00000004 ????????            <1> fileSizeInBytes DD ?
    94 00000008 ????????            <1> fileOffset DD   ?
    95 0000000C ????                <1> fileStartSegment DW ?
    96 0000000E ????                <1> fileDate DW     ?
    97 00000010 ????                <1> fileTime DW     ?
    98                              <1> a_FileStructure ends
    99                              <1> 
   100                              <1> ;-------------------------------------------------------------------------------
   101                              <1> 
   102                              <1> LOGBOOTSECT equ 1
   103                              <1> Set_Drv_Owner equ 0Fh                           ; IOCTL subfunction
   104                              <1> Custom_Media equ 0F0H                           ; Media byte for custom format
   105                              <1> Dual_8_Media equ 0FFh                           ; Dual sided 8 sectored
   106                              <1> Single_8_Media equ 0FEh                         ; Single sided 8 sectored
   107                              <1> Dual_9_Media equ 0FDh                           ; Dual sided 9 sectored
   108                              <1> Single_9_Media equ 0FCh                         ; Single sided 9 sectored
   109                              <1> Dual_15_Media equ 0F9h                          ; Dual sided 15 sectored
   110                              <1> Fixed_Disk equ  0F8h                            ; Fixed Disk
   111                              <1> Invalid_Drive   equ     000Fh                   ; Extended error 15
   112                              <1> Max_Format_Size equ     0FFFFh                  ; Max bytes to Format           ;an015; dms;
   113                              <1> Multi_Track_Format      equ     02h             ; Multi-track format            ;an015; dms;
   114                              <1> Single_Track_Format     equ     00h             ; Single track format           ;an015; dms;
   115                              <1> Select_Disk_Message     equ     0ADC1h          ; an016; dms;
    39                                  %include "forswtch.mac"
     1                              <1> ;FORMAT Pre-defined switches
     2                              <1>  SWITCH_S EQU		0001h			   ; System transfer
     3                              <1>  SWITCH_V EQU		0002h			   ; Volume ID prompt
     4                              <1>  SWITCH_BACKUP EQU	0004h
     5                              <1>  SWITCH_C EQU		0008h
     6                              <1>  SWITCH_T EQU		0010h
     7                              <1>  SWITCH_N EQU		0020h
     8                              <1>  SWITCH_1 EQU		0040h
     9                              <1>  SWITCH_4 EQU		0080h
    10                              <1>  SWITCH_8 EQU		0100h
    11                              <1>  SWITCH_B EQU		0200h
    12                              <1>  SWITCH_SELECT	EQU	0400h
    13                              <1>  SWITCH_AUTOTEST EQU	0800h
    14                              <1>  SWITCH_F	EQU	1000h
    15                              <1>  SWITCH_FS	EQU	2000h
    16                              <1> 
    17                              <1> %IF ShipDisk
    18                              <1> 
    19                              <1>  SWITCH_Z	EQU	4000h							;an000; dms;1 sector/cluster switch
    20                              <1> 
    21                              <1> %ENDIF
    22                              <1> 
    23                              <1> ;
    24                              <1> ; The following is a list of equates to define each IBM defined diskette size
    25                              <1> ; for use with the /F switch
    26                              <1> 
    27                              <1> 
    28                              <1> Size_160	equ	0001h			;Flag settings for size switch	;AN000;
    29                              <1> Size_180	equ	0002h			;				;AN000;
    30                              <1> Size_320	equ	0004h			;				;AN000;
    31                              <1> Size_360	equ	0008h			;				;AN000;
    32                              <1> Size_720	equ	0010h			;				;AN000;
    33                              <1> Size_1200	equ	0020h			;				;AN000;
    34                              <1> Size_1440	equ	0040h			;				;AN000;
    35                              <1> 
    36                              <1> 
    37                              <1> 
    40                                  [list +]
    41                                  
    42                                  ;
    43                                  ;*****************************************************************************
    44                                  ; Equates
    45                                  ;*****************************************************************************
    46                                  ;
    47                                  
    48                                  None	equ	0
    49                                  StdIn	equ	0
    50                                  StdOut	equ	1
    51                                  StdErr	equ	2
    52                                  Tab	equ	09h
    53                                  Label_Buffer_length equ 80h
    54                                  Create_Worked equ 0								;an024;
    55                                  
    56                                  
    57                                  ;
    58                                  ;*****************************************************************************
    59                                  ; External Data Declarations
    60                                  ;*****************************************************************************
    61                                  ;
    62                                  
    63                                  	Extrn	SwitchMap:Word
    64                                  	Extrn	Switch_String_Buffer:Byte
    65                                  	Extrn	VolFCB:Byte
    66                                  	Extrn	MsgBadCharacters:Byte
    67                                  	Extrn	MsgLabelPrompt:Byte
    68                                  	Extrn	MsgBadVolumeID:Byte
    69                                  	Extrn	MsgCRLF:Byte
    70                                  	Extrn	VolNam:Byte
    71                                  	Extrn	Vol_Label_Count:Byte
    72                                  	Extrn	VolDrive:Byte
    73                                  	Extrn	Drive:Byte
    74                                  	Extrn	Command_Line:Byte
    75                                  	Extrn	Vol_Label_Buffer:Byte
    76                                  	Extrn	DelDrive:Byte
    77                                  	Extrn	DelFCB:Byte
    78                                  
    79                                  section code
    80                                  
    81                                  ;************************************************************************************************
    82                                  ;Routine name Volid
    83                                  ;************************************************************************************************
    84                                  ;
    85                                  ;Description: Get volume id from command line /V:xxxxxxx if it is there, or
    86                                  ;	      else prompt user for volume label, parse the input. At this
    87                                  ;	      point setup the FCB and create the volume label. If failure,
    88                                  ;	      prompt user that they entered bad input, and try again.
    89                                  ;
    90                                  ;	      Note: This routine in 3.30 and prior used to check for /V
    91                                  ;		    switch. Volume labels are always required now, so /V
    92                                  ;		    is ignored, except to get volume label on command line.
    93                                  ;
    94                                  ;Called Procedures: Message (macro)
    95                                  ;		    Get_New_Label
    96                                  ;
    97                                  ;Change History: Created	5/1/87	       MT
    98                                  ;
    99                                  ;Input: Switch_V
   100                                  ;	Command_Line = YES/NO
   101                                  ;
   102                                  ;Output: None
   103                                  ;
   104                                  ;Psuedocode
   105                                  ;----------
   106                                  ;
   107                                  ;	Save registers
   108                                  ;	IF /V switch entered
   109                                  ;	   IF /v:xxxxx form not entered
   110                                  ;	      CALL Get_New_Label     ;Return string in Volume_Label
   111                                  ;	   ENDIF
   112                                  ;	ELSE
   113                                  ;	   CALL Get_New_Label	  ;Return string in Volume_Label
   114                                  ;	ENDIF
   115                                  ;	DO
   116                                  ;	   Create volume label
   117                                  ;	LEAVE Create Ok
   118                                  ;	   Display Bad Character message
   119                                  ;	   CALL Get_New_Label	;Return string in Volume_Label
   120                                  ;	ENDDO
   121                                  ;	Restore registers
   122                                  ;	ret
   123                                  ;*****************************************************************************
   124                                  
   125                                  Procedure Volid 				;				;AN000;
   126                                  
   127 00000000 1E                      	push	ds				;Save registers 		;AN000;
   128 00000001 56                      	push	si				; "  "	  "  "			;AN000;
   129                                  Switch_V equ SWITCH_V	; NASM port equate
   130 00000002 F706[0000]0200          	test	word [SwitchMap],Switch_V		;Was /V entered 		 ;AN000;
   131                                  ;	$IF	NZ				;Yes, see if label entered also ;AN000;
   132 00000008 740C                    	JZ DD_IF1
   133 0000000A 803E[0000]FF            	   cmp	   byte [Command_Line],YES		;Is there a string there?	;AN000;
   134                                  ;	   $IF	   NE				;Nope				;AN000;
   135 0000000F 7403                    	   JE DD_IF2
   136 00000011 E83000                  	      call    Get_New_Label		;Go get volume label from user	;AN000;
   137                                  ;	   $ENDIF				;				;AN000;
   138                                  DD_IF2:
   139                                  ;	$ELSE					;Label not entered on cmd line	;AN000;
   140 00000014 EB03                    	JMP SHORT DD_EN1
   141                                  DD_IF1:
   142 00000016 E82B00                  	   call    Get_New_Label		;Go get label from user 	;AN000;
   143                                  ;	$ENDIF					;				;AN000;
   144                                  DD_EN1:
   145                                  drive equ Drive	; NASM port label
   146 00000019 8A16[0000]              	mov	dl,[drive]			;Get drive number  A=0		;AN000;
   147 0000001D FEC2                    	inc	dl				;Make it 1 based		;AN000;
   148 0000001F 8816[0000]              	mov	[DelDrive],dl			;Put into FCBs			;AN000;
   149 00000023 8816[0000]              	mov	[VolDrive],dl			;				;AN000;
   150 00000027 BA[0000]                	mov	dx,offset DelFCB		;Point at FCB to delete label	;AN000;
   151 0000002A B413CD21                	DOS_Call FCB_Delete			;Do the delete			;AN000;
   152 0000002E BA[0000]                	mov	dx,offset VolFCB		;Point at FCB for create	;AN000;
   153 00000031 B416CD21                	DOS_CALL FCB_Create			;Go create it			;AN000;
   154 00000035 80FA00                  	cmp	dl,Create_Worked		;See if the create worked	;an024;
   155                                  ;	$IF	E								;an024;
   156 00000038 7507                    	JNE DD_IF6
   157 0000003A BA[0000]                	   mov	   dx,offset VolFCB		;Point to the FCB created	;an022; dms;
   158 0000003D B410CD21                	   DOS_Call FCB_Close			;Close the newly created FCB	;an022; dms;
   159                                  ;	$ENDIF									;an024;
   160                                  DD_IF6:
   161                                  
   162 00000041 5E                      	pop	si				;Restore registers		;AN000;
   163 00000042 1F                      	pop	ds				; "  "	   "  " 		;AN000;
   164 00000043 C3                      	ret					;				;AN000;
   165                                  
   166                                  Volid	endp					;				;AN000;
   167                                  
   168                                  ;*****************************************************************************
   169                                  ;Routine name: Get_New_Label
   170                                  ;*****************************************************************************
   171                                  ;
   172                                  ;Description: Prompts, inputs and verifies a volume label string. Continues
   173                                  ;	      to prompt until valid vol label is input
   174                                  ;
   175                                  ;Called Procedures: Message (macro)
   176                                  ;		    Build_String
   177                                  ;		    Get_11_Characters
   178                                  ;
   179                                  ;Change History: Created	3/18/87 	MT
   180                                  ;
   181                                  ;Input: None
   182                                  ;
   183                                  ;Output: Volume_Label holds
   184                                  ;
   185                                  ;Psuedocode
   186                                  ;----------
   187                                  ;
   188                                  ;	DO
   189                                  ;	   Display  new volume label prompt
   190                                  ;	   Input vol label
   191                                  ;	   IF No error (NC)
   192                                  ;	      Build Asciiz string with label, pointer DS:SI (CALL Build_String)
   193                                  ;	      Call Get_11_Characters (Error returned CY)
   194                                  ;	   ENDIF
   195                                  ;	LEAVE no error (NC)
   196                                  ;	   Display label error
   197                                  ;	ENDDO
   198                                  ;	ret
   199                                  ;*****************************************************************************
   200                                  
   201                                  Procedure Get_New_Label 			;				;AN000;
   202                                  
   203                                  ;	$DO					;Loop until we get good one	;AN000;
   204                                  DD_DO8:
   205                                  msgLabelPrompt equ MsgLabelPrompt	; NASM port label
   206 00000044 BA[0000]E8(0000)        	   Message msgLabelPrompt		;Prompt to input Vol label	;AN000;
   207 0000004A B8000C                  	   mov	ax,(Std_Con_Input_Flush << 8) + 0 ;an000; dms;clean out input
   208 0000004D CD21                    	   int	21h				;an000; dms;
   209 0000004F BA[0000]                	   mov	dx,offset Vol_Label_Count	;an000; dms;beginning of buffer
   210 00000052 B40A                    	   mov	ah,Std_Con_String_Input 	;an000; dms;get input
   211 00000054 CD21                    	   int	21h				;an000; dms;
   212 00000056 B8000C                  	   mov	ax,(Std_Con_Input_Flush << 8) + 0 ;an000; dms; clean out input
   213 00000059 CD21                    	   int	21h				;an000; dms;
   214                                  ;	   $IF	   NC				;Read ok if NC, Bad sets CY	;AN000;
   215 0000005B 7206                    	   JC DD_IF9
   216 0000005D BE[0000]                	      mov     si,offset Vol_Label_Buffer ;Get pointer to string 	 ;AN000;
   217 00000060 E81700                  	      call    Get_11_Characters 	;Handle DBCS stuff on input	;AN000;
   218                                  ;	   $ENDIF				;Ret CY if error		;AN000;
   219                                  DD_IF9:
   220                                  ;	$LEAVE	NC				;Done if NC			;AN000;
   221 00000063 730E                    	JNC DD_EN8
   222 00000065 BA[0000]E8(0000)        	   Message MsgCRLF			;next line			;an020; dms;
   223                                  msgBadVolumeID equ MsgBadVolumeID	; NASM port label
   224 0000006B BA[0000]E8(0000)        	   Message msgBadVolumeID		;Tell user error		;AN000;
   225                                  ;	$ENDDO					;Try again			;AN000;
   226 00000071 EBD1                    	JMP SHORT DD_DO8
   227                                  DD_EN8:
   228 00000073 BA[0000]E8(0000)        	Message MsgCRLF 			;an000; dms;next line
   229 00000079 C3                      	ret					;				;AN000;
   230                                  
   231                                  Get_New_Label endp				;				;AN000;
   232                                  
   233                                  ;*****************************************************************************
   234                                  ;Routine name: Get_11_Characters
   235                                  ;*****************************************************************************
   236                                  ;
   237                                  ;Description: Handle DBCS considerations, and build FCB to create vol label
   238                                  ;
   239                                  ;
   240                                  ;Called Procedures: Change_Blanks
   241                                  ;		    Skip_Blanks
   242                                  ;		    Check_DBCS_Overrun
   243                                  ;		    Copy_FCB_String
   244                                  ;
   245                                  ;Change History: Created	5/12/87 	MT
   246                                  ;
   247                                  ;Input: DS:SI = Asciiz string containing volume label input
   248                                  ;	Command_Line = YES/NO
   249                                  ;
   250                                  ;Output: Volname will contain an 8.3 volume label in FCB
   251                                  ;	 CY set on invalid label
   252                                  ;
   253                                  ;Psuedocode
   254                                  ;----------
   255                                  ;	Save regs used
   256                                  ;	Scan line replacing all DBCS blanks with SBCS  (CALL_Change_Blanks)
   257                                  ;	Skip over leading blanks (Call Skip_Blanks)
   258                                  ;	IF leading blanks ,AND
   259                                  ;	IF Command line
   260                                  ;	   Indicate invalid label (STC)
   261                                  ;	ELSE
   262                                  ;	   See if DBCS character at 11th byte (CALL Check_DBCS_Overrun)
   263                                  ;	   IF DBCS character at 11th byte
   264                                  ;	      Indicate invalid label (STC)
   265                                  ;	   ELSE
   266                                  ;	   Put string into FCB (CALL Copy_FCB_STRING)
   267                                  ;	   CLC
   268                                  ;	   ENDIF
   269                                  ;	ENDIF
   270                                  ;	Restore regs
   271                                  ;	ret
   272                                  ;*****************************************************************************
   273                                  
   274                                  Procedure Get_11_Characters			;				;AN000;
   275                                  
   276 0000007A E81C00                  	call	Change_Blanks			;Change DBCS blanks to SBCS	;AN000;
   277 0000007D E85300                  	call	Skip_Blanks			;Skip over leading blanks	;AN000;
   278                                  ;	$IF	C,AND				;Find leading blanks?		;AN000;
   279 00000080 730A                    	JNC DD_IF13
   280 00000082 803E[0000]FF            	cmp	byte [Command_Line],YES		;Is this command line input?	;AN000;
   281                                  ;	$IF	E				;Yes				;AN000;
   282 00000087 7503                    	JNE DD_IF13
   283 00000089 F9                      	   stc					;Indicate error (CY set)	;AN000;
   284                                  ;	$ELSE					;Leading blanks ok		;AN000;
   285 0000008A EB0C                    	JMP SHORT DD_EN13
   286                                  DD_IF13:
   287 0000008C E88A00                  	   call    Check_DBCS_Overrun		;Is DBCS char at 11th byte?	;AN000;
   288                                  ;	   $IF	   C				;Yes				;AN000;
   289 0000008F 7303                    	   JNC DD_IF15
   290 00000091 F9                      	      stc				;Indicate invalid label 	;AN000;
   291                                  ;	   $ELSE				;No, good characters		;AN000;
   292 00000092 EB04                    	   JMP SHORT DD_EN15
   293                                  DD_IF15:
   294 00000094 E85F00                  	      call    Copy_FCB_String		;Put string into FCB		;AN000;
   295 00000097 F8                      	      clc				;Indicate everything A-OK!	;AN000;
   296                                  ;	   $ENDIF				;				;AN000;
   297                                  DD_EN15:
   298                                  ;	$ENDIF					;				;AN000;
   299                                  DD_EN13:
   300 00000098 C3                      	ret					;				;AN000;
   301                                  
   302                                  Get_11_Characters endp				;				;AN000;
   303                                  
   304                                  ;*****************************************************************************
   305                                  ;Routine name: Change_Blanks
   306                                  ;*****************************************************************************
   307                                  ;
   308                                  ;Description: Replace all DBCS blanks with SBCS blanks, end string with
   309                                  ;	      Asciiz character if one doesn't already exist
   310                                  ;
   311                                  ;Called Procedures: Check_DBCS_Character
   312                                  ;
   313                                  ;Change History: Created	6/12/87 	MT
   314                                  ;
   315                                  ;Input: DS:SI = String containing volume label input
   316                                  ;
   317                                  ;Output: DS:SI = ASCIIZ string with all DBCS blanks replaced with 2 SBCS blanks
   318                                  ;
   319                                  ;
   320                                  ;Psuedocode
   321                                  ;----------
   322                                  ;
   323                                  ;	Save pointer to string
   324                                  ;	DO
   325                                  ;	LEAVE End of string (0)
   326                                  ;	   See if DBCS character (Check_DBCS_Character)
   327                                  ;	   IF CY (DBCS char found)
   328                                  ;	      IF first byte DBCS blank, AND
   329                                  ;	      IF second byte DBCS blank
   330                                  ;		 Convert to SBCS blanks
   331                                  ;	      ENDIF
   332                                  ;	      Point to next byte to compensate for DBCS character
   333                                  ;	   ENDIF
   334                                  ;	ENDDO
   335                                  ;	Tack on ASCIIZ character to string
   336                                  ;	Restore pointer to string
   337                                  ;
   338                                  ;*****************************************************************************
   339                                  
   340                                  Procedure Change_Blanks 			;				;AN000;
   341                                  
   342 00000099 56                      	push	si				;Save pointer to string 	;AN000;
   343 0000009A 51                      	push	cx				;				;AN000;
   344 0000009B 50                      	push	ax				;				;AN000;
   345 0000009C 31C9                    	xor	cx,cx				;				;AN000;
   346                                  ;	$DO					;Do while not CR		;AN000;
   347                                  DD_DO19:
   348 0000009E 803C00                  	   cmp	   byte ptr [si],Asciiz_End	;Is it end of string?		;AN000;
   349                                  ;	$LEAVE	E,OR				;All done if so 		;AN000;
   350 000000A1 7429                    	JE DD_EN19
   351 000000A3 803C0D                  	   cmp	   byte ptr [si],CR		;Is it CR?			;AN000;
   352                                  ;	$LEAVE	E,OR				;Exit if yes,end of label	;AN000;
   353 000000A6 7424                    	JE DD_EN19
   354 000000A8 41                      	   inc	   cx				;Count the character		;AN000;
   355                                  Label_Buffer_Length equ Label_Buffer_length	; NASM port equate
   356 000000A9 81F98000                	   cmp	   cx,Label_Buffer_Length	;Reached max chars? (80h)	;AN000;
   357                                  ;	$LEAVE	E				;Exit if so			;AN000;
   358 000000AD 741D                    	JE DD_EN19
   359 000000AF 8A04                    	   mov	   al,byte ptr [si]		;Get char to test for DBCS	;AN000;
   360 000000B1 E89D00                  	   call    Check_DBCS_Character 	;Test for dbcs lead byte	;AN000;
   361                                  ;	   $IF	   C				;We have a lead byte		;AN000;
   362 000000B4 7313                    	   JNC DD_IF21
   363 000000B6 803C81                  	      cmp     byte ptr [si],DBCS	;Is it a lead blank?		;AN000;
   364                                  ;	      $IF     E,AND			;If a dbcs char 		;AN000;
   365 000000B9 750D                    	      JNE DD_IF22
   366 000000BB 807C0140                	      cmp     byte ptr [si+1],DBCS_Blank ;Is it an Asian blank? 	;AN000;
   367                                  ;	      $IF     E 			;If an Asian blank		;AN000;
   368 000000BF 7507                    	      JNE DD_IF22
   369 000000C1 C6440120                		 mov	 byte ptr [si+1],Blank	;set up moves			;AN000;
   370 000000C5 C60420                  		 mov	 byte ptr [si],Blank	;  to replace			;AN000;
   371                                  ;	      $ENDIF				;				;AN000;
   372                                  DD_IF22:
   373 000000C8 46                      	      inc     si			;Point to dbcs char		;AN000;
   374                                  ;	   $ENDIF				;End lead byte test		;AN000;
   375                                  DD_IF21:
   376 000000C9 46                      	   inc	   si				;Point to si+1			;AN000;
   377                                  ;	$ENDDO					;End do while			;AN000;
   378 000000CA EBD2                    	JMP SHORT DD_DO19
   379                                  DD_EN19:
   380 000000CC C60400                  	mov	byte ptr [si],Asciiz_End	;Mark end of string		;AN000;
   381 000000CF 58                      	pop	ax				;Restore regs			;AN000;
   382 000000D0 59                      	pop	cx				;				;AN000;
   383 000000D1 5E                      	pop	si				;				;AN000;
   384 000000D2 C3                      	ret					;return to caller		;AN000;
   385                                  
   386                                  Change_Blanks endp				;				;AN000;
   387                                  
   388                                  ;*****************************************************************************
   389                                  ;Routine name: Skip_Blanks
   390                                  ;*****************************************************************************
   391                                  ;
   392                                  ;Description: Scan ASCIIZ string for leading blanks, return pointer to first
   393                                  ;	      non-blank character. Set CY if blanks found
   394                                  ;
   395                                  ;Called Procedures: None
   396                                  ;
   397                                  ;Change History: Created	6/12/87 	MT
   398                                  ;
   399                                  ;Input: DS:SI = ASCIIZ string containing volume label input
   400                                  ;
   401                                  ;Output: DS:SI = Input string starting at first non-blank character
   402                                  ;	 CY set if blanks found
   403                                  ;
   404                                  ;
   405                                  ;
   406                                  ;Psuedocode
   407                                  ;----------
   408                                  ;
   409                                  ;	Save original pointer, DI register
   410                                  ;	DO
   411                                  ;	  Look at character from string
   412                                  ;	LEAVE End of string (0)
   413                                  ;	  IF character is blank,OR
   414                                  ;	  IF character is tab
   415                                  ;	     INC pointer (SI)
   416                                  ;	     Indicate blank
   417                                  ;	  ELSE
   418                                  ;	     Indicate non-blank
   419                                  ;	  ENDIF
   420                                  ;	ENDDO non-blank
   421                                  ;	Get back pointer
   422                                  ;	Cmp string pointer to original pointer
   423                                  ;	IF NE
   424                                  ;	   STC
   425                                  ;	ELSE
   426                                  ;	   CLC
   427                                  ;	ENDIF
   428                                  ;	ret
   429                                  ;*****************************************************************************
   430                                  
   431                                  Procedure Skip_Blanks				;				;AN000;
   432                                  
   433 000000D3 57                      	push	di				;Preserve DI, just in case	;AN000;
   434 000000D4 56                      	push	si				;Save pointer to string 	;AN000;
   435                                  ;	$DO					;Look at entire ASCIIZ string	;AN000;
   436                                  DD_DO26:
   437                                  ASCIIZ_End equ Asciiz_End	; NASM port equate
   438 000000D5 803C00                  	   cmp	   byte ptr [si],ASCIIZ_End	;End of string? 		;AN000;
   439                                  ;	$LEAVE	E				;Yep, exit loop 		;AN000;
   440 000000D8 7411                    	JE DD_EN26
   441 000000DA 803C20                  	   cmp	   byte ptr [si],Blank		;Find a blank?			;AN000;
   442                                  ;	   $IF	   E,OR 			;Yes				;AN000;
   443 000000DD 7405                    	   JE DD_LL28
   444                                  TAB equ Tab	; NASM port equate
   445 000000DF 803C09                  	   cmp	   byte ptr [si],TAB		;Is it tab?			;AN000;
   446                                  ;	   $IF	   E				;Yes				;AN000;
   447 000000E2 7504                    	   JNE DD_IF28
   448                                  DD_LL28:
   449 000000E4 46                      	      inc     si			;Bump pointer to next character ;AN000;
   450 000000E5 F8                      	      clc				;Indicate found blank		;AN000;
   451                                  ;	   $ELSE				;Not blank or tab		;AN000;
   452 000000E6 EB01                    	   JMP SHORT DD_EN28
   453                                  DD_IF28:
   454 000000E8 F9                      	      stc				;Force exit			;AN000;
   455                                  ;	   $ENDIF				;				;AN000;
   456                                  DD_EN28:
   457                                  ;	$ENDDO	C				;Go look at next character	;AN000;
   458 000000E9 73EA                    	JNC DD_DO26
   459                                  DD_EN26:
   460 000000EB 5F                      	pop	di				;Get back original pointer	;AN000;
   461 000000EC 39F7                    	cmp	di,si				;Are they the same?		;AN000;
   462                                  ;	$IF	NE				;If not equal blanks were found ;AN000;
   463 000000EE 7403                    	JE DD_IF32
   464 000000F0 F9                      	   stc					;Set CY 			;AN000;
   465                                  ;	$ELSE					;No leading blanks found	;AN000;
   466 000000F1 EB01                    	JMP SHORT DD_EN32
   467                                  DD_IF32:
   468 000000F3 F8                      	   clc					;Clear CY			;AN000;
   469                                  ;	$ENDIF					;				;AN000;
   470                                  DD_EN32:
   471 000000F4 5F                      	pop	di				;Restore DI			;AN000;
   472 000000F5 C3                      	ret					;				;AN000;
   473                                  
   474                                  Skip_Blanks endp				;				;AN000;
   475                                  
   476                                  
   477                                  ;*****************************************************************************
   478                                  ;Routine name: Copy_FCB_String
   479                                  ;*****************************************************************************
   480                                  ;
   481                                  ;Description: Build an 11 character string in the FCB from ASCIIZ string
   482                                  ;	      If nothing entered, than terminated with 0. Also add drive
   483                                  ;	      number in FCB
   484                                  ;
   485                                  ;Called Procedures: None
   486                                  ;
   487                                  ;Change History: Created	6/12/87 	MT
   488                                  ;
   489                                  ;Input: DS:SI = String containing volume label input
   490                                  ;
   491                                  ;Output: VOLNAM is filled in with Volume label string
   492                                  ;
   493                                  ;
   494                                  ;
   495                                  ;Psuedocode
   496                                  ;----------
   497                                  ;
   498                                  ;	Save regs
   499                                  ;	Init VolNam to blanks
   500                                  ;	DO
   501                                  ;	LEAVE if character is end of ASCIIZ string
   502                                  ;	   Mov character to FCB
   503                                  ;	   Inc counter
   504                                  ;	ENDDO all 11 chars done
   505                                  ;	Restore regs
   506                                  ;*****************************************************************************
   507                                  
   508                                  Procedure Copy_FCB_String			;				;AN000;
   509                                  
   510 000000F6 57                      	push	di				;				;AN000;
   511 000000F7 51                      	push	cx				;				;AN000;
   512 000000F8 56                      	push	si				;Save pointer to string 	;AN000;
   513 000000F9 FC                      	cld					;Set string direction to up	;AN000;
   514                                  Volnam equ VolNam	; NASM port label
   515 000000FA BF[0000]                	mov	di,offset Volnam		;Init FCB field to blanks	;AN000;
   516 000000FD B020                    	mov	al,Blank			; "  "	  "  "			;AN000;
   517 000000FF B90B00                  	mov	cx,Label_Length 		; "  "	  "  "			;AN000;
   518 00000102 F3AA                    	rep	stosb				; "  "	  "  "			;AN000;
   519 00000104 5E                      	pop	si				;Get back pointer to string	;AN000;
   520 00000105 BF[0000]                	mov	di,offset VolNam		;Point at FCB field		;AN000;
   521 00000108 31C9                    	xor	cx,cx				;Init counter			;AN000;
   522                                  ;	$DO					;Copy characters over		;AN000;
   523                                  DD_DO35:
   524 0000010A 803C00                  	   cmp	   byte ptr [si],ASCIIZ_End	;End of String? 		;AN000;
   525                                  ;	$LEAVE	E				;Yes, don't copy - leave blanks ;AN000;
   526 0000010D 7407                    	JE DD_EN35
   527 0000010F A4                      	   movsb				;Nope, copy character		;AN000;
   528 00000110 41                      	   inc	   cx				;Bump up count			;AN000;
   529 00000111 83F90B                  	   cmp	   cx,Label_Length		;Have we moved 11?		;AN000;
   530                                  ;	$ENDDO	E				;Quit if so			;AN000;
   531 00000114 75F4                    	JNE DD_DO35
   532                                  DD_EN35:
   533 00000116 59                      	pop	cx				;				;AN000;
   534 00000117 5F                      	pop	di				;				;AN000;
   535 00000118 C3                      	ret					;				;AN000;
   536                                  
   537                                  Copy_FCB_String endp				;				;AN000;
   538                                  
   539                                  
   540                                  ;*****************************************************************************
   541                                  ;Routine name: Check_DBCS_Overrun
   542                                  ;*****************************************************************************
   543                                  ;
   544                                  ;Description: Check 11th byte, if the string is that long, to see
   545                                  ;	      if it is a DBCS character that is split down the middle. Must
   546                                  ;	      scan entire string to properly find DBCS characters, due to
   547                                  ;	      the fact a second byte of a DBCS character can fall into
   548                                  ;	      the range of the first byte environment vector, and thus look
   549                                  ;	      like a DBCS char when it really isn't
   550                                  ;
   551                                  ;Called Procedures: Check_DBCS_Character
   552                                  ;
   553                                  ;Change History: Created	6/12/87 	MT
   554                                  ;
   555                                  ;Input: DS:SI = String containing volume label input
   556                                  ;
   557                                  ;Output: CY set if DBCS character at bytes 11-12 in string
   558                                  ;
   559                                  ;*****************************************************************************
   560                                  
   561                                  Procedure Check_DBCS_Overrun			;				;AN000;
   562                                  
   563 00000119 56                      	push	si				;Save pointer			;AN000;
   564 0000011A 50                      	push	ax				;Save registers 		;AN000;
   565 0000011B 51                      	push	cx				;  "  "   "  "			;AN000;
   566 0000011C 89F1                    	mov	cx,si				;Get start of string		;AN000;
   567 0000011E 83C10B                  	add	cx,Label_Length 		;Find where to check for overrun;AN000;
   568                                  
   569                                  Check_DBCS_OverRun_Cont:			;Scan string for DBCS chars	;AN000;
   570                                  
   571 00000121 803C00                  	   cmp	   byte ptr [si],ASCIIZ_End	;End of string? 		;AN000;
   572 00000124 7422                    	   je	   DBCS_Good_Exit		;Yep				;AN000;
   573                                  
   574 00000126 8A04                    	   mov	   al,[si]			;Get character for routine	;AN000;
   575 00000128 E82600                  	   call    Check_DBCS_Character 	;See if DBCS leading character	;AN000;
   576                                  ;	   $if	   c				;DBCS if CY set 		;AN000;
   577 0000012B 7311                    	   JNC DD_IF38
   578 0000012D 46                      		   inc	si			;Next byte to handle DBCS	;AN000;
   579 0000012E 39CE                    		   cmp	si,cx			;Is DBCS char spanning 11-12?	;AN000;
   580                                  ;		   $if	e			;truncate string
   581 00000130 750A                    		   JNE DD_IF39
   582 00000132 C644FF20                			mov  byte ptr [si-1],20h;blank it out
   583 00000136 C60420                  			mov  byte ptr [si],20h	;blank it out
   584 00000139 EB0D                    			jmp  DBCS_Good_Exit	;exit
   585 0000013B 90                      	nop	; identicalise
   586                                  ;		   $endif			;
   587                                  DD_IF39:
   588                                  ;	   $else				;Not DBCS character		;an000; dms;
   589 0000013C EB07                    	   JMP SHORT DD_EN38
   590                                  DD_IF38:
   591 0000013E 8A04                    		   mov	al,[si] 		;Get character for routine	;an000; dms;
   592 00000140 E85B00                  		   call Scan_For_Invalid_Char	;See if invalid vol ID char	;an000; dms;
   593 00000143 7207                    		   jc	DBCS_Bad_Exit		;Bad char entered - exit	;an000; dms;
   594                                  ;	   $endif				;				;an000; dms;
   595                                  DD_EN38:
   596                                  
   597 00000145 46                      	   inc	   si				;Point to next character	;an000; dms;
   598 00000146 EBD9                    	   jmp	   Check_DBCS_OverRun_Cont	;Continue looping		;an000; dms;
   599                                  
   600                                  DBCS_Good_Exit:
   601                                  										;an000; dms;
   602 00000148 F8                      	clc					;Signal no error		;an000; dms;
   603 00000149 EB02                    	jmp	DBCS_Exit			;Exit routine			;an000; dms;
   604 0000014B 90                      	nop	; identicalise
   605                                  
   606                                  DBCS_Bad_Exit:									;an000; dms;
   607                                  
   608 0000014C F9                      	stc					;Signal error			;an000; dms;
   609                                  
   610                                  DBCS_Exit:									;an000; dms;
   611                                  
   612 0000014D 59                      	pop	cx				;Restore registers		;AN000;
   613 0000014E 58                      	pop	ax				; "  "	  "  "			;AN000;
   614 0000014F 5E                      	pop	si				;Restore string pointer 	;AN000;
   615 00000150 C3                      	ret					;				;AN000;
   616                                  
   617                                  Check_DBCS_Overrun endp 			;				;AN000;
   618                                  
   619                                  ;*****************************************************************************
   620                                  ;Routine name: Check_DBCS_Character
   621                                  ;*****************************************************************************
   622                                  ;
   623                                  ;Description: Check if specified byte is in ranges of DBCS vectors
   624                                  ;
   625                                  ;Called Procedures: None
   626                                  ;
   627                                  ;Change History: Created	6/12/87 	MT
   628                                  ;
   629                                  ;Input: AL = Character to check for DBCS lead character
   630                                  ;	DBCS_Vector = YES/NO
   631                                  ;
   632                                  ;Output: CY set if DBCS character
   633                                  ;	 DBCS_VECTOR = YES
   634                                  ;
   635                                  ;
   636                                  ;Psuedocode
   637                                  ;----------
   638                                  ;	Save registers
   639                                  ;	IF DBCS vector not found
   640                                  ;	   Get DBCS environmental vector (INT 21h
   641                                  ;	   Point at first set of vectors
   642                                  ;	ENDIF
   643                                  ;	SEARCH
   644                                  ;	LEAVE End of DBCS vectors
   645                                  ;	EXITIF Character > X1,AND  (X1,Y1) are environment vectors
   646                                  ;	EXITIF Character < Y1
   647                                  ;	  STC (DBCS character)
   648                                  ;	ORELSE
   649                                  ;	   Inc pointer to next set of vectors
   650                                  ;	ENDLOOP
   651                                  ;	   CLC (Not DBCS character)
   652                                  ;	ENDSRCH
   653                                  ;	Restore registers
   654                                  ;	ret
   655                                  ;*****************************************************************************
   656                                  
   657                                  Procedure Check_DBCS_Character			;				;AN000;
   658                                  
   659 00000151 1E                      	push	ds				;Save registers 		;AN000;
   660 00000152 56                      	push	si				; "  "	  "  "			;AN000;
   661 00000153 50                      	push	ax				; "  "	  "  "			;AN000;
   662 00000154 1E                      	push	ds				; "  "	  "  "			;AN000;
   663 00000155 07                      	pop	es				;Establish addressability	;AN000;
   664                                  Yes equ YES	; NASM port equate
   665 00000156 26803E0000FF            	cmp	byte [es:DBCS_VECTOR],Yes	;Have we set this yet?		;AN000;
   666 0000015C 50                      	push	ax				;Save input character		;AN000;
   667                                  ;	$IF	NE				;Nope				;AN000;
   668 0000015D 7417                    	JE DD_IF43
   669 0000015F B000                    	   mov	   al,0 			;Get DBCS environment vectors	;AN000;
   670 00000161 B463CD21                	   DOS_Call Hongeul			;  "  "    "  " 		;AN000;
   671 00000165 26C6060000FF            	   mov	   byte [es:DBCS_VECTOR],YES	;Indicate we've got vector      ;AN000;
   672 0000016B 268936[1100]            	   mov	   [es:DBCS_Vector_Off],si	;Save the vector		;AN000;
   673 00000170 8CD8                    	   mov	   ax,ds			;				;AN000;
   674 00000172 26A3[1300]              	   mov	   [es:DBCS_Vector_Seg],ax	;				;AN000;
   675                                  ;	$ENDIF					; for next time in		;AN000;
   676                                  DD_IF43:
   677 00000176 58                      	pop	ax				;Restore input character	;AN000;
   678 00000177 268B36[1300]            	mov	si,[es:DBCS_Vector_Seg]		;Get saved vector pointer	;AN000;
   679 0000017C 8EDE                    	mov	ds,si				;				;AN000;
   680 0000017E 268B36[1100]            	mov	si,[es:DBCS_Vector_Off]		;				;AN000;
   681                                  ;	$SEARCH 				;Check all the vectors		;AN000;
   682                                  DD_DO45:
   683 00000183 833C00                  	   cmp	   word ptr [si],End_Of_Vector ;End of vector table? 	  ;AN000;
   684                                  ;	$LEAVE	E				;Yes, done			;AN000;
   685 00000186 7411                    	JE DD_EN45
   686 00000188 3A04                    	   cmp	   al,[si]			;See if char is in vector	;AN000;
   687                                  ;	$EXITIF AE,AND				;If >= to lower, and		;AN000;
   688 0000018A 7208                    	JNAE DD_IF45
   689 0000018C 3A4401                  	   cmp	   al,[si+1] 		; =< than higher range		;AN000;
   690                                  ;	$EXITIF BE				; then DBCS character		;AN000;
   691 0000018F 7703                    	JNBE DD_IF45
   692 00000191 F9                      	   stc					;Set CY to indicate DBCS	;AN000;
   693                                  ;	$ORELSE 				;Not in range, check next	;AN000;
   694 00000192 EB06                    	JMP SHORT DD_SR45
   695                                  DD_IF45:
   696 00000194 83C602                  	   add	   si,DBCS_Vector_Size		;Get next DBCS vector		;AN000;
   697                                  ;	$ENDLOOP				;We didn't find DBCS char       ;AN000;
   698 00000197 EBEA                    	JMP SHORT DD_DO45
   699                                  DD_EN45:
   700 00000199 F8                      	   clc					;Clear CY for exit		;AN000;
   701                                  ;	$ENDSRCH				;				;AN000;
   702                                  DD_SR45:
   703 0000019A 58                      	pop	ax				;Restore registers		;AN000;
   704 0000019B 5E                      	pop	si				; "  "	  "  "			;AN000;
   705 0000019C 1F                      	pop	ds				;Restore data segment		;AN000;
   706 0000019D C3                      	ret					;				;AN000;
   707                                  
   708                                  Check_DBCS_Character endp			;				;AN000;
   709                                  
   710                                  ;=========================================================================
   711                                  ; Scan_For_Invalid_Char : This routine scans the bad character table
   712                                  ;			  to determine if the referenced character is
   713                                  ;			  invalid.
   714                                  ;
   715                                  ;	Inputs	: Bad_Char_Table	- Table of bad characters
   716                                  ;		  Bad_Char_Table_Len	- Length of table
   717                                  ;		  AL			- Character to be searched for
   718                                  ;
   719                                  ;	Outputs : CY			- Bad character
   720                                  ;		  NC			- Character good
   721                                  ;=========================================================================
   722                                  
   723                                  Procedure Scan_For_Invalid_Char 						;an000; dms;
   724                                  
   725 0000019E 50                      	push	ax								;an000; dms;save ax
   726 0000019F 51                      	push	cx								;an000; dms;save cx
   727 000001A0 57                      	push	di								;an000; dms;save di
   728                                  
   729 000001A1 8D3E[0000]              	lea	di,[Bad_Char_Table]						;an000; dms;point to bad character table
   730 000001A5 B91100                  	mov	cx,Bad_Char_Table_Len						;an000; dms;get its length
   731 000001A8 90                      	nop	; identicalise
   732 000001A9 F2AE                    	repnz	scasb								;an000; dms;scan the table
   733 000001AB 83F900                  	cmp	cx,0000h							;an000; dms;did we find the character
   734                                  ;	$if	e								;an000; dms;no - a good character
   735 000001AE 7503                    	JNE DD_IF51
   736 000001B0 F8                      		clc								;an000; dms;flag a good character
   737                                  ;	$else									;an000; dms;yes - a bad character
   738 000001B1 EB01                    	JMP SHORT DD_EN51
   739                                  DD_IF51:
   740 000001B3 F9                      		stc								;an000; dms;flag a bad character
   741                                  ;	$endif									;an000; dms;
   742                                  DD_EN51:
   743                                  
   744 000001B4 5F                      	pop	di								;an000; dms;restore di
   745 000001B5 59                      	pop	cx								;an000; dms;restore cx
   746 000001B6 58                      	pop	ax								;an000; dms;restore ax
   747                                  
   748 000001B7 C3                      	ret									;an000; dms;
   749                                  
   750                                  Scan_For_Invalid_Char	endp							;an000; dms;
   751                                  
   752                                  
   753                                  ; (no prior section) ; code	ends
   754                                  
   755                                  section data
   756                                  
   757                                  Bad_Char_Table	label	byte			;an000; dms;table of invalid vol ID chars
   758 00000000 2A                      	db	"*"
   759 00000001 3F                      	db	"?"
   760 00000002 5B                      	db	"["
   761 00000003 5D                      	db	"]"
   762 00000004 3A                      	db	":"
   763 00000005 3C                      	db	"<"
   764 00000006 7C                      	db	"|"
   765 00000007 3E                      	db	">"
   766 00000008 2B                      	db	"+"
   767 00000009 3D                      	db	"="
   768 0000000A 3B                      	db	";"
   769 0000000B 2C                      	db	","
   770 0000000C 2F                      	db	"/"
   771 0000000D 5C                      	db	"\"
   772 0000000E 2E                      	db	'.'
   773 0000000F 22                      	db	'"'
   774 00000010 20                      	db	" "
   775                                  Bad_Char_Table_Len	equ	$-Bad_Char_Table;an000; dms;length of table
   776                                  
   777 00000011 0000                    DBCS_Vector_Off dw 0				;
   778 00000013 0000                    DBCS_Vector_Seg dw 0				;
   779                                  
   780                                  ; (no prior section) ; data	ends
   781                                  	end
