[comp.sys.ibm.pc] How can you check that a readable floppy is in a drive?

mike@erix.ericsson.se (Mike Williams) (08/10/88)

is in a cerain drive (for example b:). I have tried using
int 13h with ah=4 to do a verify on a sector on the floppy. This
always works OK on the second or third attempt. But if the disk
is not readable and one tries again with a new disk always
fails on the first new attempt with 'Drive failed to respond' in ah 
(80H) on return. The next attempt gives 'address mark not found'
and 'requested sector not found' (06H) in ah and the third attempt
works.

I have tried doing int 13h with ah=0 (reset diskette) first but this
seems only to eliminate the first error. I have also tried to do an
int 13h with ah=01 first (diskette status) but this makes no difference.

What's going on here? Do I really need to do 'verify' three times before
I can be sure that the result is OK?

I also see that ah=05h can be used to format one or more sectors, is there
any way of using this to write one's own 'format' program? I would like to
be able to format a disk from within my program without spawning a
format b:  task to let DOS do it for me.

Mike Williams

mike@erix.ericsson.se   or  ...uunet!enea!erix!mike

haugj@pigs.UUCP (Joe Bob Willie) (08/12/88)

In article <1736@erix.ericsson.se> mike@erix.ericsson.se (Mike Williams) writes:
|is in a cerain drive (for example b:). I have tried using
|int 13h with ah=4 to do a verify on a sector on the floppy. This
|always works OK on the second or third attempt. But if the disk
|is not readable and one tries again with a new disk always
|fails on the first new attempt with 'Drive failed to respond' in ah 
|(80H) on return. The next attempt gives 'address mark not found'
|and 'requested sector not found' (06H) in ah and the third attempt
|works.

it may be that your floppy drive has not yet spun up to speed
until the third request is issued.  try sticking a delay in between
the first drive query and the second.  don't forget that physical
hardware is SLOW by comparision to CPU's.
-- 
 jfh@rpp386.uucp	(The Beach Bum at The Big "D" Home for Wayward Hackers)
     "Never attribute to malice what is adequately explained by stupidity"
                -- Hanlon's Razor