🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5906

Formatting diskettes, round II

#5906
From: Lepp{j{rvi Jouni
Date: Mon, 22 Apr 1991 13:13
87 lines
3488 bytes
Problem : formatting 1.2 M floppy

I have received some replies to my question about formatting
diskettes, which I posted some days ago. Thanks (again) for all those
who replied. Still, I can't make it work .. :-)  I have been suggested
that my sector header table has incorret contents (it should not). One
suggestion was to format the 15 tracks of a 1.2 M disk in two parts. I
tried this, but no luck. (Apparently int 13h, ah=5 is meant to format
an entre track). I also received dome source code, but it apparently
only reads/writes diskettes. I can do this already, but formatting is
the problem. 

So, I guess I have to try again with a piece of my code included. The
following tiny program is for Borland's turbo C. The intention is to
format the single track 1, side 0 on a 1.2 M floppy. (If I can format 
one, then I guess I can format them all.) What goes wrong with this,
is that I get just 9 formatted sectors instead of 15. The code uses
turbo's pseudo-variables and __int__(). This could cause problems
since register contents may be overwriten as setting up other
registers. According to the assembler output of the compiler, however,
this goes as intented.

#include <stdio.h>

main()
{
   unsigned i;
   unsigned char fmtbuf[15][4];
   
   /* format track 1, head 0, drive A */
   
   /* set up headers */
   
   for (i = 0; i < 15 ;i++)
   {
      fmtbuf[i][0] = 1;       /* track */
      fmtbuf[i][1] = 0;       /* head */
      fmtbuf[i][2] = i+1;     /* sector */
      fmtbuf[i][3] = 2;       /* 512 bytes / sector */
   }
   
   /* reset */
   
   _DL = 0x00;
   _AH = 0x00;
   __int__(0x13); 
   i = _AH;
   
   printf("result %x\n",i);
   
   /* set format parameters */
   
   _DL = 0x00;                /* drive A */
   _CX = 0x4f0f;              /* 80 tracks (4fh + 1), 15 sectors */
   _AX = 0x180f;              /* function 18h - set format parameters */
   __int__(0x13);
   i = _AH;
   
   printf("result %x\n",i);
     
   /* format track */

   _ES = _DS;                 /* ES:BX pointer to header table */
   _DX = 0x0000;              /* head = 0, drive = A */
   _CX = 0x0100;              /* track = 0, sector = 0 (sector value has no effect ?) */
   _BX = (unsigned) &fmtbuf;  /* ES:BX pointer to header table */
   _AX = 0x050f;              /* function 05h, format 0fh sectors */
   __int__(0x13);
   i = _AH;
   
   printf("result %x\n",i);
}

So, this is my way. What is the right way ?

If you should actually want to try the code, remember that it effectively
destroys the diskette's contents (!). The reason for track 1 is that
it is about the first track I can write without destroying the boot
record and so the BPB which my diskette scanning utility needs. I, in
turn, need this utility to see the results.

Please post answers (if any) directly to me. I'll summarize later if
there is intrest. Any clues are welcome.

-- 
- Jouni Lepp{j{rvi / jml@stekt.oulu.fi   -
- '.. but only maybe, life is a joy .. ' -
Technical Details
Message-ID: <1991Apr22.131323.28547@ousrvr.oulu.fi>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!ousrvr.oulu.fi!stekt!jml

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!ousrvr.oulu.fi!stekt!jml
From: jml@stekt.oulu.fi (Lepp{j{rvi Jouni)
Newsgroups: comp.os.msdos.programmer
Subject: Formatting diskettes, round II
Message-ID: <1991Apr22.131323.28547@ousrvr.oulu.fi>
Date: 22 Apr 91 13:13:23 GMT
Sender: news@ousrvr.oulu.fi
Organization: University of Oulu, Finland
Lines: 84