Before this chapter, bootloader was built to work with floppy disk. Fortunately, I had a usb floppy disk drive, and BIOS has a feature to emulate it as a normal floppy disk so I could boot from floppy disk on real computer. However, the drive was not working for some reason. To get around this problem, I modified the bootloader code, so computer can load MINT64OS from USB.
When bootloader is loaded at 0x07C0:0x0000, bios set dl register
with disk drive number which has the bootloader code. Bootloader asks BIOS
the drive information including maximum cylinder, head, and sector. Based on
the information, BIOS loads MINT64OS at 0x10000.
Unfortunately, when BIOS came to the world, USB did not exist, and there is still no standard specification about how to boot from USB. Some vendors emulate USB as a Floppy disk drive and most vendors emulate USB as a hard disk drive. In addition, some of them that emulate USB as a hard disk require USB to have valid partition entries in MBR section. Otherwise, they skips booting from USB.
My father's Samsung laptop and my Acer laptop emulates USB as a hard disk.
the Samsung laptop allows the USB to boot. However, the Acer laptop requires
it to have partition entries. Therefore, I put a fake partition entry at 0x1BE
Although the partition really exist, it is ok if the entry looks valid to BIOS
In my Acer laptop, BIOS allows to use video memory address without some preparation action. However, the Samsung laptop requires some action before using the video memory address. Otherwise, nothing comes up to the screen.
I do not know the exactly problem, but using a BIOS service that prints text on the screen solves the problem. Therefore, I added code using BIOS service before clearing the whole screen.
-
When bootloader is loaded,
dlcontains drive number that contains the bootloader code -
0x13interrupt withah=0x08let you have a drive information. The information contains maximum track number, head number, and sector number. You can use the info to load operating system into memory.
0x10interrupt withah=0x0Elet you write a character.
-
lodsbmeans load string byte. For legacy mode, it load byte at address DS:(E)SI into AL. For 64-bit mode load byte at address (R)SI into AL.- Unlike mov, lods increments/decrements ESI additionally.
- It is usually faster than just mov for this specific goal
-
orsetZF=1if result is zero -
conditional jump,
jzjump ifZF=0