CS609 Assignment No. 03 Solution and Discussion
-

Semester: Spring 2019
CS609: System Programming
Graded
Assignment No. 03
Total Marks: 20Due Date: July 16, 2019
Instructions:
Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:
♣ The assignment is submitted after 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 with zero marks.
Objectives:
The objective of this assignment is to provide hands-on experience of System Programming concepts including:
• Hard Disk interrupts
• Hard Disk data reading
• Hard Disk BioDisk() functionFor any assignment related query, contact at [email protected]
Problem Statement:
Q: Write a program which reads two physically addressed blocks from disk using biosdisk() function.
Instructions:
• Declare arrays to handle head, sector and track numbers to read from hard disk.
unsigned char headno[10];
unsigned char secno[10];
unsigned char trackno[10];
• Similarly declare a buffer of 1024 char to store data 2 blocks data etc.
• unsigned char buf[1024];
• Use printf to print message of entering head no. i.e printf("Head ");
• Use gets function to get head no. from user i.e gets(headno);
• Use puts function to put headno in array of headno
• Use biodisk function to read two blocks i.e
biosdisk(2,0x80,atoi(headno),atoi(trackno),atoi(secno),2,buf) ;
• Similarly get and put sector and track numbers.
• Show error message in case of failure of biodisk() function.Note: Your assignment file should be a single Word file (.doc or .docx) containing code only.
Best of Luck!
-
@Anaya-Ali
-
Idea Solution
#include #include FILE *fp; unsigned char buf[1024]; unsigned char st[60]; unsigned char headno[10]; unsigned char secno[10]; unsigned char trackno[10]; void main (void) { int i ; for (i=0;i<1024;i++) buf[i]=0; gets(st); fp=fopen(st,"wb"); printf("Head "); gets(headno); puts (headno); i = biosdisk(2,0x80,atoi(headno), atoi(trackno),atoi(secno),2,buf) ; if (*(((char *)(&i))+1)==0) { fwrite(buf,2,1024,fp); fclose(fp); } else printf("Cannot Read Error# = %x",i); } -
Idea Solution
#include #include FILE *fp; unsigned char buf[1024]; unsigned char st[60]; unsigned char headno[10]; unsigned char secno[10]; unsigned char trackno[10]; void main (void) { int i ; for (i=0;i<1024;i++) buf[i]=0; gets(st); fp=fopen(st,"wb"); printf("Head "); gets(headno); puts (headno); i = biosdisk(2,0x80,atoi(headno), atoi(trackno),atoi(secno),2,buf) ; if (*(((char *)(&i))+1)==0) { fwrite(buf,2,1024,fp); fclose(fp); } else printf("Cannot Read Error# = %x",i); }@moaaz
Another Idea solution#include <bios.h> #include <dos.h> FILE *fp; unsigned char buf[1024]; unsigned char st[60]; unsigned char headno[10]; unsigned char secno[10]; unsigned char trackno[10]; void main (void) { int i; for (i=0; i<1024; i++) buf[i]=0; gets(st); fp=fopeon(st,”wb”); printf(“Head”); gets(headno); puts(headno); printf(“/nsector ”); gets(secno); puts(secno); printf(“/ntrack ”); gets(trackno); puts(trackno); i = biosdisk(2, 0x80, atoi(headno), atoi(trackno), atoi(trackno), 2,buf); } if(*(((char *)(&i))+1)= =0) { fwrite(buf,2,1024,fp); fclose(fp); } else { printf(“Cannot Read Error# = %x” i); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login

