As a hobby project I am working on a small OS project for i386 (and ARM). Recently I was writing a driver for floppy disk drives and I stumbled on to a issue that I needed to find a solution for. The issue was how to detect if any or how many floppy disk drives are present on a given system. I quick google informed me that the CMOS was normally used for this and the page provided some getting started information on how to detect floppy disk drives. The #osdev wiki also had some good information about the CMOS. Using this information I started implementing a very simple FDD detection routine to use in my OS.
First a bit about the CMOS: The CMOS is a static memory chip used to store information for the BIOS while the computer is powered down. The CMOS memory is located on the same chip as the real time clock. Because of this developers normally think of the RTC to be a part of the CMOS, even though it is not. The CMOS can be accessed via port IO. It uses the ports 0x71 and 0x70. To read data you send the number/id of the register you want to read from to port 0x70 and the value of the register becomes available from port 0x71.
With this information in my mind I then started on my implementation. Using the documentation from the #osdev wiki I knew that the information about the floppy disk drives was present in register 0x10 and all I had to do was to read it.
My implementation became as follows: