CS609 System Programming Assignment 3 Solution Fall 2013

Question:

Implement the program of lecture number 27 by using the BORLANDC compiler. File path of this program should be at the root directory of D partition and the file name should be LBA.txt. After the implementation of this program you take a memory dump which shows the successive operation of this program.  Also describe the values of this dump to prove the successive operation and also describes the whole processes of your implementation within few lines.

At the end of this assignment, show the data of your text file “LBA.txt” after the execution of above program.

Solution:

#include <dos.h>
#include <bios.h>
#include <stdlib.h>
#include <stdio.h>
struct DAP {
unsigned char size;
unsigned char reserved1;
unsigned char blocks;
unsigned char reserved2;
unsigned char far *buffer;
unsigned long int lbalod;
unsigned long int lbahid;
} dap;
char st[80];
unsigned char buf[512];
FILE *fptr ;
void main (void)
{
puts ("enter the lba low double word: ");
gets (st);
dap.lbalod=atol(st);
puts ("enter the lba high double word: ");
gets (st);
dap.lbahid=atol(st);
dap.size=16;
dap.reserved1=0;
dap.blocks=1;
dap.reserved2=0;
dap.buffer = (unsigned char far *)MK_FP(_DS,buf);

_AH=0x42;
_DL=0x80;
_SI=(unsigned int)&dap;
geninterrupt(0x13);
puts ("enter the path: ");
gets (st);
fptr = fopen(st,"wb");
fwrite(buf,512,1,fptr);
fclose (fptr);
}

This is the program. Copy it in notepad and save with  LBA.C extension, open borland c editor, select file > open the given file and compile.

DOWNLOAD SOLUTION HERE
loading...