Cs609@vu.edu.pk
Lecture # 32
Besides the BPB another data structure can be used equivalently called the DPB (Drive
parameter block). The operating system translates the information in BPB on disk into the
DPB which is maintained main memory. This data structure can be accessed using the
undocumented service 21H/32H. Its detail is shown in the slide below.
The DPB contains the information shown in the table below. This information can be
derived from the BPB but is placed in memory in the form of DPB.
The following code shows how the service 21H/32H is invoked and the registers in which
it returns a value. It also shows the contents of the DPB by taking the dump at the
location returned by the service for a FAT 12 volume (i.e. Floppy disk).
-a
13A6:0100 mov ah,32
13A6:0102 int 21
13A6:0104
-p
AX=3200 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=13A6 ES=13A6 SS=13A6 CS=13A6 IP=0102 NV UP EI PL NZ NA PO NC
13A6:0102 CD21 INT 21
-p
AX=3200 BX=13D2 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=00A7 ES=13A6 SS=13A6 CS=13A6 IP=0104 NV UP EI PL NZ NA PO NC
13A6:0104 D3E3 SHL BX,CL
-d a7:13d2
The details of the information read from the dump of the DPB are shown below.
Drive # = 0
unit # = 0
Bytes per sector = 0200H = 512 bytes
highest sec no within a cluster = 0
Shift count to convert sec to clust = 0
Reserved sectors at the begining of drive = 0001
FAT copies = 02
Root directory entries = E0 = 224
First sector containing user data = 21H = 33
Highest cluster number = 0b20 = 2848
Number of sectors per fat = 0009 = 9
Sector number of first directory = 0013 = 19
The following code shows how the service 21H/32H is invoked and the registers in which
it returns a value. It also shows the contents of the DPB by taking the dump at the
location returned by the service for a FAT 16 volume (i.e. hard disk partition smaller than
2 GB approx.).
-a
13A6:0100 mov ah,32
13A6:0102 int 21
13A6:0104
-p
AX=3200 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=13A6 ES=13A6 SS=13A6 CS=13A6 IP=0102 NV UP EI PL NZ NA PO NC
13A6:0102 CD21 INT 21
-p
AX=3200 BX=13D2 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=00A7 ES=13A6 SS=13A6 CS=13A6 IP=0104 NV UP EI PL NZ NA PO NC
13A6:0104 0000 ADD [BX+SI],AL DS:13D2=05
-d a7:13d2
The details of the information read from the dump of the DPB are shown below.
drive no = 05 = F drive
unit no = 05
bytes per sector = 200H = 512
Highest sector number within a cluster = 7
Hence Sec. per cluster = highest sec. within a
cluster + 1 = 7 + 1 = 8
shift count = 3
reserved sectors = 0008
Number of Fats = 2
Root Dir Entries = 0200H = 512
First sector containing user data = 01C0 = 448
Highest cluster number = cbb4H = 52148
No of sectors per FAT = CC = 204
Sector number of First directory = 01A0 = 416
#include <bios.h>
#include <dos.h>
struct BPB
{
unsigned int bytespersec;
unsigned char secperclust;
unsigned int reservedsecs;
unsigned char fats;
unsigned int rootdirents;
unsigned int smallsecs;
unsigned char media;
unsigned int fatsecs;
unsigned int secspertrack;
unsigned int heads;
The above program creates a data structure in reflection of the BPB and reads the boot
record of the volume using absread(). It extracts the data part of the boot block and
displays all the values stored in it.
#include <dos.h>
#include <bios.h>
struct DPB {
unsigned char driveno;
unsigned char unitno;
unsigned int bytespersec;
unsigned char highestsecinclust;
unsigned char shiftcount;
unsigned int reservedsecs;
unsigned char fats;
unsigned int rootentries;
unsigned int firstuserdatasec;
unsigned int highestclustnumber; //only for 16 and 12
bit FATs
unsigned int secsperfat;
unsigned int firstdirsec;
unsigned int ddheaderoff;
unsigned int ddheaderseg;
The above program is doing is the same using the DPB rather than BPB.