1 ; SCCSID = @(#)forproc.asm 1.2 85/07/25
18 data segment public para
'DATA'
21 code segment public para
'CODE'
22 assume
cs:code,ds:data
24 PUBLIC FormatAnother?
,Yes?
,REPORT
,USER_STRING
25 public fdsksiz
,badsiz
,syssiz
,datasiz
,biosiz
26 public AllocSize
,AllocNum
28 extrn std_printf
:near,crlf
:near,PrintString
:near
29 extrn Multiply_32_Bits
:near
30 extrn AddToSystemSize
:near
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
47 extrn Serial_Num_Low
:Word
48 extrn Serial_Num_High
:Word
49 extrn msgSerialNumber
:Byte
64 AllocSize dd 0 ; ;AN000;
65 AllocNum dw 0 ; ;AN000;
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;
77 JMP SHORT FormatAnother?
82 ;*****************************************************************************
84 ;*****************************************************************************
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.
90 ;Called Procedures: Message (macro)
93 ;Change History: Created 4/32/87 MT
97 ;Output: CY = 0 Yes is entered
104 ; Get input (CALL USER STRING)
106 ; Check for country dependent Y/N (INT 21h, AX=6523h Get Ext Country)
118 ; ELSE (nothing entered)
123 ;*****************************************************************************
125 Procedure YES?
; ;AN000;
127 call User_String
;Get character ; ;
128 ; $IF NZ ;Got one if returned NZ ;AC000;
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;
136 clc ;Clear CY for return ;AN000;
137 ; $ELSE ;Not a Yes ;AN000;
140 cmp ax,Found_No
;Is it No? ;AC000;
143 stc ;Set CY for return ;AC000;
144 ; $ELSE ;Something else we don't want ;AN000;
147 xor al,al ;Set NZ flag for ret ;AC000;
148 cmp al,1 ; " " " " ;AC000;
149 stc ;And CY flag for good measure ;AN000;
154 ; $ELSE ;No char found at all ;AN000;
157 xor al,al ;Set NZ flag for ret ;AN000;
158 cmp al,1 ; " " " " ;AN000;
159 stc ;And CY flag for good measure ;AN000;
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
173 MOV AH,STD_CON_STRING_INPUT
175 MOV AX,(STD_CON_INPUT_FLUSH
SHL 8) + 0 ; Clean out input
177 CMP BYTE PTR [INBUFF
+1],0
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
192 call Calc_System_Space
;an013; dms;calc system space
193 call Calc_Total_Addressible_Space
;an013; dms;calc total space
195 Message msgTotalDiskSpace
; ;AC000;
197 cmp WORD PTR SYSSIZ
,0
199 cmp WORD PTR SYSSIZ
+2,0
202 Message msgSystemSpace
; ;AC000;
203 ;CALL std_printf ;Report space used by system
205 cmp WORD PTR BADSIZ
,0
207 cmp WORD PTR BADSIZ
+2,0
210 Message msgBadSpace
; ;AC000;
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;
227 mov ax,deviceParameters
.DP_BPB
.BPB_BytesPerSector
; ;AN000;
228 mov cl,deviceParameters
.DP_BPB
.BPB_SectorsPerCluster
; ;AN000;
230 mul cx ;Get bytes per alloc ;AN000;
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
237 mov word ptr AllocNum
,bx ;Put result in msg ;AN000;
238 Message msgAllocNum
; = cluster/disk ;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;
244 NOSERIALNUMBER: ;AN027;
247 ;*****************************************************************************
248 ;Routine name: Read_Disk
249 ;*****************************************************************************
251 ;description: Read in data using Generic IOCtl
253 ;Called Procedures: None
256 ;Change History: Created 5/13/87 MT
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
265 ; AH = INT 25h error code
270 ; Setup structure for function call
271 ; Read the disk (AX=440Dh, CL = 6Fh)
274 ;*****************************************************************************
276 Procedure Read_Disk
; ;AN000;
278 ;This is setup for INT 25h right;AN000;
279 ;Change it to Read relative sect;AN000;
280 push bx ;Save registers ;AN000;
288 mov si,data ; ;AN000;
291 assume
es:data,ds:nothing
; ;AN000;
293 mov es:Read_Write_Relative
.Buffer_Offset
,bx ;Get transfer buffer add;AN000;
295 mov es:Read_Write_Relative
.Buffer_Segment
,bx ;Get segment ;AN000;
296 mov bx,data ;Point DS at parameter list ;AN000;
299 assume
ds:data,es:data
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;
312 pop dx ;Restore registers ;AN000;
318 Read_Disk endp
; ;AN000;
320 ;*****************************************************************************
321 ;Routine name: Write_Disk
322 ;*****************************************************************************
324 ;description: Write Data using Generic IOCtl
326 ;Called Procedures: None
329 ;Change History: Created 5/13/87 MT
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
338 ; AH = INT 26h error code
343 ; Setup structure for function call
344 ; Write to disk (AX=440Dh, CL = 4Fh)
347 ;*****************************************************************************
349 Procedure Write_Disk
; ;AN000;
352 ;This is setup for INT 26h right
353 ;Change it to Read relative sect
355 push bx ;Save registers ;AN000;
363 mov si,data ; ;AN000;
366 assume
es:data,ds:nothing
; ;AN000;
368 mov es:Read_Write_Relative
.Buffer_Offset
,bx ;Get transfer buffer add;AN000;
370 mov es:Read_Write_Relative
.Buffer_Segment
,bx ;Get segment ;AN000;
371 mov bx,data ;Point DS at parameter list ;AN000;
374 assume
ds:data,es:data
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;
387 pop dx ;Restore registers ;AN000;
392 Write_Disk endp
; ;AN000;
394 ;=========================================================================
395 ; Calc_Total_Addressible_Space : Calculate the total space that is
396 ; addressible on the the disk by DOS.
400 ; Outputs : Fdsksiz - Size in bytes of the disk
401 ;=========================================================================
403 Procedure Calc_Total_Addressible_Space
;an013; dms;
405 push ax ;an013; dms;save affected regs
409 call Get_Free_Space
;an013; dms;get free disk space
411 push bx ;an013; dms;save avail. cluster
412 push dx ;an013; dms;save total. cluster
414 mov ax,dx ;an013; dms;get total clusters
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
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
425 mov word ptr Fdsksiz
,ax ;an013; dms;save high word
426 mov word ptr Fdsksiz
+2,bx ;an013; dms;save low word
428 pop dx ;an000; dms;get total clusters
429 pop bx ;an000; dms;get avail clusters
431 mov ax,dx ;an013; dms;get total clusters
432 sub ax,bx ;an013; dms;get bad clusters
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
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
443 sub ax,word ptr syssiz
;an013; dms;account for system
444 sbb bx,word ptr syssiz
+2 ;an013; dms;size
446 mov word ptr Badsiz
,ax ;an013; dms;save high word
447 mov word ptr Badsiz
+2,bx ;an013; dms;save low word
450 pop dx ;an013; dms;restore regs
455 Calc_Total_Addressible_Space endp
;an013; dms;
458 ;=========================================================================
459 ; Get_Free_Space : Get the free space on the disk.
463 ; Outputs : BX - Available space in clusters
464 ; DX - Total space in clusters
465 ;=========================================================================
467 Procedure Get_Free_Space
;an013; dms;
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
477 Get_Free_Space endp
;an013; dms;
479 ;=========================================================================
480 ; Calc_System_Space : This routine calculates the space occupied by
481 ; the system on the disk.
483 ; Inputs : DOS.FileSizeInBytes
484 ; BIOS.FileSizeInBytes
485 ; Command.FileSizeInBytes
487 ; Outputs : SysSiz - Size of the system
488 ;=========================================================================
490 Procedure Calc_System_Space
;an013; dms;
492 push ax ;an013; dms;save regs
495 mov word ptr SysSiz
+0,00h ;an013; dms;clear variable
496 mov word ptr SysSiz
+2,00h ;an013; dms;
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
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
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
510 pop dx ;an013; dms;restore regs
515 Calc_System_Space endp
;an013; dms;