diff options
| author | 2024-04-25 21:24:10 +0100 | |
|---|---|---|
| committer | 2024-04-25 22:32:27 +0000 | |
| commit | 2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch) | |
| tree | 80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/CMD/FORMAT/FORPROC.ASM | |
| parent | Merge pull request #430 from jpbaltazar/typoptbr (diff) | |
| download | ms-dos-main.tar.gz ms-dos-main.tar.xz ms-dos-main.zip | |
Diffstat (limited to 'v4.0/src/CMD/FORMAT/FORPROC.ASM')
| -rw-r--r-- | v4.0/src/CMD/FORMAT/FORPROC.ASM | 521 |
1 files changed, 521 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FORMAT/FORPROC.ASM b/v4.0/src/CMD/FORMAT/FORPROC.ASM new file mode 100644 index 0000000..bbf139a --- /dev/null +++ b/v4.0/src/CMD/FORMAT/FORPROC.ASM | |||
| @@ -0,0 +1,521 @@ | |||
| 1 | ; SCCSID = @(#)forproc.asm 1.2 85/07/25 | ||
| 2 | ; | ||
| 3 | .xlist | ||
| 4 | .xcref | ||
| 5 | BREAK MACRO subtitle | ||
| 6 | SUBTTL subtitle | ||
| 7 | PAGE | ||
| 8 | ENDM | ||
| 9 | |||
| 10 | INCLUDE FORCHNG.INC | ||
| 11 | INCLUDE SYSCALL.INC | ||
| 12 | INCLUDE FOREQU.INC | ||
| 13 | INCLUDE FORMACRO.INC | ||
| 14 | INCLUDE FORSWTCH.INC | ||
| 15 | INCLUDE IOCTL.INC | ||
| 16 | .cref | ||
| 17 | .list | ||
| 18 | data segment public para 'DATA' | ||
| 19 | data ends | ||
| 20 | |||
| 21 | code segment public para 'CODE' | ||
| 22 | assume cs:code,ds:data | ||
| 23 | |||
| 24 | PUBLIC FormatAnother?,Yes?,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 | data segment public para '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 | fdsksiz dd 0 | ||
| 56 | |||
| 57 | syssiz dd 0 | ||
| 58 | biosiz dd 0 | ||
| 59 | |||
| 60 | badsiz dd 0 | ||
| 61 | |||
| 62 | datasiz dd 0 | ||
| 63 | |||
| 64 | AllocSize dd 0 ; ;AN000; | ||
| 65 | AllocNum dw 0 ; ;AN000; | ||
| 66 | dw offset driveLetter | ||
| 67 | 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 | Message msgFormatAnother? ; ;AC000; | ||
| 73 | CALL Yes? | ||
| 74 | JNC WAIT20 | ||
| 75 | JZ WAIT20 | ||
| 76 | CALL CRLF | ||
| 77 | JMP SHORT FormatAnother? | ||
| 78 | WAIT20: ; ;AC000; | ||
| 79 | RET ; ;AC000; | ||
| 80 | FormatAnother? endp | ||
| 81 | |||
| 82 | ;***************************************************************************** | ||
| 83 | ;Routine name:Yes? | ||
| 84 | ;***************************************************************************** | ||
| 85 | ; | ||
| 86 | ;Description: Validate that input is valid Y/N for the country dependent info | ||
| 87 | ; Wait for key. If YES return carry clear,else carry set. | ||
| 88 | ; If carry is set, Z is set if explicit NO, else key was not Yes or No. | ||
| 89 | ; | ||
| 90 | ;Called Procedures: Message (macro) | ||
| 91 | ; User_String | ||
| 92 | ; | ||
| 93 | ;Change History: Created 4/32/87 MT | ||
| 94 | ; | ||
| 95 | ;Input: None | ||
| 96 | ; | ||
| 97 | ;Output: CY = 0 Yes is entered | ||
| 98 | ; CY = 1, Z = No | ||
| 99 | ; CY = 1, NZ = other | ||
| 100 | ; | ||
| 101 | ;Psuedocode | ||
| 102 | ;---------- | ||
| 103 | ; | ||
| 104 | ; Get input (CALL USER STRING) | ||
| 105 | ; IF got character | ||
| 106 | ; Check for country dependent Y/N (INT 21h, AX=6523h Get Ext Country) | ||
| 107 | ; IF Yes | ||
| 108 | ; clc | ||
| 109 | ; ELSE (No) | ||
| 110 | ; IF No | ||
| 111 | ; stc | ||
| 112 | ; Set Zero flag | ||
| 113 | ; ELSE (Other) | ||
| 114 | ; stc | ||
| 115 | ; Set NZ | ||
| 116 | ; ENDIF | ||
| 117 | ; ENDIF | ||
| 118 | ; ELSE (nothing entered) | ||
| 119 | ; stc | ||
| 120 | ; Set NZ flag | ||
| 121 | ; ENDIF | ||
| 122 | ; ret | ||
| 123 | ;***************************************************************************** | ||
| 124 | |||
| 125 | Procedure YES? ; ;AN000; | ||
| 126 | |||
| 127 | call User_String ;Get character ; ; | ||
| 128 | ; $IF NZ ;Got one if returned NZ ;AC000; | ||
| 129 | JZ $$IF1 | ||
| 130 | mov al,23h ;See if it is Y/N ;AN000; | ||
| 131 | mov dl,[InBuff+2] ;Get character ;AN000; | ||
| 132 | DOS_Call GetExtCntry ;Get country info call ;AN000; | ||
| 133 | cmp ax,Found_Yes ;Which one? ;AC000; | ||
| 134 | ; $IF E ;Got a Yes ;AC000; | ||
| 135 | JNE $$IF2 | ||
| 136 | clc ;Clear CY for return ;AN000; | ||
| 137 | ; $ELSE ;Not a Yes ;AN000; | ||
| 138 | JMP SHORT $$EN2 | ||
| 139 | $$IF2: | ||
| 140 | cmp ax,Found_No ;Is it No? ;AC000; | ||
| 141 | ; $IF E ;Yep ;AN000; | ||
| 142 | JNE $$IF4 | ||
| 143 | stc ;Set CY for return ;AC000; | ||
| 144 | ; $ELSE ;Something else we don't want ;AN000; | ||
| 145 | JMP SHORT $$EN4 | ||
| 146 | $$IF4: | ||
| 147 | xor al,al ;Set NZ flag for ret ;AC000; | ||
| 148 | cmp al,1 ; " " " " ;AC000; | ||
| 149 | stc ;And CY flag for good measure ;AN000; | ||
| 150 | ; $ENDIF ; ;AN000; | ||
| 151 | $$EN4: | ||
| 152 | ; $ENDIF ; ;AN000; | ||
| 153 | $$EN2: | ||
| 154 | ; $ELSE ;No char found at all ;AN000; | ||
| 155 | JMP SHORT $$EN1 | ||
| 156 | $$IF1: | ||
| 157 | xor al,al ;Set NZ flag for ret ;AN000; | ||
| 158 | cmp al,1 ; " " " " ;AN000; | ||
| 159 | stc ;And CY flag for good measure ;AN000; | ||
| 160 | ; $ENDIF ; ;AN000; | ||
| 161 | $$EN1: | ||
| 162 | ret ; ; ; | ||
| 163 | |||
| 164 | Yes? endp ; ;AN000; | ||
| 165 | |||
| 166 | |||
| 167 | USER_STRING: | ||
| 168 | ; Get a string from user. Z is set if user typed no chars (imm CR) | ||
| 169 | ; We need to flush a second time to get rid of incoming Kanji characters also. | ||
| 170 | MOV AX,(STD_CON_INPUT_FLUSH SHL 8) + 0 ; Clean out input | ||
| 171 | INT 21H | ||
| 172 | MOV DX,OFFSET INBUFF | ||
| 173 | MOV AH,STD_CON_STRING_INPUT | ||
| 174 | INT 21H | ||
| 175 | MOV AX,(STD_CON_INPUT_FLUSH SHL 8) + 0 ; Clean out input | ||
| 176 | INT 21H | ||
| 177 | CMP BYTE PTR [INBUFF+1],0 | ||
| 178 | RET | ||
| 179 | |||
| 180 | ;********************************************* | ||
| 181 | ; Make a status report including the following information: | ||
| 182 | ; Total disk capacity | ||
| 183 | ; Total system area used | ||
| 184 | ; Total bad space allocated | ||
| 185 | ; Total data space available | ||
| 186 | ; Number of allocation units | ||
| 187 | ; Size of allocation units | ||
| 188 | |||
| 189 | REPORT: | ||
| 190 | call crlf | ||
| 191 | |||
| 192 | call Calc_System_Space ;an013; dms;calc system space | ||
| 193 | call Calc_Total_Addressible_Space ;an013; dms;calc total space | ||
| 194 | |||
| 195 | Message msgTotalDiskSpace ; ;AC000; | ||
| 196 | ;call std_printf | ||
| 197 | cmp WORD PTR SYSSIZ,0 | ||
| 198 | JNZ SHOWSYS | ||
| 199 | cmp WORD PTR SYSSIZ+2,0 | ||
| 200 | JZ CHKBAD | ||
| 201 | SHOWSYS: | ||
| 202 | Message msgSystemSpace ; ;AC000; | ||
| 203 | ;CALL std_printf ;Report space used by system | ||
| 204 | CHKBAD: | ||
| 205 | cmp WORD PTR BADSIZ,0 | ||
| 206 | JNZ SHOWBAD | ||
| 207 | cmp WORD PTR BADSIZ+2,0 | ||
| 208 | JZ SHOWDATA | ||
| 209 | SHOWBAD: | ||
| 210 | Message msgBadSpace ; ;AC000; | ||
| 211 | ;call std_printf | ||
| 212 | SHOWDATA: | ||
| 213 | |||
| 214 | |||
| 215 | MOV CX,WORD PTR Fdsksiz | ||
| 216 | MOV BX,WORD PTR Fdsksiz+2 | ||
| 217 | SUB CX,WORD PTR BADSIZ | ||
| 218 | SBB BX,WORD PTR BADSIZ+2 | ||
| 219 | SUB CX,WORD PTR SYSSIZ | ||
| 220 | SBB BX,WORD PTR SYSSIZ+2 | ||
| 221 | MOV word ptr datasiz,CX | ||
| 222 | MOV word ptr datasiz+2,BX | ||
| 223 | Message msgDataSpace ; ;AC000; | ||
| 224 | ;call std_printf | ||
| 225 | |||
| 226 | call crlf ; ;AN000; | ||
| 227 | mov ax,deviceParameters.DP_BPB.BPB_BytesPerSector ; ;AN000; | ||
| 228 | mov cl,deviceParameters.DP_BPB.BPB_SectorsPerCluster ; ;AN000; | ||
| 229 | xor ch,ch ; ;AN000; | ||
| 230 | mul cx ;Get bytes per alloc ;AN000; | ||
| 231 | |||
| 232 | mov word ptr AllocSize,ax ;Save allocation size ;AN000; | ||
| 233 | mov word ptr AllocSize+2,dx ; for message ;AN000; | ||
| 234 | Message msgAllocSize ;Print size of cluster ;AN000; | ||
| 235 | call Get_Free_Space ;an013; dms;get disk space | ||
| 236 | |||
| 237 | mov word ptr AllocNum,bx ;Put result in msg ;AN000; | ||
| 238 | Message msgAllocNum ; = cluster/disk ;AN000; | ||
| 239 | call crlf ; ;AN000; | ||
| 240 | test switchmap, SWITCH_8 ;If 8 tracks, don't display ;AN027; | ||
| 241 | jnz NOSERIALNUMBER ;serial number ;AN027; | ||
| 242 | Message msgSerialNumber ;Spit out serial number ;AN000; | ||
| 243 | call crlf ; | ||
| 244 | NOSERIALNUMBER: ;AN027; | ||
| 245 | RET ; | ||
| 246 | |||
| 247 | ;***************************************************************************** | ||
| 248 | ;Routine name: Read_Disk | ||
| 249 | ;***************************************************************************** | ||
| 250 | ; | ||
| 251 | ;description: Read in data using Generic IOCtl | ||
| 252 | ; | ||
| 253 | ;Called Procedures: None | ||
| 254 | ; | ||
| 255 | ; | ||
| 256 | ;Change History: Created 5/13/87 MT | ||
| 257 | ; | ||
| 258 | ;Input: AL = Drive number (0=A) | ||
| 259 | ; DS:BX = Transfer address | ||
| 260 | ; CX = Number of sectors | ||
| 261 | ; Read_Write_Relative.Start_Sector_High = Number of sectors high | ||
| 262 | ; DX = logical sector number low | ||
| 263 | ; | ||
| 264 | ;Output: CY if error | ||
| 265 | ; AH = INT 25h error code | ||
| 266 | ; | ||
| 267 | ;Psuedocode | ||
| 268 | ;---------- | ||
| 269 | ; Save registers | ||
| 270 | ; Setup structure for function call | ||
| 271 | ; Read the disk (AX=440Dh, CL = 6Fh) | ||
| 272 | ; Restore registers | ||
| 273 | ; ret | ||
| 274 | ;***************************************************************************** | ||
| 275 | |||
| 276 | Procedure Read_Disk ; ;AN000; | ||
| 277 | |||
| 278 | ;This is setup for INT 25h right;AN000; | ||
| 279 | ;Change it to Read relative sect;AN000; | ||
| 280 | push bx ;Save registers ;AN000; | ||
| 281 | push cx ; ;AN000; | ||
| 282 | push dx ; ;AN000; | ||
| 283 | push si ; ;AN000; | ||
| 284 | push di ; ;AN000; | ||
| 285 | push bp ; ;AN000; | ||
| 286 | push es ; ;AN000; | ||
| 287 | push ds ; | ||
| 288 | mov si,data ; ;AN000; | ||
| 289 | mov es,si ; ;AN000; | ||
| 290 | |||
| 291 | assume es:data,ds:nothing ; ;AN000; | ||
| 292 | |||
| 293 | mov es:Read_Write_Relative.Buffer_Offset,bx ;Get transfer buffer add;AN000; | ||
| 294 | mov bx,ds ; ;AN000; | ||
| 295 | mov es:Read_Write_Relative.Buffer_Segment,bx ;Get segment ;AN000; | ||
| 296 | mov bx,data ;Point DS at parameter list ;AN000; | ||
| 297 | mov ds,bx ; ;AN000; | ||
| 298 | |||
| 299 | assume ds:data,es:data | ||
| 300 | |||
| 301 | mov Read_Write_Relative.Number_Sectors,cx ;Number of sec to read ;AN000; | ||
| 302 | mov Read_Write_Relative.Start_Sector_Low,dx ;Start sector ;AN000; | ||
| 303 | mov bx,offset Read_Write_Relative ; ;AN000; | ||
| 304 | mov cx,0FFFFh ;Read relative sector ;AN000; | ||
| 305 | INT 25h ;Do the read ;AN000; | ||
| 306 | pop dx ;Throw away flags on stack ;AN000; | ||
| 307 | pop ds ; | ||
| 308 | pop es ; ;AN000; | ||
| 309 | pop bp ; ;AN000; | ||
| 310 | pop di ; ;AN000; | ||
| 311 | pop si ; ;AN000; | ||
| 312 | pop dx ;Restore registers ;AN000; | ||
| 313 | pop cx ; ;AN000; | ||
| 314 | pop bx ; ;AN000; | ||
| 315 | ret ; ;AN000; | ||
| 316 | |||
| 317 | |||
| 318 | Read_Disk endp ; ;AN000; | ||
| 319 | |||
| 320 | ;***************************************************************************** | ||
| 321 | ;Routine name: Write_Disk | ||
| 322 | ;***************************************************************************** | ||
| 323 | ; | ||
| 324 | ;description: Write Data using Generic IOCtl | ||
| 325 | ; | ||
| 326 | ;Called Procedures: None | ||
| 327 | ; | ||
| 328 | ; | ||
| 329 | ;Change History: Created 5/13/87 MT | ||
| 330 | ; | ||
| 331 | ;Input: AL = Drive number (0=A) | ||
| 332 | ; DS:BX = Transfer address | ||
| 333 | ; CX = Number of sectors | ||
| 334 | ; Read_Write_Relative.Start_Sector_High = Number of sectors high | ||
| 335 | ; DX = logical sector number low | ||
| 336 | ; | ||
| 337 | ;Output: CY if error | ||
| 338 | ; AH = INT 26h error code | ||
| 339 | ; | ||
| 340 | ;Psuedocode | ||
| 341 | ;---------- | ||
| 342 | ; Save registers | ||
| 343 | ; Setup structure for function call | ||
| 344 | ; Write to disk (AX=440Dh, CL = 4Fh) | ||
| 345 | ; Restore registers | ||
| 346 | ; ret | ||
| 347 | ;***************************************************************************** | ||
| 348 | |||
| 349 | Procedure Write_Disk ; ;AN000; | ||
| 350 | |||
| 351 | |||
| 352 | ;This is setup for INT 26h right | ||
| 353 | ;Change it to Read relative sect | ||
| 354 | |||
| 355 | push bx ;Save registers ;AN000; | ||
| 356 | push cx ; ;AN000; | ||
| 357 | push dx ; ;AN000; | ||
| 358 | push si ; ;AN000; | ||
| 359 | push di ; ;AN000; | ||
| 360 | push bp ; ;AN000; | ||
| 361 | push es ; ;AN000; | ||
| 362 | push ds ; | ||
| 363 | mov si,data ; ;AN000; | ||
| 364 | mov es,si ; ;AN000; | ||
| 365 | |||
| 366 | assume es:data,ds:nothing ; ;AN000; | ||
| 367 | |||
| 368 | mov es:Read_Write_Relative.Buffer_Offset,bx ;Get transfer buffer add;AN000; | ||
| 369 | mov bx,ds ; ;AN000; | ||
| 370 | mov es:Read_Write_Relative.Buffer_Segment,bx ;Get segment ;AN000; | ||
| 371 | mov bx,data ;Point DS at parameter list ;AN000; | ||
| 372 | mov ds,bx ; ;AN000; | ||
| 373 | |||
| 374 | assume ds:data,es:data | ||
| 375 | |||
| 376 | mov Read_Write_Relative.Number_Sectors,cx ;Number of sec to write ;AN000; | ||
| 377 | mov Read_Write_Relative.Start_Sector_Low,dx ;Start sector ;AN000; | ||
| 378 | mov bx,offset Read_Write_Relative ; ;AN000; | ||
| 379 | mov cx,0FFFFh ;Write relative sector ;AN000; | ||
| 380 | INT 26h ;Do the write ;AN000; | ||
| 381 | pop dx ;Throw away flags on stack ;AN000; | ||
| 382 | pop ds ; ;AN000; | ||
| 383 | pop es ; ;AN000; | ||
| 384 | pop bp ; ;AN000; | ||
| 385 | pop di ; ;AN000; | ||
| 386 | pop si ; ;AN000; | ||
| 387 | pop dx ;Restore registers ;AN000; | ||
| 388 | pop cx ; ;AN000; | ||
| 389 | pop bx ; ;AN000; | ||
| 390 | ret ; ;AN000; | ||
| 391 | |||
| 392 | Write_Disk endp ; ;AN000; | ||
| 393 | |||
| 394 | ;========================================================================= | ||
| 395 | ; Calc_Total_Addressible_Space : Calculate the total space that is | ||
| 396 | ; addressible on the the disk by DOS. | ||
| 397 | ; | ||
| 398 | ; Inputs : none | ||
| 399 | ; | ||
| 400 | ; Outputs : Fdsksiz - Size in bytes of the disk | ||
| 401 | ;========================================================================= | ||
| 402 | |||
| 403 | Procedure Calc_Total_Addressible_Space ;an013; dms; | ||
| 404 | |||
| 405 | push ax ;an013; dms;save affected regs | ||
| 406 | push dx ;an013; dms; | ||
| 407 | push bx ;an013; dms; | ||
| 408 | |||
| 409 | call Get_Free_Space ;an013; dms;get free disk space | ||
| 410 | |||
| 411 | push bx ;an013; dms;save avail. cluster | ||
| 412 | push dx ;an013; dms;save total. cluster | ||
| 413 | |||
| 414 | mov ax,dx ;an013; dms;get total clusters | ||
| 415 | |||
| 416 | xor bx,bx ;an013; dms;clear bx | ||
| 417 | xor cx,cx ;an013; dms;clear cx | ||
| 418 | mov cl,DeviceParameters.DP_BPB.BPB_SectorsPerCluster ;an013; dms;get total sectors | ||
| 419 | call Multiply_32_Bits ;an013; dms;multiply | ||
| 420 | |||
| 421 | xor cx,cx ;an013; dms;clear cx | ||
| 422 | mov cx,DeviceParameters.DP_BPB.BPB_BytesPerSector ;an013; dms;get total bytes | ||
| 423 | call Multiply_32_Bits ;an013; dms; multiply | ||
| 424 | |||
| 425 | mov word ptr Fdsksiz,ax ;an013; dms;save high word | ||
| 426 | mov word ptr Fdsksiz+2,bx ;an013; dms;save low word | ||
| 427 | |||
| 428 | pop dx ;an000; dms;get total clusters | ||
| 429 | pop bx ;an000; dms;get avail clusters | ||
| 430 | |||
| 431 | mov ax,dx ;an013; dms;get total clusters | ||
| 432 | sub ax,bx ;an013; dms;get bad clusters | ||
| 433 | |||
| 434 | xor bx,bx ;an013; dms;clear bx | ||
| 435 | xor cx,cx ;an013; dms;clear cx | ||
| 436 | mov cl,DeviceParameters.DP_BPB.BPB_SectorsPerCluster ;an013; dms;get total sectors | ||
| 437 | call Multiply_32_Bits ;an013; dms;multiply | ||
| 438 | |||
| 439 | xor cx,cx ;an013; dms;clear cx | ||
| 440 | mov cx,DeviceParameters.DP_BPB.BPB_BytesPerSector ;an013; dms;get total bytes | ||
| 441 | call Multiply_32_Bits ;an013; dms; multiply | ||
| 442 | |||
| 443 | sub ax,word ptr syssiz ;an013; dms;account for system | ||
| 444 | sbb bx,word ptr syssiz+2 ;an013; dms;size | ||
| 445 | |||
| 446 | mov word ptr Badsiz,ax ;an013; dms;save high word | ||
| 447 | mov word ptr Badsiz+2,bx ;an013; dms;save low word | ||
| 448 | |||
| 449 | pop bx ;an013; dms; | ||
| 450 | pop dx ;an013; dms;restore regs | ||
| 451 | pop ax ;an013; dms; | ||
| 452 | |||
| 453 | ret ;an013; dms; | ||
| 454 | |||
| 455 | Calc_Total_Addressible_Space endp ;an013; dms; | ||
| 456 | |||
| 457 | |||
| 458 | ;========================================================================= | ||
| 459 | ; Get_Free_Space : Get the free space on the disk. | ||
| 460 | ; | ||
| 461 | ; Inputs : none | ||
| 462 | ; | ||
| 463 | ; Outputs : BX - Available space in clusters | ||
| 464 | ; DX - Total space in clusters | ||
| 465 | ;========================================================================= | ||
| 466 | |||
| 467 | Procedure Get_Free_Space ;an013; dms; | ||
| 468 | |||
| 469 | xor ax,ax ;an013; dms;clear ax | ||
| 470 | mov ah,36h ;an013; dms;Get disk free space | ||
| 471 | mov dl,driveletter ;an013; dms;get drive letter | ||
| 472 | sub dl,"A" ;an013; dms;get 0 based number | ||
| 473 | inc dl ;an013; dms;make it 1 based | ||
| 474 | int 21h ;an013; dms; | ||
| 475 | ret ;an013; dms; | ||
| 476 | |||
| 477 | Get_Free_Space endp ;an013; dms; | ||
| 478 | |||
| 479 | ;========================================================================= | ||
| 480 | ; Calc_System_Space : This routine calculates the space occupied by | ||
| 481 | ; the system on the disk. | ||
| 482 | ; | ||
| 483 | ; Inputs : DOS.FileSizeInBytes | ||
| 484 | ; BIOS.FileSizeInBytes | ||
| 485 | ; Command.FileSizeInBytes | ||
| 486 | ; | ||
| 487 | ; Outputs : SysSiz - Size of the system | ||
| 488 | ;========================================================================= | ||
| 489 | |||
| 490 | Procedure Calc_System_Space ;an013; dms; | ||
| 491 | |||
| 492 | push ax ;an013; dms;save regs | ||
| 493 | push dx ;an013; dms; | ||
| 494 | |||
| 495 | mov word ptr SysSiz+0,00h ;an013; dms;clear variable | ||
| 496 | mov word ptr SysSiz+2,00h ;an013; dms; | ||
| 497 | |||
| 498 | mov ax,word ptr [DOS.FileSizeInBytes+0] ;an013; dms;get low word | ||
| 499 | mov dx,word ptr [DOS.FileSizeInBytes+2] ;an013; dms;get high word | ||
| 500 | call AddToSystemSize ;an013; dms;add in values | ||
| 501 | |||
| 502 | mov ax,word ptr [BIOS.FileSizeInBytes+0] ;an013; dms;get bios size | ||
| 503 | mov dx,word ptr [BIOS.FileSizeInBytes+2] ;an013; dms; | ||
| 504 | call AddToSystemSize ;an013; dms;add in values | ||
| 505 | |||
| 506 | mov ax,word ptr [COMMAND.FileSizeInBytes+0] ;an013; dms;get command size | ||
| 507 | mov dx,word ptr [COMMAND.FileSizeInBytes+2] ;an013; dms; | ||
| 508 | call AddToSystemSize ;an013; dms;add in values | ||
| 509 | |||
| 510 | pop dx ;an013; dms;restore regs | ||
| 511 | pop ax ;an013; dms; | ||
| 512 | |||
| 513 | ret ;an013; dms; | ||
| 514 | |||
| 515 | Calc_System_Space endp ;an013; dms; | ||
| 516 | |||
| 517 | |||
| 518 | |||
| 519 | code ends | ||
| 520 | end | ||
| 521 | \ No newline at end of file | ||