Interesting... How would I do that? C generates no less than 32-bit code I thought. Perhaps this is one of the holes in my knowledge, and definitely not something I took into consideration. About the multiple disk sectors either.Octocontrabass wrote:It's possible, but it definitely won't work if you forget RET at the end of your function, and you need to tell the compiler to emit 16-bit code, and you need to obey the compiler's ABI, and you need to load enough sectors from the disk because compiled C will quickly outgrow the one sector the BIOS loads for you.TheGameMaker90 wrote:Is it not possible to do it that way?
You might want to consider splitting the bootloader into two or more stages, where the first stage is written entirely in assembly to fit within the single sector provided by the BIOS.
You might want to consider switching the CPU to 32-bit protected mode for your C code, and using a wrapper around BIOS interrupts that switches the CPU to real mode before calling the BIOS and back to 32-bit protected mode after the call returns.
That is something I was thinking of doing anyway, but with this approach, it seems inevitable based on what you're telling me. The problem is that I really have my heart set on getting it done this way (if for no other reason that learning), but something I'll take into consideration. I already had a basic bootloader at one point (or more like for one of my OSes, I have a couple of dummy projects also for learning). After getting to a cetain point I'd get a black screen. I quickly (or not quickly enough) realized this might be an issue, but only kept adding sectors. I'm not real sure how to do much else with disks, but I will be doing more research.
And isn't that the default way of doing it? Write a bootloader, switch to 32 bit protected mode, then call kmain or your kernel's entry point. I would honestly like to go above the normal way. If I physically can't, I'll no doubt go back to the default setup. I honestly haven't swapped anything out yet, so my OS will continue to use GRUB until I get [something/it] working.