I have just completed this exercise with respect to the "lack of tools" issue. Note that I was referred to this thread by someone not here.bluemoon wrote:I don't know why anyone would want to write boot loader with 16-bit C. It's so obvious that writing a early stage (with do all the necessary real mode functions) with assembly is straightforward*, and any complex logic could be implemented with 32-bit C after entering protected mode or long mode.
* By straightforward, I meant a reasonable early stage boot loader can be implemented in about 500 lines of assembly code.
* In contrast, insist to do that with C you not only end up with almost equal amount of (inline) assembly, but also suffer from the lack of tools.
PDOS/386 (as of an hour ago) now has the ability to build the 16-bit bootloader with PDOS/386 itself. Meaning the required tool is now on PDOS/386 itself. Which means it is a C90-compliant program. That program is "sccdos.exe" - my fork of SubC. The compiler itself is not 100% C90 conformant, but it is sufficiently conformant for my coding style at least. I did have to make some changes to my code because SubC is only small memory model, but my bootloader was previously huge memory model (and before that - large).
Note that "huge" is the technically correct thing in my opinion.
Regardless, for someone like me who struggles with assembler (I'm probably 50 times more productive in C), I dispute that bootloaders shouldn't be written in C. I don't want to see any while or if in assembler. I am happy for small assembler routines.
I wasn't required to use inline assembly at all. Not sure why you would think that was a requirement.
I do call fairly small assembler routines, but they're in separate (masm-compatible) source files.
The switch to PM32 requires more assembler, but there is no way to do that in C anyway, and regardless there are no loops or ifs. That is 500 lines of assembler just for itself. Well, my version has more things in it to allow a return to RM16.
All available on the PDOS/386 hard disk image at http://pdos.org or start with this batch file:
https://sourceforge.net/p/pdos/gitcode/ ... comp4w.bat