home *** CD-ROM | disk | FTP | other *** search
/ PC Press 1997 July / Sezamfile97_1.iso / msdos / utility / sdf105.arj / GETDPB.ASM < prev    next >
Assembly Source File  |  1993-11-12  |  2KB  |  126 lines

  1. ;; ╔════════════════════════╗
  2. ;; ║   23/08/1993 - mjova   ║
  3. ;; ╚════════════════════════╝
  4.  
  5.  
  6.  
  7. locals
  8. .model large
  9.  
  10. .data
  11.  
  12. _Drive                db    ?
  13. _BytPerSec            dw    ?
  14. _SecPerClu            db    ?
  15. _FATtype                db    ?
  16. _StartFAT            dw    ?
  17. _MaxRootDir            dw    ?
  18. _FstCluster            dw    ?
  19. _SecPerFAT            dw    ?
  20. _RootSec                dw    ?
  21.  
  22. PUBLIC _Drive;
  23. PUBLIC _BytPerSec;
  24. PUBLIC _SecPerClu;
  25. PUBLIC _FATtype;
  26. PUBLIC _StartFAT;
  27. PUBLIC _MaxRootDir;
  28. PUBLIC _FstCluster;
  29. PUBLIC _SecPerFAT;
  30. PUBLIC _RootSec;
  31.  
  32. extrn    _FAT:DWORD;
  33.  
  34. .code
  35.  
  36. ; ------------------------------------------------------------
  37.         public c GetDPB
  38. GetDPB            proc c 
  39.                     arg drive:byte
  40.  
  41.                     mov ah, 032h
  42.                     mov dl, drive
  43.                     push ds
  44.                     int 21h
  45.                     and al, al
  46.                     jz @@not_error
  47.  
  48. @@error:            pop ds;            ; cannot read drive parametar block
  49.                     xor ax, ax
  50.                     mov dx, ax
  51.                     ret
  52.  
  53. @@not_error:    mov dx, ds
  54.                     pop ds
  55.                     mov es, dx            ; es:bx
  56.  
  57.                     mov ah, es:[bx]        ; set _Drive
  58.                     mov _Drive, ah
  59.  
  60.                     mov ax, es:[bx+2]    ; set _BytesPerSector
  61.                     mov _BytPerSec, ax
  62.  
  63.                     mov ax, es:[bx+9]    ; set _MaxRootDir
  64.                     mov _MaxRootDir, ax
  65.  
  66.                     mov ah, es:[bx+4]    ; set _SecPerClu
  67.                     inc ah
  68.                     mov _SecPerClu, ah
  69.                     add ah, ah
  70.                     mov ch, 0
  71.                     mov cl, ah
  72.                     mov ax, es:[bx+0bh]    ; set _FstCluster
  73.                     sub ax, cx
  74.                     jc @@error
  75.                     mov _FstCluster, ax
  76.  
  77.                     mov ax, es:[bx+0dh]    ;    highest cluster number
  78.                     cmp ax, 0FF6h
  79.                     mov al, 16
  80.                     ja @@fat16
  81.                     mov al, 12
  82. @@fat16:            mov _FATtype, al
  83.  
  84.                     mov ax, es:[bx+6]    ; set _StartFAT
  85.                     mov _StartFAT, ax
  86.  
  87.                     mov ax, 3000h        ; get dos ver
  88.                     push es
  89.                     push dx
  90.                     push bx
  91.                     int 21h
  92.                     pop bx
  93.                     pop dx
  94.                     pop es
  95.                     cmp al, 4
  96.                     jb @@OldDos
  97.         
  98.                     ; dos 4.0+
  99.                     mov ax, es:[bx+0fh]    ; set _SecPerFAT
  100.                     mov _SecPerFAT, ax
  101.  
  102.                     mov ax, es:[bx+11h]    ; set _RootSec
  103.                     mov _RootSec, ax
  104.  
  105.                     mov ax, bx;
  106.                     ret
  107.  
  108. @@OldDos:        mov al, es:[bx+0fh]    ; set _SecPerFAT
  109.                     xor ah, ah
  110.                     mov _SecPerFAT, ax
  111.  
  112.                     mov ax, es:[bx+10h]    ; set _RootSec
  113.                     mov _RootSec, ax
  114.  
  115.                     mov ax, bx;
  116.                     ret
  117.  
  118.  
  119. GetDPB             endp
  120.  
  121.  
  122.  
  123.  
  124.                     end
  125.  
  126.