Friday, May 28, 2010

Verifying disk sectors using REGS union and SREGS structure

SREGS Structure

This structure of the segment registers, which is passed to and filled by the functions, int86x, intdosx and segread, has been defined in dos.h. Following is the the declaration of the structure:

struct SREGS { unsigned int es; unsigned int cs; unsigned int ss; unsigned int ds; };

REGS union

REGS, the union of two structures, has also been defined in dos.h and it is used to pass information to and from the functions, int86, int86x, intdos and intdosx. The declaration of the union is as follows:

union REGS { struct WORDREGS x; struct BYTEREGS h;

};

void main(void)
{
clrscr();
union REGS rg;
struct SREGS srg;
char bfr[1000];
int i;
rg.h.ah = 4;
rg.h.al = 1;
rg.h.ch = 1;
rg.h.dh = 0;
rg.h.cl = 1;
rg.h.dl = 0x80;
rg.x.bx = FP_OFF(bfr);
srg.es = FP_SEG(bfr);
int86x(0x13,®s,®s,&srg);
printf("rg.x.cflag - %d",rg.x.cflag);
printf("rg.h.ah - %d",rg.h.ah);
printf("rg.h.al - %d",rg.h.al);
printf("Buffer - %d",bfr);
getch();
}

No comments:

Post a Comment