home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Press 1997 July
/
Sezamfile97_1.iso
/
msdos
/
utility
/
sdf105.arj
/
GETDPB.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-11-12
|
2KB
|
126 lines
;; ╔════════════════════════╗
;; ║ 23/08/1993 - mjova ║
;; ╚════════════════════════╝
locals
.model large
.data
_Drive db ?
_BytPerSec dw ?
_SecPerClu db ?
_FATtype db ?
_StartFAT dw ?
_MaxRootDir dw ?
_FstCluster dw ?
_SecPerFAT dw ?
_RootSec dw ?
PUBLIC _Drive;
PUBLIC _BytPerSec;
PUBLIC _SecPerClu;
PUBLIC _FATtype;
PUBLIC _StartFAT;
PUBLIC _MaxRootDir;
PUBLIC _FstCluster;
PUBLIC _SecPerFAT;
PUBLIC _RootSec;
extrn _FAT:DWORD;
.code
; ------------------------------------------------------------
public c GetDPB
GetDPB proc c
arg drive:byte
mov ah, 032h
mov dl, drive
push ds
int 21h
and al, al
jz @@not_error
@@error: pop ds; ; cannot read drive parametar block
xor ax, ax
mov dx, ax
ret
@@not_error: mov dx, ds
pop ds
mov es, dx ; es:bx
mov ah, es:[bx] ; set _Drive
mov _Drive, ah
mov ax, es:[bx+2] ; set _BytesPerSector
mov _BytPerSec, ax
mov ax, es:[bx+9] ; set _MaxRootDir
mov _MaxRootDir, ax
mov ah, es:[bx+4] ; set _SecPerClu
inc ah
mov _SecPerClu, ah
add ah, ah
mov ch, 0
mov cl, ah
mov ax, es:[bx+0bh] ; set _FstCluster
sub ax, cx
jc @@error
mov _FstCluster, ax
mov ax, es:[bx+0dh] ; highest cluster number
cmp ax, 0FF6h
mov al, 16
ja @@fat16
mov al, 12
@@fat16: mov _FATtype, al
mov ax, es:[bx+6] ; set _StartFAT
mov _StartFAT, ax
mov ax, 3000h ; get dos ver
push es
push dx
push bx
int 21h
pop bx
pop dx
pop es
cmp al, 4
jb @@OldDos
; dos 4.0+
mov ax, es:[bx+0fh] ; set _SecPerFAT
mov _SecPerFAT, ax
mov ax, es:[bx+11h] ; set _RootSec
mov _RootSec, ax
mov ax, bx;
ret
@@OldDos: mov al, es:[bx+0fh] ; set _SecPerFAT
xor ah, ah
mov _SecPerFAT, ax
mov ax, es:[bx+10h] ; set _RootSec
mov _RootSec, ax
mov ax, bx;
ret
GetDPB endp
end