     1                                  ;	SCCSID = @(#)forproc.asm	1.2 85/07/25
     2                                  [list -]
   134                              <1> 
    10                                  	%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
    11                                  	%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;
    12                                  	%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
    13                                  	%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> 
    14                                  	%include "ioctl.mac"
     1                              <1> 
     2                              <1> %warning out: IOCTL.INC...
     2          ******************  <1>  warning: out: IOCTL.INC... [-w+user]
     3                              <1> ; THESE ARE ALL THE IMPORTANT STRUCTURES AND EQUATES FOR IOCTL
     4                              <1> ;==============================================================================
     5                              <1> ;REVISION HISTORY:
     6                              <1> ;AN000 - New for DOS Version 4.00 - J.K.
     7                              <1> ;AC000 - Changed for DOS Version 4.00 - J.K.
     8                              <1> ;AN00x - PTM number for DOS Version 4.00 - J.K.
     9                              <1> ;==============================================================================
    10                              <1> ;AN001; D241 Provide support of Multi-track Format/Verify	   9/23/87 J.K.
    11                              <1> ;AN002; P1535 Unformatted hard file problem			  10/15/87 J.K.
    12                              <1> ;AN003; D490 IOCTL subfunction 63h,43h,64h,44h conflicts with OS2  2/26/88 J.K.
    13                              <1> ;==============================================================================
    14                              <1> 
    15                              <1> ;*** J.K.
    16                              <1> ;General Guide -
    17                              <1> ;Category Code:
    18                              <1> ; 0... .... DOS Defined
    19                              <1> ; 1... .... User defined
    20                              <1> ; .xxx xxxx Code
    21                              <1> 
    22                              <1> ;Function Code:
    23                              <1> ; 0... .... Return error if unsupported
    24                              <1> ; 1... .... Ignore if unsupported
    25                              <1> ; .0.. .... Intercepted by DOS
    26                              <1> ; .1.. .... Passed to driver
    27                              <1> ; ..0. .... Sends data/commands to device
    28                              <1> ; ..1. .... Quries data/info from device
    29                              <1> ; ...x .... Subfunction
    30                              <1> ;
    31                              <1> ; Note that "Sends/queries" data bit is intended only to regularize the
    32                              <1> ; function set.  It plays no critical role; some functions may contain both
    33                              <1> ; command and query elements. The convention is that such commands are
    34                              <1> ; defined as "sends data".
    35                              <1> 
    36                              <1> ;*****************************;*
    37                              <1> ; BLOCK DRIVERS 	      ;*
    38                              <1> ;*****************************;*
    39                              <1> 
    40                              <1> ; IOCTL SUB-FUNCTIONS
    41                              <1> IOCTL_GET_DEVICE_INFO	EQU	0
    42                              <1> IOCTL_SET_DEVICE_INFO	EQU	1
    43                              <1> IOCTL_READ_HANDLE	EQU	2
    44                              <1> IOCTL_WRITE_HANDLE	EQU	3
    45                              <1> IOCTL_READ_DRIVE	EQU	4
    46                              <1> IOCTL_WRITE_DRIVE	EQU	5
    47                              <1> IOCTL_GET_INPUT_STATUS	EQU	6
    48                              <1> IOCTL_GET_OUTPUT_STATUS EQU	7
    49                              <1> IOCTL_CHANGEABLE?	EQU	8
    50                              <1> IOCTL_DeviceLocOrRem?	EQU	9
    51                              <1> IOCTL_HandleLocOrRem?	EQU	0Ah   ;10
    52                              <1> IOCTL_SHARING_RETRY	EQU	0Bh   ;11
    53                              <1> GENERIC_IOCTL_HANDLE	EQU	0Ch   ;12
    54                              <1> GENERIC_IOCTL		EQU	0Dh   ;13
    55                              <1> 
    56                              <1> ; GENERIC IOCTL CATEGORY CODES
    57                              <1> IOC_OTHER		EQU	0	; Other device control J.K. 4/29/86
    58                              <1> IOC_SE			EQU	1	; SERIAL DEVICE CONTROL
    59                              <1> IOC_TC			EQU	2	; TERMINAL CONTROL
    60                              <1> IOC_SC			EQU	3	; SCREEN CONTROL
    61                              <1> IOC_KC			EQU	4	; KEYBOARD CONTROL
    62                              <1> IOC_PC			EQU	5	; PRINTER CONTROL
    63                              <1> IOC_DC			EQU	8	; DISK CONTROL (SAME AS RAWIO)
    64                              <1> 
    65                              <1> ; GENERIC IOCTL SUB-FUNCTIONS
    66                              <1> RAWIO			EQU	8
    67                              <1> 
    68                              <1> ; RAWIO SUB-FUNCTIONS
    69                              <1> GET_DEVICE_PARAMETERS	EQU	60H
    70                              <1> SET_DEVICE_PARAMETERS	EQU	40H
    71                              <1> READ_TRACK		EQU	61H
    72                              <1> WRITE_TRACK		EQU	41H
    73                              <1> VERIFY_TRACK		EQU	62H
    74                              <1> FORMAT_TRACK		EQU	42H
    75                              <1> GET_MEDIA_ID		EQU	66h		;AN000;AN003;changed from 63h
    76                              <1> SET_MEDIA_ID		EQU	46h		;AN000;AN003;changed from 43h
    77                              <1> GET_ACCESS_FLAG 	EQU	67h		;AN002;AN003;Unpublished function.Changed from 64h
    78                              <1> SET_ACCESS_FLAG 	EQU	47h		;AN002;AN003;Unpublished function.Changed from 44h
    79                              <1> 
    80                              <1> ; SPECIAL FUNCTION FOR GET DEVICE PARAMETERS
    81                              <1> BUILD_DEVICE_BPB	EQU	000000001B
    82                              <1> 
    83                              <1> ; SPECIAL FUNCTIONS FOR SET DEVICE PARAMETERS
    84                              <1> INSTALL_FAKE_BPB	EQU	000000001B
    85                              <1> ONLY_SET_TRACKLAYOUT	EQU	000000010B
    86                              <1> TRACKLAYOUT_IS_GOOD	EQU	000000100B
    87                              <1> 
    88                              <1> ; SPECIAL FUNCTION FOR FORMAT TRACK
    89                              <1> STATUS_FOR_FORMAT		EQU	000000001B
    90                              <1> DO_FAST_FORMAT			equ	000000010B	;AN001;
    91                              <1> ; CODES RETURNED FROM FORMAT STATUS CALL
    92                              <1> FORMAT_NO_ROM_SUPPORT		EQU	000000001B
    93                              <1> FORMAT_COMB_NOT_SUPPORTED	EQU	000000010B
    94                              <1> 
    95                              <1> ; DEVICETYPE VALUES
    96                              <1> MAX_SECTORS_IN_TRACK	EQU	63	; MAXIMUM SECTORS ON A DISK.(Was 40 in DOS 3.2)
    97                              <1> DEV_5INCH		EQU	0
    98                              <1> DEV_5INCH96TPI		EQU	1
    99                              <1> DEV_3INCH720KB		EQU	2
   100                              <1> DEV_8INCHSS		EQU	3
   101                              <1> DEV_8INCHDS		EQU	4
   102                              <1> DEV_HARDDISK		EQU	5
   103                              <1> DEV_OTHER		EQU	7
   104                              <1> 
   105                              <1> MAX_DEV_TYPE		EQU	7	; MAXIMUM DEVICE TYPE THAT WE
   106                              <1> 					; CURRENTLY SUPPORT.
   107                              <1> 
   108                              <1> %include "bpb.mac"
     1                              <2> 	%warning out: BPB.INC...
     1          ******************  <2>  warning: out: BPB.INC... [-w+user]
     2                              <2> ;	SCCSID = @(#)BPB.ASM	1.1 85/04/29
     3                              <2> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
     4                              <2> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
     5                              <2> ;									   ;
     6                              <2> 
     7                              <2> ; BIOS PARAMETER BLOCK DEFINITION
     8                              <2> ; THIS STRUCTURE IS USED TO BUILD A FULL DPB
     9                              <2> 
    10                              <2> BPBLOCK STRUC
    11 00000000 ????                <2> BPSECSZ DW	?			; SIZE IN BYTES OF PHYSICAL SECTOR
    12 00000002 ??                  <2> BPCLUS	DB	?			; SECTORS/ALLOC UNIT
    13 00000003 ????                <2> BPRES	DW	?			; NUMBER OF RESERVED SECTORS
    14 00000005 ??                  <2> BPFTCNT DB	?			; NUMBER OF FATS
    15 00000006 ????                <2> BPDRCNT DW	?			; NUMBER OF DIRECTORY ENTRIES
    16 00000008 ????                <2> BPSCCNT DW	?			; TOTAL NUMBER OF SECTORS
    17 0000000A ??                  <2> BPMEDIA DB	?			; MEDIA DESCRIPTOR BYTE
    18 0000000B ????                <2> BPFTSEC DW	?			; NUMBER OF SECTORS TAKEN UP BY ONE FAT
    19                              <2> BPBLOCK ENDS
    20                              <2> 
    21                              <2> A_BPB			STRUC
    22 00000000 ????                <2> BPB_BYTESPERSECTOR	DW	?
    23 00000002 ??                  <2> BPB_SECTORSPERCLUSTER	DB	?
    24 00000003 ????                <2> BPB_RESERVEDSECTORS	DW	?
    25 00000005 ??                  <2> BPB_NUMBEROFFATS	DB	?
    26 00000006 ????                <2> BPB_ROOTENTRIES 	DW	?
    27 00000008 ????                <2> BPB_TOTALSECTORS	DW	?
    28 0000000A ??                  <2> BPB_MEDIADESCRIPTOR	DB	?
    29 0000000B ????                <2> BPB_SECTORSPERFAT	DW	?
    30 0000000D ????                <2> BPB_SECTORSPERTRACK	DW	?
    31 0000000F ????                <2> BPB_HEADS		DW	?
    32 00000011 ????                <2> BPB_HIDDENSECTORS	DW	?
    33 00000013 ????                <2> 			DW	?
    34 00000015 ????                <2> BPB_BIGTOTALSECTORS	DW	?
    35 00000017 ????                <2> 			DW	?
    36 00000019 ????????????        <2> 			DB	6 DUP(?)
    37                              <2> A_BPB			ENDS
    38                              <2> ;									   ;
    39                              <2> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    40                              <2> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
   109                              <1> 
   110                              <1> A_SECTORTABLE	    STRUC
   111 00000000 ????                <1> ST_SECTORNUMBER 	DW	?
   112 00000002 ????                <1> ST_SECTORSIZE		DW	?
   113                              <1> A_SECTORTABLE	    ENDS
   114                              <1> 
   115                              <1> A_DEVICEPARAMETERS  STRUC
   116 00000000 ??                  <1> DP_SPECIALFUNCTIONS	DB	?
   117 00000001 ??                  <1> DP_DEVICETYPE		DB	?
   118 00000002 ????                <1> DP_DEVICEATTRIBUTES	DW	?
   119 00000004 ????                <1> DP_CYLINDERS		DW	?
   120 00000006 ??                  <1> DP_MEDIATYPE		DB	?
   121 00000007 <res 1Fh>           <1> DP_BPB			DB	A_BPB_struc_size DUP (?)
   122 00000026 ????                <1> DP_TRACKTABLEENTRIES	DW	?
   123 00000028 <res FCh>           <1> DP_SECTORTABLE		DB MAX_SECTORS_IN_TRACK * A_SECTORTABLE_struc_size DUP (?)
   124                              <1> A_DEVICEPARAMETERS  ENDS
   125                              <1> 
   126                              <1> A_TRACKREADWRITEPACKET STRUC
   127 00000000 ??                  <1> TRWP_SPECIALFUNCTIONS	DB	?
   128 00000001 ????                <1> TRWP_HEAD		DW	?
   129 00000003 ????                <1> TRWP_CYLINDER		DW	?
   130 00000005 ????                <1> TRWP_FIRSTSECTOR	DW	?
   131 00000007 ????                <1> TRWP_SECTORSTOREADWRITE DW	?
   132 00000009 ????????            <1> TRWP_TRANSFERADDRESS	DD	?
   133                              <1> A_TRACKREADWRITEPACKET ENDS
   134                              <1> 
   135                              <1> ;AN001; - FP_TRACKCOUNT is only meaningful when FP_SPECIALFUNCTIONS bit 1 = 1.
   136                              <1> A_FORMATPACKET	    STRUC
   137 00000000 ??                  <1> FP_SPECIALFUNCTIONS	DB	?
   138 00000001 ????                <1> FP_HEAD 		DW	?
   139 00000003 ????                <1> FP_CYLINDER		DW	?
   140 00000005 ????                <1> FP_TRACKCOUNT		DW	? ;1
   141                              <1> A_FORMATPACKET	    ENDS
   142                              <1> 
   143                              <1> A_VERIFYPACKET	    STRUC
   144 00000000 ??                  <1> VP_SPECIALFUNCTIONS	DB	?
   145 00000001 ????                <1> VP_HEAD 		DW	?
   146 00000003 ????                <1> VP_CYLINDER		DW	?
   147                              <1> A_VERIFYPACKET	    ENDS
   148                              <1> 
   149                              <1> A_MEDIA_ID_INFO     STRUC
   150 00000000 ????                <1> MI_LEVEL		DW	? ;0		;J.K. 87 Info. level
   151 00000002 ????????            <1> MI_SERIAL		DD	?		;J.K. 87 Serial #
   152 00000006 <res Bh>            <1> MI_LABEL		DB     11 DUP (?) ;(' ')     ;J.K. 87 volume label
   153 00000011 ????????????????    <1> MI_SYSTEM		DB	8 DUP (?) ;(' ')     ;J.K. 87 File system type
   154                              <1> A_MEDIA_ID_INFO     ENDS
   155                              <1> 
   156                              <1> A_DISKACCESS_CONTROL	STRUC			;AN002; Unpublished function. Only for Hard file.
   157 00000000 ??                  <1> DAC_SPECIALFUNCTIONS	DB	? ;0		;AN002; Always 0
   158 00000001 ??                  <1> DAC_ACCESS_FLAG 	DB	? ;0		;AN002; Non Zero - allow disk I/O to unformatted hard file
   159                              <1> A_DISKACCESS_CONTROL	ENDS			;AN002; 0 - Disallow disk I/O to unformatted hard file
   160                              <1> 
   161                              <1> ;********************************;*
   162                              <1> ; CHARACTER DEVICES (PRINTERS)	 ;*
   163                              <1> ;********************************;*
   164                              <1> 
   165                              <1> ;RAWIO SUB-FUNCTIONS
   166                              <1> GET_RETRY_COUNT 	EQU	65H
   167                              <1> SET_RETRY_COUNT 	EQU	45H
   168                              <1> 
   169                              <1> A_RETRYCOUNT	    STRUC
   170 00000000 ????                <1> RC_COUNT		DW	?
   171                              <1> A_RETRYCOUNT	    ENDS
   172                              <1> 
   173                              <1> ;********************************;*		;J.K. 4/29/86
   174                              <1> ; CHARACTER DEVICES (SCREEN)	 ;*
   175                              <1> ;********************************;*		;J.K. 4/29/86
   176                              <1> ;
   177                              <1> ;SC_MODE_INFO	 struc
   178                              <1> ;SC_INFO_LENGTH 	 DW	 9
   179                              <1> ;SC_MODE		 DB	 0
   180                              <1> ;SC_COLORS		 DW	 0
   181                              <1> ;SC_WIDTH		 DW	 0
   182                              <1> ;SC_LENGTH		 DW	 0
   183                              <1> ;SC_MODE_INFO	 ends
   184                              <1> ;
   185                              <1> ;SC_INFO_PACKET_LENGTH	 EQU	 9		 ;LENGTH OF THE INFO PACKET.
   186                              <1> 
   187                              <1> ;SUBFUNCTIONS FOR CON$GENIOCTL
   188                              <1> ;GET_SC_MODE		 EQU	 60h
   189                              <1> ;SET_SC_MODE		 EQU	 40h
   190                              <1> ;The following subfunctions are reserved for installable CODE PAGE switch
   191                              <1> ;console devices. - J.K. 4/29/86
   192                              <1> ;Get_active_codepage	 equ	 6Ah
   193                              <1> ;Invoke_active_codepage  equ	 4Ah
   194                              <1> ;Start_designate_codepage equ	 4Ch
   195                              <1> ;End_designate_codepage  equ	 4Dh
   196                              <1> ;Get_list_of_designated_codepage equ 6Bh
   197                              <1> ;J.K. 4/29/86 *** End of Con$genioctl equates & structures
    15                                  ;.cref
    16                                  [list +]
    17                                  section data public align=16 class=DATA
    18                                  ; (no prior section) ; data	ends
    19                                  
    20                                  section code public align=16 class=CODE
    21                                  	assume	cs:code,ds:data
    22                                  
    23                                  Yes? equ YES?	; NASM port label
    24                                  	PUBLIC	FormatAnother?,REPORT,USER_STRING
    25                                  	public	fdsksiz,badsiz,syssiz,datasiz,biosiz
    26                                  	public	AllocSize,AllocNum
    27                                  
    28                                  	extrn	std_printf:near,crlf:near,PrintString:near
    29                                  	extrn	Multiply_32_Bits:near
    30                                  	extrn	AddToSystemSize:near
    31                                  
    32                                  section data
    33                                  	extrn	driveLetter:byte
    34                                  	extrn	msgInsertDisk:byte
    35                                  	extrn	msgFormatAnother?:byte
    36                                  	extrn	msgTotalDiskSpace:byte
    37                                  	extrn	msgSystemSpace:byte
    38                                  	extrn	msgBadSpace:byte
    39                                  	extrn	msgDataSpace:byte
    40                                  	extrn	Read_Write_Relative:byte
    41                                  	extrn	msgAllocSize:byte
    42                                  	extrn	MsgAllocNum:Byte
    43                                  	extrn	deviceParameters:byte
    44                                  	extrn	bios:byte
    45                                  	extrn	dos:byte
    46                                  	extrn	command:byte
    47                                  	extrn	Serial_Num_Low:Word
    48                                  	extrn	Serial_Num_High:Word
    49                                  	extrn	msgSerialNumber:Byte
    50                                  	extrn	SwitchMap:Word
    51                                  
    52                                  
    53                                  	extrn	inbuff:byte
    54                                  
    55 00000000 00000000                fdsksiz dd	0
    56                                  
    57 00000004 00000000                syssiz	dd	0
    58 00000008 00000000                biosiz	dd	0
    59                                  
    60 0000000C 00000000                badsiz	dd	0
    61                                  
    62 00000010 00000000                datasiz dd	0
    63                                  
    64 00000014 00000000                AllocSize dd	0				;				;AN000;
    65 00000018 0000                    AllocNum dw	0				;				;AN000;
    66 0000001A [0000]                  	dw	offset driveLetter
    67                                  section code	; data	ends
    68                                  
    69                                  FormatAnother? proc near
    70                                  ; Wait for key. If yes return carry clear, else no. Insures
    71                                  ;   explicit Y or N answer.
    72 00000000 BA[0000]E8(0000)        	Message msgFormatAnother?		;				;AC000;
    73 00000006 E80A00                  	CALL	Yes?
    74 00000009 7307                    	JNC	WAIT20
    75 0000000B 7405                    	JZ	WAIT20
    76                                  CRLF equ crlf	; NASM port label
    77 0000000D E8(0000)                	CALL	CRLF
    78 00000010 EBEE                    	JMP	SHORT FormatAnother?
    79                                  WAIT20: 					;				;AC000;
    80 00000012 C3                      	RET					;				;AC000;
    81                                  FormatAnother? endp
    82                                  
    83                                  ;*****************************************************************************
    84                                  ;Routine name:Yes?
    85                                  ;*****************************************************************************
    86                                  ;
    87                                  ;Description: Validate that input is valid Y/N for the country dependent info
    88                                  ;	      Wait for key. If YES return carry clear,else carry set.
    89                                  ;	      If carry is set, Z is set if explicit NO, else key was not Yes or No.
    90                                  ;
    91                                  ;Called Procedures: Message (macro)
    92                                  ;		    User_String
    93                                  ;
    94                                  ;Change History: Created	4/32/87 	MT
    95                                  ;
    96                                  ;Input: None
    97                                  ;
    98                                  ;Output: CY = 0 Yes is entered
    99                                  ;	 CY = 1, Z = No
   100                                  ;	 CY = 1, NZ = other
   101                                  ;
   102                                  ;Psuedocode
   103                                  ;----------
   104                                  ;
   105                                  ;	Get input (CALL USER STRING)
   106                                  ;	IF got character
   107                                  ;	   Check for country dependent Y/N (INT 21h, AX=6523h Get Ext Country)
   108                                  ;	   IF Yes
   109                                  ;	      clc
   110                                  ;	   ELSE (No)
   111                                  ;	      IF No
   112                                  ;		 stc
   113                                  ;		 Set Zero flag
   114                                  ;	      ELSE (Other)
   115                                  ;		 stc
   116                                  ;		 Set NZ
   117                                  ;	      ENDIF
   118                                  ;	   ENDIF
   119                                  ;	ELSE  (nothing entered)
   120                                  ;	   stc
   121                                  ;	   Set NZ flag
   122                                  ;	ENDIF
   123                                  ;	ret
   124                                  ;*****************************************************************************
   125                                  
   126                                  Procedure YES?					;				;AN000;
   127                                  
   128                                  User_String equ USER_STRING	; NASM port label
   129 00000013 E82900                  	call	User_String			;Get character			;     ;
   130                                  ;	$IF	NZ				;Got one if returned NZ 	;AC000;
   131 00000016 7421                    	JZ DD_IF1
   132 00000018 B023                    	   mov	   al,23h			;See if it is Y/N		;AN000;
   133                                  InBuff equ inbuff	; NASM port label
   134 0000001A 8A16[0200]              	   mov	   dl,[InBuff+2]		;Get character			;AN000;
   135 0000001E B465CD21                	   DOS_Call GetExtCntry 		;Get country info call		;AN000;
   136 00000022 83F801                  	   cmp	   ax,Found_Yes 		;Which one?			;AC000;
   137                                  ;	   $IF	   E				;Got a Yes			;AC000;
   138 00000025 7503                    	   JNE DD_IF2
   139 00000027 F8                      	      clc				;Clear CY for return		;AN000;
   140                                  ;	   $ELSE				;Not a Yes			;AN000;
   141 00000028 EB0D                    	   JMP SHORT DD_EN2
   142                                  DD_IF2:
   143 0000002A 83F800                  	      cmp     ax,Found_No		;Is it No?			;AC000;
   144                                  ;	      $IF     E 			;Yep				;AN000;
   145 0000002D 7503                    	      JNE DD_IF4
   146 0000002F F9                      		 stc				;Set CY for return		;AC000;
   147                                  ;	      $ELSE				;Something else we don't want   ;AN000;
   148 00000030 EB05                    	      JMP SHORT DD_EN4
   149                                  DD_IF4:
   150 00000032 30C0                    		 xor	 al,al			;Set NZ flag for ret		;AC000;
   151 00000034 3C01                    		 cmp	 al,1			; " "	 " "			;AC000;
   152 00000036 F9                      		 stc				;And CY flag for good measure	;AN000;
   153                                  ;	      $ENDIF				;				;AN000;
   154                                  DD_EN4:
   155                                  ;	   $ENDIF				;				;AN000;
   156                                  DD_EN2:
   157                                  ;	$ELSE					;No char found at all		;AN000;
   158 00000037 EB05                    	JMP SHORT DD_EN1
   159                                  DD_IF1:
   160 00000039 30C0                    	   xor	   al,al			;Set NZ flag for ret		;AN000;
   161 0000003B 3C01                    	   cmp	   al,1 			; " "	 " "			;AN000;
   162 0000003D F9                      	   stc					;And CY flag for good measure	;AN000;
   163                                  ;	$ENDIF					;				;AN000;
   164                                  DD_EN1:
   165 0000003E C3                      	ret					;				;     ;
   166                                  
   167                                  Yes?	endp					;				;AN000;
   168                                  
   169                                  
   170                                  USER_STRING:
   171                                  ; Get a string from user. Z is set if user typed no chars (imm CR)
   172                                  ;  We need to flush a second time to get rid of incoming Kanji characters also.
   173                                  STD_CON_INPUT_FLUSH equ Std_Con_Input_Flush	; NASM port equate
   174 0000003F B8000C                  	MOV	AX,(STD_CON_INPUT_FLUSH << 8) + 0 ; Clean out input
   175 00000042 CD21                    	INT	21H
   176                                  INBUFF equ inbuff	; NASM port label
   177 00000044 BA[0000]                	MOV	DX,OFFSET INBUFF
   178                                  STD_CON_STRING_INPUT equ Std_Con_String_Input	; NASM port equate
   179 00000047 B40A                    	MOV	AH,STD_CON_STRING_INPUT
   180 00000049 CD21                    	INT	21H
   181 0000004B B8000C                  	MOV	AX,(STD_CON_INPUT_FLUSH << 8) + 0 ; Clean out input
   182 0000004E CD21                    	INT	21H
   183 00000050 803E[0100]00            	CMP	BYTE PTR [INBUFF+1],0
   184 00000055 C3                      	RET
   185                                  
   186                                  ;*********************************************
   187                                  ; Make a status report including the following information:
   188                                  ; Total disk capacity
   189                                  ; Total system area used
   190                                  ; Total bad space allocated
   191                                  ; Total data space available
   192                                  ; Number of allocation units
   193                                  ; Size of allocation units
   194                                  
   195                                  REPORT:
   196 00000056 E8(0000)                	call	crlf
   197                                  
   198 00000059 E86601                  	call	Calc_System_Space		;an013; dms;calc system space
   199 0000005C E80101                  	call	Calc_Total_Addressible_Space	;an013; dms;calc total space
   200                                  
   201 0000005F BA[0000]E8(0000)        	Message msgTotalDiskSpace		;				;AC000;
   202                                  						;call	 std_printf
   203                                  SYSSIZ equ syssiz	; NASM port label
   204 00000065 833E[0400]00            	cmp	WORD [SYSSIZ],0
   205 0000006A 7507                    	JNZ	SHOWSYS
   206 0000006C 833E[0600]00            	cmp	WORD [SYSSIZ+2],0
   207 00000071 7406                    	JZ	CHKBAD
   208                                  SHOWSYS:
   209 00000073 BA[0000]E8(0000)        	Message msgSystemSpace			;				;AC000;
   210                                  						;CALL	 std_printf		 ;Report space used by system
   211                                  CHKBAD:
   212                                  BADSIZ equ badsiz	; NASM port label
   213 00000079 833E[0C00]00            	cmp	WORD [BADSIZ],0
   214 0000007E 7507                    	JNZ	SHOWBAD
   215 00000080 833E[0E00]00            	cmp	WORD [BADSIZ+2],0
   216 00000085 7406                    	JZ	SHOWDATA
   217                                  SHOWBAD:
   218 00000087 BA[0000]E8(0000)        	Message msgBadSpace			;				;AC000;
   219                                  						;call	 std_printf
   220                                  SHOWDATA:
   221                                  
   222                                  
   223                                  Fdsksiz equ fdsksiz	; NASM port label
   224 0000008D 8B0E[0000]              	MOV	CX,WORD PTR [Fdsksiz]
   225 00000091 8B1E[0200]              	MOV	BX,WORD PTR [Fdsksiz+2]
   226 00000095 2B0E[0C00]              	SUB	CX,WORD PTR [BADSIZ]
   227 00000099 1B1E[0E00]              	SBB	BX,WORD PTR [BADSIZ+2]
   228 0000009D 2B0E[0400]              	SUB	CX,WORD PTR [SYSSIZ]
   229 000000A1 1B1E[0600]              	SBB	BX,WORD PTR [SYSSIZ+2]
   230 000000A5 890E[1000]              	MOV	word ptr [datasiz],CX
   231 000000A9 891E[1200]              	MOV	word ptr [datasiz+2],BX
   232 000000AD BA[0000]E8(0000)        	Message msgDataSpace			;				;AC000;
   233                                  						;call	 std_printf
   234                                  
   235 000000B3 E8(0000)                	call	crlf				;				;AN000;
   236                                  BPB_BytesPerSector equ BPB_BYTESPERSECTOR	; NASM port equate
   237 000000B6 A1[0700]                	mov	ax,[deviceParameters + DP_BPB + BPB_BytesPerSector] ; 		;AN000;
   238                                  BPB_SectorsPerCluster equ BPB_SECTORSPERCLUSTER	; NASM port equate
   239 000000B9 8A0E[0900]              	mov	cl,[deviceParameters + DP_BPB + BPB_SectorsPerCluster] ;		;AN000;
   240 000000BD 30ED                    	xor	ch,ch				;				;AN000;
   241 000000BF F7E1                    	mul	cx				;Get bytes per alloc		;AN000;
   242                                  
   243 000000C1 A3[1400]                	mov	word ptr [AllocSize],ax		;Save allocation size		;AN000;
   244 000000C4 8916[1600]              	mov	word ptr [AllocSize+2],dx 	; for message			;AN000;
   245 000000C8 BA[0000]E8(0000)        	Message msgAllocSize			;Print size of cluster		;AN000;
   246 000000CE E8E100                  	call	Get_Free_Space			;an013; dms;get disk space
   247                                  
   248 000000D1 891E[1800]              	mov	word ptr [AllocNum],bx		;Put result in msg		;AN000;
   249                                  msgAllocNum equ MsgAllocNum	; NASM port label
   250 000000D5 BA[0000]E8(0000)        	Message msgAllocNum			; = cluster/disk		;AN000;
   251 000000DB E8(0000)                	call	crlf				;				;AN000;
   252                                  switchmap equ SwitchMap	; NASM port label
   253 000000DE F706[0000]0001          	test	word [switchmap], SWITCH_8		;If 8 tracks, don't display     ;AN027;
   254 000000E4 7509                    	jnz	NOSERIALNUMBER			;serial number			;AN027;
   255 000000E6 BA[0000]E8(0000)        	Message msgSerialNumber 		;Spit out serial number 	;AN000;
   256 000000EC E8(0000)                	call	crlf				;
   257                                  NOSERIALNUMBER: 								;AN027;
   258 000000EF C3                      	RET					;
   259                                  
   260                                  ;*****************************************************************************
   261                                  ;Routine name: Read_Disk
   262                                  ;*****************************************************************************
   263                                  ;
   264                                  ;description: Read in data using Generic IOCtl
   265                                  ;
   266                                  ;Called Procedures: None
   267                                  ;
   268                                  ;
   269                                  ;Change History: Created	5/13/87 	MT
   270                                  ;
   271                                  ;Input: AL = Drive number (0=A)
   272                                  ;	DS:BX = Transfer address
   273                                  ;	CX = Number of sectors
   274                                  ;	Read_Write_Relative.Start_Sector_High = Number of sectors high
   275                                  ;	DX = logical sector number low
   276                                  ;
   277                                  ;Output: CY if error
   278                                  ;	 AH = INT 25h error code
   279                                  ;
   280                                  ;Psuedocode
   281                                  ;----------
   282                                  ;	Save registers
   283                                  ;	Setup structure for function call
   284                                  ;	Read the disk (AX=440Dh, CL = 6Fh)
   285                                  ;	Restore registers
   286                                  ;	ret
   287                                  ;*****************************************************************************
   288                                  
   289                                  Procedure Read_Disk				;				;AN000;
   290                                  
   291                                  						;This is setup for INT 25h right;AN000;
   292                                  						;Change it to Read relative sect;AN000;
   293 000000F0 53                      	push	bx				;Save registers 		;AN000;
   294 000000F1 51                      	push	cx				;				;AN000;
   295 000000F2 52                      	push	dx				;				;AN000;
   296 000000F3 56                      	push	si				;				;AN000;
   297 000000F4 57                      	push	di				;				;AN000;
   298 000000F5 55                      	push	bp				;				;AN000;
   299 000000F6 06                      	push	es				;				;AN000;
   300 000000F7 1E                      	push	ds				;
   301 000000F8 BE[ssss]                	mov	si,data 			;				;AN000;
   302 000000FB 8EC6                    	mov	es,si				;				;AN000;
   303                                  
   304                                  	assume	es:data,ds:nothing		;				;AN000;
   305                                  
   306 000000FD 26891E[0600]            	mov	[es:Read_Write_Relative + Buffer_Offset],bx ;Get transfer buffer add;AN000;
   307 00000102 8CDB                    	mov	bx,ds				;				;AN000;
   308 00000104 26891E[0800]            	mov	[es:Read_Write_Relative + Buffer_Segment],bx ;Get segment		;AN000;
   309 00000109 BB[ssss]                	mov	bx,data 			;Point DS at parameter list	;AN000;
   310 0000010C 8EDB                    	mov	ds,bx				;				;AN000;
   311                                  
   312                                  	assume	ds:data,es:data
   313                                  
   314 0000010E 890E[0400]              	mov	[Read_Write_Relative + Number_Sectors],cx ;Number of sec to read	;AN000;
   315 00000112 8916[0000]              	mov	[Read_Write_Relative + Start_Sector_Low],dx ;Start sector		;AN000;
   316 00000116 BB[0000]                	mov	bx,offset Read_Write_Relative	;				  ;AN000;
   317 00000119 B9FFFF                  	mov	cx,0FFFFh			;Read relative sector		;AN000;
   318 0000011C CD25                    	INT	25h				;Do the read			;AN000;
   319 0000011E 5A                      	pop	dx				;Throw away flags on stack	;AN000;
   320 0000011F 1F                      	pop	ds				;
   321 00000120 07                      	pop	es				;				;AN000;
   322 00000121 5D                      	pop	bp				;				;AN000;
   323 00000122 5F                      	pop	di				;				;AN000;
   324 00000123 5E                      	pop	si				;				;AN000;
   325 00000124 5A                      	pop	dx				;Restore registers		;AN000;
   326 00000125 59                      	pop	cx				;				;AN000;
   327 00000126 5B                      	pop	bx				;				;AN000;
   328 00000127 C3                      	ret					;				;AN000;
   329                                  
   330                                  
   331                                  Read_Disk endp					;				;AN000;
   332                                  
   333                                  ;*****************************************************************************
   334                                  ;Routine name: Write_Disk
   335                                  ;*****************************************************************************
   336                                  ;
   337                                  ;description: Write Data using Generic IOCtl
   338                                  ;
   339                                  ;Called Procedures: None
   340                                  ;
   341                                  ;
   342                                  ;Change History: Created	5/13/87 	MT
   343                                  ;
   344                                  ;Input: AL = Drive number (0=A)
   345                                  ;	DS:BX = Transfer address
   346                                  ;	CX = Number of sectors
   347                                  ;	Read_Write_Relative.Start_Sector_High = Number of sectors high
   348                                  ;	DX = logical sector number low
   349                                  ;
   350                                  ;Output: CY if error
   351                                  ;	 AH = INT 26h error code
   352                                  ;
   353                                  ;Psuedocode
   354                                  ;----------
   355                                  ;	Save registers
   356                                  ;	Setup structure for function call
   357                                  ;	Write to disk (AX=440Dh, CL = 4Fh)
   358                                  ;	Restore registers
   359                                  ;	ret
   360                                  ;*****************************************************************************
   361                                  
   362                                  Procedure Write_Disk				;				;AN000;
   363                                  
   364                                  
   365                                  						;This is setup for INT 26h right
   366                                  						;Change it to Read relative sect
   367                                  
   368 00000128 53                      	push	bx				;Save registers 		;AN000;
   369 00000129 51                      	push	cx				;				;AN000;
   370 0000012A 52                      	push	dx				;				;AN000;
   371 0000012B 56                      	push	si				;				;AN000;
   372 0000012C 57                      	push	di				;				;AN000;
   373 0000012D 55                      	push	bp				;				;AN000;
   374 0000012E 06                      	push	es				;				;AN000;
   375 0000012F 1E                      	push	ds				;
   376 00000130 BE[ssss]                	mov	si,data 			;				;AN000;
   377 00000133 8EC6                    	mov	es,si				;				;AN000;
   378                                  
   379                                  	assume	es:data,ds:nothing		;				;AN000;
   380                                  
   381 00000135 26891E[0600]            	mov	[es:Read_Write_Relative + Buffer_Offset],bx ;Get transfer buffer add;AN000;
   382 0000013A 8CDB                    	mov	bx,ds				;				;AN000;
   383 0000013C 26891E[0800]            	mov	[es:Read_Write_Relative + Buffer_Segment],bx ;Get segment		;AN000;
   384 00000141 BB[ssss]                	mov	bx,data 			;Point DS at parameter list	;AN000;
   385 00000144 8EDB                    	mov	ds,bx				;				;AN000;
   386                                  
   387                                  	assume	ds:data,es:data
   388                                  
   389 00000146 890E[0400]              	mov	[Read_Write_Relative + Number_Sectors],cx ;Number of sec to write	;AN000;
   390 0000014A 8916[0000]              	mov	[Read_Write_Relative + Start_Sector_Low],dx ;Start sector		;AN000;
   391 0000014E BB[0000]                	mov	bx,offset Read_Write_Relative	;				;AN000;
   392 00000151 B9FFFF                  	mov	cx,0FFFFh			;Write relative sector		;AN000;
   393 00000154 CD26                    	INT	26h				;Do the write			;AN000;
   394 00000156 5A                      	pop	dx				;Throw away flags on stack	;AN000;
   395 00000157 1F                      	pop	ds				;				;AN000;
   396 00000158 07                      	pop	es				;				;AN000;
   397 00000159 5D                      	pop	bp				;				;AN000;
   398 0000015A 5F                      	pop	di				;				;AN000;
   399 0000015B 5E                      	pop	si				;				;AN000;
   400 0000015C 5A                      	pop	dx				;Restore registers		;AN000;
   401 0000015D 59                      	pop	cx				;				;AN000;
   402 0000015E 5B                      	pop	bx				;				;AN000;
   403 0000015F C3                      	ret					;				;AN000;
   404                                  
   405                                  Write_Disk endp 				;				;AN000;
   406                                  
   407                                  ;=========================================================================
   408                                  ; Calc_Total_Addressible_Space	: Calculate the total space that is
   409                                  ;				  addressible on the the disk by DOS.
   410                                  ;
   411                                  ;	Inputs	: none
   412                                  ;
   413                                  ;	Outputs : Fdsksiz - Size in bytes of the disk
   414                                  ;=========================================================================
   415                                  
   416                                  Procedure Calc_Total_Addressible_Space		;an013; dms;
   417                                  
   418 00000160 50                      	push	ax				;an013; dms;save affected regs
   419 00000161 52                      	push	dx				;an013; dms;
   420 00000162 53                      	push	bx				;an013; dms;
   421                                  
   422 00000163 E84C00                  	call	Get_Free_Space			;an013; dms;get free disk space
   423                                  
   424 00000166 53                      	push	bx				;an013; dms;save avail. cluster
   425 00000167 52                      	push	dx				;an013; dms;save total. cluster
   426                                  
   427 00000168 89D0                    	mov	ax,dx				;an013; dms;get total clusters
   428                                  
   429 0000016A 31DB                    	xor	bx,bx				;an013; dms;clear bx
   430 0000016C 31C9                    	xor	cx,cx				;an013; dms;clear cx
   431                                  DeviceParameters equ deviceParameters	; NASM port label
   432 0000016E 8A0E[0900]              	mov	cl,[DeviceParameters + DP_BPB + BPB_SectorsPerCluster]  ;an013; dms;get total sectors
   433 00000172 E8(0000)                	call	Multiply_32_Bits		;an013; dms;multiply
   434                                  
   435 00000175 31C9                    	xor	cx,cx				;an013; dms;clear cx
   436 00000177 8B0E[0700]              	mov	cx,[DeviceParameters + DP_BPB + BPB_BytesPerSector]  ;an013; dms;get total bytes
   437 0000017B E8(0000)                	call	Multiply_32_Bits		;an013; dms; multiply
   438                                  
   439 0000017E A3[0000]                	mov	word ptr [Fdsksiz],ax		;an013; dms;save high word
   440 00000181 891E[0200]              	mov	word ptr [Fdsksiz+2],bx		;an013; dms;save low word
   441                                  
   442 00000185 5A                      	pop	dx				;an000; dms;get total clusters
   443 00000186 5B                      	pop	bx				;an000; dms;get avail clusters
   444                                  
   445 00000187 89D0                    	mov	ax,dx				;an013; dms;get total clusters
   446 00000189 29D8                    	sub	ax,bx				;an013; dms;get bad clusters
   447                                  
   448 0000018B 31DB                    	xor	bx,bx				;an013; dms;clear bx
   449 0000018D 31C9                    	xor	cx,cx				;an013; dms;clear cx
   450 0000018F 8A0E[0900]              	mov	cl,[DeviceParameters + DP_BPB + BPB_SectorsPerCluster]  ;an013; dms;get total sectors
   451 00000193 E8(0000)                	call	Multiply_32_Bits		;an013; dms;multiply
   452                                  
   453 00000196 31C9                    	xor	cx,cx				;an013; dms;clear cx
   454 00000198 8B0E[0700]              	mov	cx,[DeviceParameters + DP_BPB + BPB_BytesPerSector]  ;an013; dms;get total bytes
   455 0000019C E8(0000)                	call	Multiply_32_Bits		;an013; dms; multiply
   456                                  
   457 0000019F 2B06[0400]              	sub	ax,word ptr [syssiz]		;an013; dms;account for system
   458 000001A3 1B1E[0600]              	sbb	bx,word ptr [syssiz+2]		;an013; dms;size
   459                                  
   460                                  Badsiz equ badsiz	; NASM port label
   461 000001A7 A3[0C00]                	mov	word ptr [Badsiz],ax		;an013; dms;save high word
   462 000001AA 891E[0E00]              	mov	word ptr [Badsiz+2],bx		;an013; dms;save low word
   463                                  
   464 000001AE 5B                      	pop	bx				;an013; dms;
   465 000001AF 5A                      	pop	dx				;an013; dms;restore regs
   466 000001B0 58                      	pop	ax				;an013; dms;
   467                                  
   468 000001B1 C3                      	ret					;an013; dms;
   469                                  
   470                                  Calc_Total_Addressible_Space	endp		;an013; dms;
   471                                  
   472                                  
   473                                  ;=========================================================================
   474                                  ; Get_Free_Space	: Get the free space on the disk.
   475                                  ;
   476                                  ;	Inputs	: none
   477                                  ;
   478                                  ;	Outputs : BX - Available space in clusters
   479                                  ;		  DX - Total space in clusters
   480                                  ;=========================================================================
   481                                  
   482                                  Procedure Get_Free_Space			;an013; dms;
   483                                  
   484 000001B2 31C0                    	xor	ax,ax				;an013; dms;clear ax
   485 000001B4 B436                    	mov	ah,36h				;an013; dms;Get disk free space
   486                                  driveletter equ driveLetter	; NASM port label
   487 000001B6 8A16[0000]              	mov	dl,[driveletter]			;an013; dms;get drive letter
   488 000001BA 80EA41                  	sub	dl,"A"				;an013; dms;get 0 based number
   489 000001BD FEC2                    	inc	dl				;an013; dms;make it 1 based
   490 000001BF CD21                    	int	21h				;an013; dms;
   491 000001C1 C3                      	ret					;an013; dms;
   492                                  
   493                                  Get_Free_Space	endp				;an013; dms;
   494                                  
   495                                  ;=========================================================================
   496                                  ; Calc_System_Space	: This routine calculates the space occupied by
   497                                  ;			  the system on the disk.
   498                                  ;
   499                                  ;	Inputs	: DOS.FileSizeInBytes
   500                                  ;		  BIOS.FileSizeInBytes
   501                                  ;		  Command.FileSizeInBytes
   502                                  ;
   503                                  ;	Outputs : SysSiz			- Size of the system
   504                                  ;=========================================================================
   505                                  
   506                                  Procedure Calc_System_Space							;an013; dms;
   507                                  
   508 000001C2 50                      	push	ax								;an013; dms;save regs
   509 000001C3 52                      	push	dx								;an013; dms;
   510                                  
   511                                  SysSiz equ syssiz	; NASM port label
   512 000001C4 C706[0400]0000          	mov	word [SysSiz+0],00h						;an013; dms;clear variable
   513 000001CA C706[0600]0000          	mov	word [SysSiz+2],00h						;an013; dms;
   514                                  
   515                                  DOS equ dos	; NASM port label
   516                                  FileSizeInBytes equ fileSizeInBytes	; NASM port equate
   517 000001D0 A1[0400]                	mov	ax,word ptr [DOS + FileSizeInBytes+0]				;an013; dms;get low word
   518 000001D3 8B16[0600]              	mov	dx,word ptr [DOS + FileSizeInBytes+2]				;an013; dms;get high word
   519 000001D7 E8(0000)                	call	AddToSystemSize 						;an013; dms;add in values
   520                                  
   521                                  BIOS equ bios	; NASM port label
   522 000001DA A1[0400]                	mov	ax,word ptr [BIOS + FileSizeInBytes+0]				;an013; dms;get bios size
   523 000001DD 8B16[0600]              	mov	dx,word ptr [BIOS + FileSizeInBytes+2]				;an013; dms;
   524 000001E1 E8(0000)                	call	AddToSystemSize 						;an013; dms;add in values
   525                                  
   526                                  COMMAND equ command	; NASM port label
   527 000001E4 A1[0400]                	mov	ax,word ptr [COMMAND + FileSizeInBytes+0] 			;an013; dms;get command size
   528 000001E7 8B16[0600]              	mov	dx,word ptr [COMMAND + FileSizeInBytes+2] 			;an013; dms;
   529 000001EB E8(0000)                	call	AddToSystemSize 						;an013; dms;add in values
   530                                  
   531 000001EE 5A                      	pop	dx								;an013; dms;restore regs
   532 000001EF 58                      	pop	ax								;an013; dms;
   533                                  
   534 000001F0 C3                      	ret									;an013; dms;
   535                                  
   536                                  Calc_System_Space	endp							;an013; dms;
   537                                  
   538                                  
   539                                  
   540                                  ; (no prior section) ; code	ends
   541                                  	end
   542                                  
