I've been trying this for 1 year now and can't seem to find anything useful (yeah, I know I suck). I've made a C++ application with WinAPI which allows me to read and write raw disk bytes with CreateFile(). However, now I need to do it with assembly so the program runs as a bootloader. It will interact with the user, but that part I can handle.

So I've tried many tutorials of making your own operating system, but none of the code there appears to work. I started with this and learned how to print text to the screen (which I will use to interact with the user):
http://www.howtodothings.com/computers/a1015-making-your-own-operating-system.html

Then I tried many tutorials on bootloaders and bootstraps which I don't have anymore because my bookmarks were deleted. However I recently tried the part of the following code to read sectors and tired to print them to the screen, but it didn't work:
http://www.omninerd.com/articles/PC_Bootstrap_Loader_Programming_Tutorial_in_ASM

I found that all tutorials talk about bootloaders and bootstraps loaded from a floppy disk, not a hard disk, and when I change the parameters for a hard disk it doesn't work.

I no longer know what to do, I've created and got rid of countless bootloaders until now because I couldn't make them work. Does anyone know of any code or tutorial that will allow me to read the MBR 512 bytes with a bootstrap and store them in a variable? That's where I'm stuck, I can't read them from the hard disk, much less store them in a variable (which I will then use teletype to print it to the screen).

I am using 16 bits assembly and emu8086 as compiler. Tried to look if one could make a bootloader with 32 bits assembly, but found no tutorial on 32 bits bootstraps.

Recommended Answers

All 3 Replies

Sorry for double posting, I can't find the edit option with the new template.
EDIT:

Let's make this easier to understand...

Is it possible to read a 500 GB Hard Disk with interrupt 13 (INT 13h)? Or is INT 13h obsolete? If so, how do I then read such a disk?

The original INT 13h was for a real-mode system. Once the operating system has booted into the OS these days, unless you are running MS-DOS/FreeDOS, et al, you will be running in protected mode. You need to check your OS documentation to see if INT 13h will still work for you. You set up some registers for the sector to read, and possibly the address to read the disc into (normally that would be fixed in a real-mode boot loader), execute the interrupt, and there you are. FWIW, the last time I wrote a bootloader (real mode) was in 1986 or 1987. I'd have to pull out my old IBM PC BIOS docs to see what needs to be done for sure...

Ah, don't worry. It does work, my code. Its just that I thought it didn't work because I couldn't see what I was reading from the hard disk when I tried to print it to the screen. In shorts, my code wasn't the correct way of prinitng what I had, but it was reading.

So yup, it does work for a couple of sectors. Let me add that there are limits in real mode and if one wants to read past those limits, one needs to enter protected mode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.