4

When the BIOS gives control to the MBR (or the bootloader, for non-partitioned media), it passes the drive number from which the bootloader was loaded in the DL register. This number is most of the times 0x00 when booting floppy drives or 0x80 when booting from hard drives.

The BIOS disk functions (int 0x13) all require a drive number when accessing a drive. Since the bootloader is only given the boot drive's number, how is it possible to determine how many drives are in the system (assuming that the BIOS will enumerate the disks sequentially, so the second floppy is 0x01, the second hard drive is 0x81 and so on...)? There seems to be no BIOS function for this, at least according to Wikipedia.

3
  • IIRC, there is no way to detect a 5.25" floppy drive when no floppy is inserted. The 3.5" drives generate the index pulse without a floppy. – the busybee Oct 19 '20 at 6:17
  • @thebusybee Is the output of the track 0 sensor available in a PC environment? On other platforms, one could step the head out until you get a change on the track 0 sensor (or give up after stepping 80 tracks) – Kaz Oct 20 '20 at 9:41
  • I don't think that this line is available to software. It is used by the FDC. But your note is good: Perhaps it is possible to detect a disk drive by commanding the FDC to go to track 0, and watch it time out or not. However, if it is possible, the operating system needs to use this method and reveal the result. What I don't know. – the busybee Oct 20 '20 at 10:00
7

The number of hard drives supported by interrupt 13h is stored in the byte at 0040h:0075h. This includes drives managed by expansion ROMs (e.g. SCSI drives); see the Wikipedia article on the topic for details. You can also find this value at offset 70h in IBM’s Extended BIOS Data Area.

Hard drives are accessed using values from 80h to 80h + the number of drives, minus one.

3

INT 13h / AL=8, when called with DL >= 80h, will return the number of hard drives in DL. On many systems (but not the original PC or XT) it will do the same for floppy drives if called with DL < 80h.

The number of floppy drives configured can also be determined using INT 11h. If bit 0 of AX is 0 there are no floppy drives; otherwise bits 7 and 6 give the count of floppy drives, minus 1. This is supported on the original PC and XT (where it returns the motherboard DIP switch settings), as well as subsequent systems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.