Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

formatting a floppy

51 views
Skip to first unread message

Paul Edwards

unread,
Jul 18, 2018, 5:38:24 AM7/18/18
to
Could someone give me the recommended
algorithm for formatting a floppy disk
using BIOS calls?

I found this:

http://www.ctyme.com/intr/rb-0621.htm

which looks promising, although it comes
with a warning:

For systems predating the IBM AT, this call is only valid for hard disks

which is a bit strange, given that I
expected floppies to be the first things
that were implemented.

I assume that as part of the floppy disk
formatting procedure, a BPB is written
to the boot sector, containing information
that "format" figured out from various
BIOS calls querying the hardware.

After floppies are working I'll need to
know how to format a hard disk.

Thanks. Paul.

Paul Edwards

unread,
Jul 18, 2018, 9:04:45 AM7/18/18
to
On Wednesday, 18 July 2018 19:38:24 UTC+10, Paul Edwards wrote:
> Could someone give me the recommended
> algorithm for formatting a floppy disk
> using BIOS calls?

Or using MSDOS calls.

BFN. Paul.

Rick C. Hodgin

unread,
Jul 18, 2018, 9:26:34 AM7/18/18
to
Physical floppy drives support formatting a track at a time, and
a number of sectors on the track. There are BIOS calls which format
a track:

http://www.ctyme.com/intr/int-13.htm
http://www.ctyme.com/intr/rb-0610.htm

You'll just have to write an algorithm that iterates through the
info for the size of the disk. A nested set of for {..} loops
would do it, accounting for head and track formatting all sectors
on each track.

BIOS disk info:
http://www.ctyme.com/intr/rb-0639.htm

Note: The disk info is not always correct on all BIOS versions.
You'll have to trust it, or look require a double-sided,
high-density 3.5" 1.44 MB floppy, or some such. There may
also be algorithms in Linux or other source which more
accurately identify the floppy type on BIOS versions where
the information is not properly conveyed.

Note: I've never seen it fail in all of my testing.

--
Rick C. Hodgin

Ivan Shmakov

unread,
Jul 18, 2018, 9:37:24 AM7/18/18
to
>>>>> Paul Edwards <muta...@gmail.com> writes:

> Could someone give me the recommended algorithm for formatting a
> floppy disk using BIOS calls?

> I found this:

> http://www.ctyme.com/intr/rb-0621.htm

Did you by chance mean -0610.htm instead?

> which looks promising, although it comes with a warning:

> For systems predating the IBM AT, this call is only valid for hard
> disks

> which is a bit strange, given that I expected floppies to be the
> first things that were implemented.

> I assume that as part of the floppy disk formatting procedure, a BPB
> is written to the boot sector, containing information that "format"
> figured out from various BIOS calls querying the hardware.

The floppy disk itself is /not/ part of the hardware that can be
queried with BIOS calls; rather, it was the responsibility of
the /user/ to specify how the disk is to be formatted (which
would better to match its specs.)

Consider, e. g., the convenience /F:size option to FreeDOS
FORMAT, as well as low-level /T:, /N: options. [1]

From there, the algorithm is along these lines:

* decide what type of disk is being formatted (360k, ..., 2880k,
or custom);

* configure the drive for specified format with int 13h, ah =
17h or 18h [2, 3]; set the int 1eh vector to the value returned;

* for (i = 0; i < tracks; i++) format track i;

* repeat for the other side if formatting a double-side floppy.

* restore the int 1eh vector.

After formatting, it'd probably be wise to install a filesystem
on the disk, that is (assuming FAT12): a "boot sector" and one
or more FAT tables. But that's another story.

[1] format // FreeDOS commands.
URI: http://help.fdos.org/en/hhstndrd/base/format.htm
[2] Int 13h: AH = 18h
URI: http://www.ctyme.com/intr/rb-0643.htm
[3] Int 13h: AH = 17h
URI: http://www.ctyme.com/intr/rb-0641.htm

[...]

--
FSF associate member #7257 http://am-1.org/~ivan/

