Article View: comp.os.msdos.programmer
Article #1553How to use the Bios INT13 to format a floppy.
From: Sarmad Adnan
Date: Mon, 09 Jul 1990 15:59
Date: Mon, 09 Jul 1990 15:59
63 lines
2087 bytes
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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Technical Details
Message-ID:
<9732@brazos.Rice.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!rice!adnanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!rice!adnan From: adnan@rice.edu (Sarmad Adnan) Newsgroups: comp.os.msdos.programmer Subject: How to use the Bios INT13 to format a floppy. Message-ID: <9732@brazos.Rice.edu> Date: 9 Jul 90 15:59:30 GMT Sender: root@rice.edu Reply-To: adnan@screech.rice.edu (Sarmad Adnan) Distribution: usa Organization: Rice University, Houston, Texas Lines: 63