cs609 assignment 3 solution 2020

0
41
cs609 assignment 3 solution 2020
Semester: Spring 2020

CS609: System Programming

Graded

Assignment No. 03

Total Marks: 20

 

Due Date: July 30, 2020

 

Instructions:

 

Please read the following instructions carefully before submitting the assignment. It should be clear that your assignment will not get any credit if:

 

§  The assignment is submitted after the due date.

§  The submitted assignment does not open or file is corrupt.

§  You have not followed steps described in Detailed Instructions of the problem statement.

§  Assignment is copied (partial or full) from any source (websites, forums, students, etc.) Strict action will be taken in this regard.

 

Note:You have to upload only .doc or .docx file. Assignment in any other format (extension) will not be accepted and will be awarded zero marks.

 

Objectives:

 

The objective of this assignment is to provide hands-on experience of System Programming concepts including:

 

  1. Hard DiskInterrupts
  2.  Reading Hard Disk Block
  3.  Invoking Interrupts
  4.  File Pointer

 

For any assignment related query, contact at CS609@vu.edu.pk

 
Problem Statement CS609 Assignment 3 Solution 2020:

Q: Write C program to perform a block read operation using interrupt 13H/42H. Follow the instructions given below: [Note that we are using DAP data structure which is used by extended int 13H service].

 

 

Instructions CS609 Assignment 3 Solution 2020:

1)         Include all header files and declare string arrays to input low and high word.

2)         Declare DAP structure and file pointer.

3)      Get low double word from the user, temporarily store it in character array st, and assign this value to lbalod.

4)      Get high double word from the user, temporarily store it in character array st, and assign this value to lbahid.

5)         Finally, generate the interrupt 0x13

6)         Open file through fopen()

7)         Write the read block of hard disk to file.

CS609 Assignment 3 Solution 2020  : 

 #include <dos.h>

 #include <bios.h>

struct DAP{

  1. unsigned char size;
  2. unsigned char reserved1;
  3. unsigned char blocks;
  4. unsigned char reserved2;
  5. unsigned char far *buffer;
  6. unsigned long int lbalod;
  7. unsigned long int lbalid;

} dap;

 

  1. char st[80];
  2. unisigned char buf[512];
  3. FILE *fptr;
  4. void main(void){
  5. puts (“Enter the lba low double word:-”);
  6. gets(st);
  7. dap.lbalod=atol(st);
  8. dap.size=10;
  9. dap. reserved1=0;
  10. dap.blocks=1;
  11. dap. Reserved2=0;
  12. dap.buffer=(unsigned char far *)MK_FP(_DS,buf);
  13. _AH=0x42;
  14. _DL=0x80;
  15. _SI=(unsigned int)&dap;
  16. Geninterrupt(0x13);
  17. puts (“Enter the path”);
  18. gets(st);
  19. fptr=fopen(st,”wb”);
  20. fwrite(buf,512,1,fptr);
  21. fclase(fptr);

}

 

CS508 Assignment 3 Solution 2020