home *** CD-ROM | disk | FTP | other *** search
- ; DF Print disk free space.
-
- ; Usage: df [drive: ...]
-
- ; By default it reports free space for the current disk drive. If you
- ; specify a drive explicitly, the colon is optional, so you can do
- ; `df acd' to get free space for drives a:, c:, and d:.
-
- ; Assemble with A86. Version 1.00 (9/15/90)
-
- CR equ 0dh
- LF equ 0ah
-
- cld
- mov si,81h
-
- ; Loop over drives.
-
- df1: lodsb
- cmp al,CR
- je df3 ;if end of argument(s)
- or al,20h
- sub al,'a'
- jae df4 ;if a letter found
- jmp df1
-
- df2: ret
-
- df3: cmp byte msg1a,'$'
- jne df2 ;if we did something already
- dec si ;go back here when done
- mov ah,19h ;get current disk
- int 21h
-
- ; Print stats for drive given in AL.
-
- df4: push si
- mov dl,al
- inc dx
- add al,'a'
- mov msg1a,al
- mov msg2a,al
- mov ah,36h ;get disk free space
- int 21h
- cmp ax,-1
- jne df5 ;if not invalid drive
- mov dx,offset msg2 ;error message
- jmp short df6 ;print it and go on
-
- df5: push dx,bx ;save total, avail number of clusters
- mul cx ;number of bytes per cluster
- mul bx ;number of bytes available, period
- mov di,offset msg1b
- mov cx,9
- call dprintdxax
- pop bx ;number of clusters available
- push bx
- xor ax,ax
- mov di,offset msg1c
- mov cx,5
- call dprint
- mov ax,100 ;print percentage free
- pop bx ;number of clusters free
- mul bx
- pop bx ;number of clusters total
- mov cx,bx ;round off
- shr cx,1
- add ax,cx
- div bx
- xor dx,dx
- mov di,offset msg1d
- mov cx,3
- call dprintdxax
- mov dx,offset msg1
-
- df6: mov ah,9 ;print string
- int 21h
- pop si
- jmp df1 ;loop back to the next one
-
- ; DPRINTDXAX - Print (CX)-digit number in DX:AX.
- ; DPRINT Print (CX)-digit number in AX:BX.
-
- dprintdxax:
- xchg ax,bx ;move dx:ax into ax:bx
- xchg ax,dx
-
- dprint: mov bp,sp
- mov si,10
- dp1: xor dx,dx
- div si
- xchg ax,bx
- div si
- add dl,'0'
- push dx
- dec cx
- xchg ax,bx
- or bx,bx
- jnz dp1
- or ax,ax
- jnz dp1
- or cx,cx
- js dp2
- mov al,' '
- rep stosb
- dp2: pop ax
- stosb
- cmp sp,bp
- jne dp2
- ret
-
- msg1 db 'Drive '
- msg1a db '$: has'
- msg1b db 'XXXXXXXXX bytes = '
- msg1c db 'XXXXX clusters ('
- msg1d db 'XXX%) free.',CR,LF,'$'
-
- msg2 db 'Drive '
- msg2a db '$: is invalid.',CR,LF,'$'
-
- end
-