home *** CD-ROM | disk | FTP | other *** search
-
-
- ; TITLE DISK FREE SPACE SUBROUTINE
- ; COMMENT * 5-26-85
- ; Basic subroutine to determine free space left on disk.
- ; CALLING SYNTAX:
-
- ; CALL XX(DRIVE%,SPACE)
-
- ; where: XX=the address of the subroutine
- ; DRIVE% = An integer variable designating the disk drive.
- ; 0=default, 1=a:, 2=b:, etc.
- ; SPACE = A single-precision variable to get the result.
-
- ; Written by Burks A. Smith
- ; Datasmith, In.
- ; Box 8036
- ; Shawnee Mission KS 66208
- ; *
- ;
- cseg segment ;run in Basic's data seg
- assume cs:cseg, ds:cseg
- org 100h ;for testing.
- space proc far
- push bp ;save base
- mov bp,sp ;point at stack
- mov ah,30h ;test version
- int 21h
- cmp al,0 ;is it 1.x?
- jnz okver ;jump if not
- mov ax,8000h ;force floating point -1
- xor dx,dx ;least significant bits
- mov cl,ah ;exponent is 80h (128)
- jmp short done ;version 1 exit
- ; version 2.0 or later, test free space
- okver: mov si,[bp]+8 ;get drive # address
- mov dx,[si] ;set drive id
- mov ah,36h ;free space command
- int 21h
- mul cx ;bytes/sec*sec/cluster
- mul bx ;avail clusters*bytes/cluster
- xor cx,cx ;init shift count = 0
- push ax ;save while comparing
- or ax,dx ;space left zero?
- pop ax ;restore original value
- jz done ;jump if so
- ; normalize floating point
- xchg ax,dx ;format change DX:AX->AX:DX
- shift: inc ch ;count the shift
- shl dx,1 ;shift lsw left
- rcl ax,1 ;shift msw & pick up carry
- jnc shift ;loop if it was a zero
- ; 32 bits normalized. fix exponent & mantissa.
- mov cl,128+32+1 ;bias+max shift+assumed bit
- sub cl,ch ;less actual shifts=exponen
- shr ax,1 ;shift mantissa for + sign
- rcr dx,1 ;pick up bit & shift lsw
- ; store result
- done: mov di,[bp]+6 ;get addr of result
- mov [di],dh ;least significant byte
- inc di
- stosw ;most significant word
- mov [di],cl ;and finally exponent
- pop bp ;restore bp
- ret 4 ;normal return
- space endp
- cseg ends
- ;
- end space
-