




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture handout is for System Programming course. It was provided by Prof. Indubhushan Vijayabhas at Ambedkar University, Delhi. It includes: Drive, Parameter, Block, Slide, Exit, Entry, Memory, Information, Contain, Code, Return, Service
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!





DPB (Drive Parameter Block)
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, 13A6:0102 int 21 13A6:
-p AX=3200 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 D I= 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 D I= 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:13d
00A7:13D0 00 00 00 02 00 00-01 00 02 E0 00 21 00 20 ...........!. 00A7:13E0 0B 09 00 13 00 56 34 12-00 F0 0A FF FF FF FF 00 .....V4......... 00A7:13F0 00 C9 06 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1400 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1410 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1420 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1430 00 00 00 00 00 00 00 0C-00 00 80 00 B0 13 10 00 ................ 00A7:1440 D8 12 4D 5A 9A 00 29 00-00 00 20 00 C5 00 FF FF ..MZ..)... ..... 00A7:1450 A7 05 ..
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;
unsigned long int hiddensecs;
unsigned long int hugesecs;
unsigned char driveno;
unsigned char reserved;
unsigned char bootsignature;
unsigned long int volumeid;
unsigned char volumelabel[11];
unsigned char filesystem[8];
};
struct bootblock
{
unsigned char jumpinstruction[3];
unsigned char osname[8];
struct BPB bpb;
unsigned char code[448];
};
*void nputs( char p, int n)
{
int i ;
for (i =0;i<n;i++)
putch(p[i]);
}
void main( void)
{
struct bootblock bb;
clrscr();
absread(0,1,0,&bb);
printf("jump instruction = % x\n" ,
bb.jumpinstruction);
printf("OS = ");
nputs (bb.osname,8);
puts("\n");
#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;
unsigned char media;
unsigned char accessed;
unsigned int nextdpboff;
unsigned int nextdpbseg; unsigned int searchstart;
unsigned int freeclust;
};
void main (void)
{
*struct DPB far ptr;
struct DPB dpb;
clrscr();
_asm push DS;
_asm push BX; _AH=0x32;
_DL=1;
geninterrupt (0x21);
*ptr = (struct DPB far )MK_FP(_DS,_BX);
dpb=ptr; _asm pop BX;*
_asm pop DS;
printf("Drive No = %x\n",dpb.driveno);
printf("Unit No = %x\n",dpb.unitno);
printf("Bytes per sector = %d\n",dpb.bytespersec);
printf("Highest sector number within a cluster =
%d\n",dpb.highestsecinclust); printf("Shift Count = %d\n",dpb.shiftcount);
printf("Reserved sectors = %d\n",dpb.reservedsecs); printf("number of FATs = %d\n",dpb.fats);
printf("Root enteries = %d\n",dpb.rootentries);
printf("First User data sec = %d\n",dpb.firstuserdatasec);
printf("Highest Cluster number =
%d\n",dpb.highestclustnumber);
printf("No of Sectors per FAT = %d\n",dpb.secsperfat);
printf("First directory Sector = %d\n",dpb.firstdirsec);
printf("DD header offset = %x\n",dpb.ddheaderoff);
printf("DD header segment = %x\n",dpb.ddheaderseg); printf("Media ID= %d\n",dpb.media);
printf("Disk accessed recently= %d\n",dpb.accessed);
printf("Next DPB offset address = %d\n",dpb.nextdpboff);
printf("Next DPB segment address =
%d\n",dpb.nextdpbseg);
printf("Point where to start the search for next cluster=
%d\n",dpb.searchstart); printf("Free cluster= %d\n",dpb.freeclust);
getch(); }
The above program is doing is the same using the DPB rather than BPB.