(Please do not laugh at my poor English - I am not a native English speaker, but I will try my best to avoid grammar mistakes.)
I want to make a boot loader, and my boot loader is in a U disk. After choosing "booting from USB" when starting the computer, the first sector of the U disk will be loaded in memory automatically. But the rest of the boot loader is still in the U disk, so I have to write some code so that the content in the U disk will be read into memory. I have read this page: http://wiki.osdev.org/USB. But my English is not good, so I cannot read it at all. And I think it just contains some hardware-based information, without how to read from USB by using assembly.
So, would anyone like to tell me how to use assembly to read from a U disk?
I will really appreciate it if you can give me some code.
Thank you a lot!
How can I use assembly to read from a U disk?
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: How can I use assembly to read from a U disk?
Depending on the first sector of your USB flash, the BIOS will emulate a floppy disk or a hard disk. If you want to emulate a hard disk, the first sector will need to have a valid MBR partition table. The BIOS will then boot your USB flash with a BIOS boot drive number 0x80 in DL.
Then, reading the USB stick is done just like a hard disk, using INT 0x13 calls. In fact, your bootloader may not even know if it's booting from USB or hard disk.
These extended functions are the standard for reading hard disk in real mode.
Then, reading the USB stick is done just like a hard disk, using INT 0x13 calls. In fact, your bootloader may not even know if it's booting from USB or hard disk.
These extended functions are the standard for reading hard disk in real mode.
You know your OS is advanced when you stop using the Intel programming guide as a reference.