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