home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / qb_lib / diskdata.asm < prev    next >
Encoding:
Assembly Source File  |  1990-07-21  |  3.1 KB  |  72 lines

  1. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. ;
  3. ;       DiskData.ASM -  A QB4 FUNCTION to return data about a specified
  4. ;                       disk(ette) drive.
  5. ;
  6. ;       Last Revised -  07/21/90 11:44am
  7. ;
  8. ;       This FUNCTION should be DECLAREd in your source program as follows:
  9. ;
  10. ;          DECLARE FUNCTION DiskData% (Drv%, SPC&, NAC&, BPS&, CPD&)
  11. ;
  12. ;       where the passed parms are defined as follows:
  13. ;
  14. ;       Drv% =  an INTEGER value containing the value of the drive to be read,
  15. ;               where 0 = the current default drive, 1 = A:, 2 = B:, etc
  16. ;       SPC& =  a LONG INT variable which will contain the number of sectors
  17. ;               per cluster on the specified drive on return.
  18. ;       NAC& =  a LONG INT variable which will contain the number of available
  19. ;               clusters on the drive on return.
  20. ;       BPS& =  a LONG INT variable which will contain the number of Bytes per
  21. ;               sector on the drive on return.
  22. ;       CPD& =  a LONG INT variable which will contain the total number of
  23. ;               clusters (whether used or not) on the drive on return.
  24. ;
  25. ;       RETURNS         An INT value which will be 0 if the drive was read
  26. ;                       successfully, or -1 if it could not be read.
  27. ;
  28. ;       Common uses for the above data would include:
  29. ;
  30. ;       1.  SPC& * BPS& = number of bytes per cluster on the disk
  31. ;       2.  SPC& * BPS& * NAC& = number of bytes free on the drive
  32. ;       3.  SPC& * BPS& * CPD* = total number bytes on disk (free or not)
  33. ;       4.  (BPS& * 100) / CPD& = percent of drive space which is free
  34. ;       5.  If S = the size of any given file in bytes, then we can determine
  35. ;           how many drive sectors it requires by the following:
  36. ;               (S + BPS& * SPC& - 1) / (BPS& * SPC*)
  37. ;
  38. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  39.  
  40.         .MODEL MEDIUM,BASIC
  41.         .CODE
  42.  
  43. DiskData        PROC    DRV:word,SPC:word,NAC:word,BPS:word,CPD:word
  44.  
  45.         mov     BX,DRV
  46.         mov     DX,[BX]                 ; DL = Drive code (0=default,1=A:,etc)
  47.         mov     AH,36h
  48.         int     21h
  49.         cmp     AX,0FFFFh               ; If error, RETURN with AX = -1
  50.         je      ExitDiskData
  51.  
  52.         push    DX                      ; Store CPD for later use
  53.         mov     DX,BX                   ; Put NAC into DX
  54.         mov     BX,NAC                  ; Point BX at location of NAC variable
  55.         mov     [BX],DX                 ; Store # avail. clusters into NAC
  56.         mov     BX,SPC
  57.         mov     [BX],AX                 ; Store Sectors Per Cluster in SPC
  58.         mov     BX,BPS
  59.         mov     [BX],CX                 ; Store Bytes per Sector in BPS
  60.         mov     BX,CPD
  61.         pop     DX
  62.         mov     [BX],DX                 ; Store Clusters per drive in CPD
  63.         xor     AX,AX                   ; Indicate RETURN = 0 = no problems
  64.  
  65. ExitDiskData:
  66.  
  67.         ret
  68.  
  69. DiskData        ENDP
  70.                 END
  71.  
  72. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++