CS609 System Programming Assignment No 1 Solution Fall 2012

Write a C-language program that shall find the size of the two attached files (abc.txt, xyz.txt) using interrupts. Sample output of the desired program is shown in the form of snapshots on Page-2.

Submission
You are required to submit two files in Zip format through LMS:
  • Your C-language program (.c file).
  • An MS Word document having screen shots of your program execution…showing your own ID displayed as given on Page-2.
Hint: The desired task can easily be achieved by modifying “Get the file size Program” given in your handouts at page # 19.
This Snapshot was taken after program execution. It shows how your output shall look like. (BC00123456 is sample ID that I have used; you shall display your own ID).
 Solution:
#include<stdio.h>
#include<fcntl.h>
#include<io.h>
#include<BIOS.H>
#include<DOS.H>
unsigned int handle;
void main()
{
union REGS regs;
unsigned long int size;

handle = open (“c:\\abc.txt”,O_RDONLY);
regs.x.bx = handle;
regs.x.bx =handle;
regs.h.ah = 0×42;
regs.h.al = 0×02;
regs.x.cx = 0;
regs.x.dx = 0;
int86(0×21, &regs, &regs);
*((int*)(&size)) = regs.x.ax;
*(((int*)(&size))+1) = regs.x.dx;
printf(“\nname” );
printf(“\nabc file is %d”, size);

}

Leave a Reply

Related Posts Plugin for WordPress, Blogger...