Rod Pemberton

unread,
Jul 18, 2018, 4:10:04 PM7/18/18
to
On Wed, 18 Jul 2018 02:38:23 -0700 (PDT)
Paul Edwards <muta...@gmail.com> wrote:

> [snip]
> For systems predating the IBM AT, this call is only valid for hard
> disks
>

Bitsavers archives a bunch of programming and computing stuff here:
http://bitsavers.trailing-edge.com/

IBM AT/XT/PC Technical reference manuals should be in their
directory here:
http://bitsavers.trailing-edge.com/pdf/ibm/pc/

PS/2 Technical reference manuals:
http://www.mcamafia.de/pdf/pdfref.htm


I've posted a number of posts to comp.os.msdos.programmer with links to
various technical references for DOS, BIOS, and AT/XT/PC etc. These
are some of the more recent posts. If any of the links are bad, it
might be good in another post, or I'll attempt to track it down if you
want it.

https://groups.google.com/d/msg/comp.os.msdos.programmer/y-NXoYRaxuQ/wuFu71JRAQAJ
https://groups.google.com/d/msg/comp.os.msdos.programmer/13YDpwuIBP4/zz2VwEBvDwAJ
https://groups.google.com/d/msg/comp.os.msdos.programmer/m81wlINr1bs/NyST6AhgFAAJ


Rod Pemberton
--
As long as the UK continues to work with the EU, Brexit won't happen.
The first pawn sacrifice: Gibraltar. Set Gibraltar free.

Paul Edwards

unread,
Jul 19, 2018, 12:35:43 AM7/19/18
to
On Wednesday, 18 July 2018 23:37:24 UTC+10, Ivan Shmakov wrote:

Hi Ivan. Thanks for your reply.

> The floppy disk itself is /not/ part of the hardware that can be
> queried with BIOS calls; rather, it was the responsibility of
> the /user/ to specify how the disk is to be formatted (which
> would better to match its specs.)
>
> Consider, e. g., the convenience /F:size option to FreeDOS
> FORMAT, as well as low-level /T:, /N: options. [1]
>
> From there, the algorithm is along these lines:
>
> * decide what type of disk is being formatted (360k, ..., 2880k,
> or custom);

I'm having trouble getting my head around
this. Normally when I format a floppy, the
format command doesn't require any
parameter to know what to do.

I can understand the concept that the
floppy disk itself could be 720K instead
of the normal 1.44 MB. But shouldn't the
drive itself be queryable to determine
if it is a 1.2 MB or a 1.44 MB drive?

Then I would at least have a default.

BFN. Paul.

Ivan Shmakov

unread,
Jul 19, 2018, 1:50:24 AM7/19/18
to
>>>>> Paul Edwards <muta...@gmail.com> writes:
>>>>> On Wednesday, 18 July 2018 23:37:24 UTC+10, Ivan Shmakov wrote:

>> The floppy disk itself is /not/ part of the hardware that can be
>> queried with BIOS calls; rather, it was the responsibility of the
>> /user/ to specify how the disk is to be formatted (which would
>> better to match its specs.)

>> Consider, e. g., the convenience /F:size option to FreeDOS FORMAT,
>> as well as low-level /T:, /N: options.

>> From there, the algorithm is along these lines:

>> * decide what type of disk is being formatted (360k, ..., 2880k,
>> or custom);

> I'm having trouble getting my head around this. Normally when I
> format a floppy, the format command doesn't require any parameter to
> know what to do.

The command may use the "current" parameters (that is: those
used for the last disk I/O) as defaults. Alternatively, given
that most floppies came preformatted, it may try reading the
boot sector using several popular formats, and if successful,
get the parameters from there.

> I can understand the concept that the floppy disk itself could be
> 720K instead of the normal 1.44 MB. But shouldn't the drive itself
> be queryable to determine if it is a 1.2 MB or a 1.44 MB drive?

> Then I would at least have a default.

Yes. Apologies if I wasn't clear on that.
0 new messages