Sponsored Links

Results 1 to 3 of 3

Thread: CS609-System Programming Assignment No. 5 [Spring 2010]

  1. #1
    Administrator Xpert's Avatar
    Join Date
    May 2010

    28 CS609-System Programming Assignment No. 5 [Spring 2010]

    Sponsored Links1

    Assignment [Total Marks 10]

    Write a C program that will translate a CHS address into a LBA address and display it. Take the CHS information from user and use interrupt 13H/48H to get drive parameters.

    Note: Submit .C files only. You have to run this in DOS mode because Windows will not allow you to access hard disk directly.

    Sponsored Links

  2. #2
    Junior Member Minnow's Avatar
    Join Date
    Jun 2010


    Find the solution and make changes.
    #include <bios.h>
    #include <dos.h>
    #include <conio.h>
    #include <stdio.h>
    #include <stdlib.h>
    //Structure of result buffer used by extended 13H services.
        unsigned int size;
        unsigned int infoflags;
        unsigned long int cylinders;
        unsigned long int heads;
        unsigned long int sectors;
        unsigned long int locount;
        unsigned long int hicount;
        unsigned int bytespersector;
        unsigned long int configptr;
    }rb; //If Int 13 returns some value then it will be stored in rb.
    //Function to get drive parameters
    void getDriveParameters(unsigned int drive, struct RESULTBUFFER * rbptr)
        _AH = 0x48;   //Service #
        _DL = drive ; //Drive number
        rbptr->size = 30; //Size of result buffer
        _SI = (unsigned int) rbptr; //Offset address of result buffer
        geninterrupt (0x13); //Generate Interrupt 13
    void main()
        char input[15];
        //Will be used to store current cylender, head and sector numbers
        unsigned long int lba, cylinder, head , sector;
        //Taking input from user
        puts ("\nEnter the current Cylinder # : ");
        gets (input);
        cylinder = atol(input);
        puts ("\nEnter the current Head # : ");
        gets (input);
        head = atol(input);
        puts ("\nEnter the current Sector # : ");
        gets (input);
        sector = atol(input);
        //Getting drive parameters of Result buffer using Int 13H/48H
        //Now we have No. of heads  per cylinder in rb.heads and No. of Sectors per track for the disk in rb.sectors
        //Now from the following formula we can calculate the LBA index for the selected CHS index
        lba=( ( cylinder * rb.heads + head ) * rb.sectors ) + sector - 1;
        printf("\n\nThe LBA Index for current CHS address : %ld",lba);
        printf("\n\n\n\nPress any key to exit...");

  3. #3
    Administrator Xpert's Avatar
    Join Date
    May 2010
    thanks for the solution. would you like to introduce your self?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 05-14-2013, 05:52 PM
  2. Replies: 0
    Last Post: 05-31-2012, 04:36 PM
  3. Replies: 0
    Last Post: 05-31-2012, 01:05 AM
  4. Replies: 9
    Last Post: 05-04-2012, 01:07 AM
  5. Replies: 0
    Last Post: 04-13-2012, 05:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft