🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
1 messages
1 total messages Started by Sarmad Adnan Mon, 09 Jul 1990 15:59
How to use the Bios INT13 to format a floppy.
#1553
Author: Sarmad Adnan
Date: Mon, 09 Jul 1990 15:59
63 lines
2087 bytes
I have been trying to format a floppy inside an application program written
in MSC5.1 as follows, and have not had success. The bios does not return
any error code and the floppy remains unformatted. 
I think I am not filling the sector data array properly, I would appreciate
any pointers(No pun intended **).

###########################################################################



#include <stdio.h>
#include <dos.h>
#include <bios.h>
#define  DOS_DISPCHAR 2



main()
{
int track, head, sector, ndx;
unsigned status=0;
char buf[1000];
void far *pbuf;
struct diskinfo_t info;


printf("An attempt to format drive A: 360kb 9sectors 40 tracks\n");

pbuf = (void far *)(&buf[0]);
info.buffer = pbuf;

for(track=0; track<40; track++)
    {
    for(head=0; head<=1; head++)
        {
        info.drive = 0;
        info.head = head;
        info.track = track;
        info.nsectors = 9;
        info.sector = 1;

/* I do not think I am filling this data array 'buf[]' properly */
        for(sector=0; sector<9; sector++)
            {
            ndx=sector*4;
            buf[ndx]=track, buf[ndx+1]=head, buf[ndx+2]=sector+1, buf[ndx+3]=2;
            }

        status= _bios_disk(_DISK_FORMAT, &info);

        if( status>0xff )
            printf("%x \n",status);
        else
            printf("Track %d\t Head %d   \r", track, head);
        }
    }
}

##########################################################################

                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  Sarmad Adnan (adnan@rice.edu)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads