Warm tip: This article is reproduced from serverfault.com, please click

Any way to list the BIOS drive numbers in real mode

发布于 2017-08-26 01:08:11

Is there any way to list the BIOS drive indexes in real mode (E.g. 0x80, 0x81 ...)?

I did not find any interrupt that is in charge of listing drive numbers!!

Questioner
Mohamad-Jaafar NEHME
Viewed
0
David Wohlferd 2017-08-27 08:21:57

I'm not aware of any way to 'list' the available bios drives in real mode.

However, there are some things that might help:

  • The number of hard drives is stored at 40:75 in the the BIOS Data Area. While I don't 'know' that drive numbers are assigned sequentially, I'd expect them to be. If so, the list of hard drives would run from 0x80 to 0x80 + (40:75 - 1) (although conceivably there could be 0 hard drives, so 0x80 might not be valid either).
  • There is also int 21h function 0E (select default drive), which returns "the highest drive present." Without checking, I'm guessing this is related to LastDrive, but it might be useful.
  • And finally there's int 13h function 08 (read drive parameters) and incrementing the drive number until you get an error. I'm pretty sure DOS maxed out at 26 drives (including hard disks, cds, floppies, etc), so this loop wouldn't run very long.

Note that for bios functions, hard drives typically have the most significant bit set. So hard drive #0 is referred to as 0x80, #1 is 0x81, etc. Floppy drives don't have this bit set and so count from 0.

By the time USB drives came along, I had stopped using DOS, so I'm not sure whether they appear as hard drives or floppies. Since they are removable, I wouldn't expect them to be listed as hard drives, but it may depend on the driver you use.