Is C directly capable of producing a bootable kernel.sys?
I think we would have to use a bit of assembly to get things started, then shift control over to C. If I'm correct, then what linker would we use to merge the two?
On Saturday, July 25, 2015 at 7:30:12 AM UTC-4, maarten wrote:Granted the terminology is different, but there's not much difference between C and Java structurally. Then again, this is coming from a C programmer who never wrote anything in Java! lol
djdev203.zip DJGPP Basic Development Kit (Pretty sure this isn't neccessary) bnu225b.zip Basic assembler, linker Needed gcc473b.zip Basic GCC compiler Definitely needed csdpmi7b.zip CWSDPMI - DPMI server (Not sure if any GCC uses this or not - don't think so though)
gcc -ffreestanding -c -o kernel.obj kernel.cand then wrote a simple do-nothing kernel.c as follows:
ld -Ttext 0x0600 --oformat binary -o kernel.sys kernel.obj
void main(void)
{
repeat:
goto repeat;
}
I then used MAKE to run the batch file and got the resulting kernel.sys, 1KB in size. Only a few useful bytes of code (three lines of assembly) are in the beginning of the file, the rest is garbage but doesn't get executed anyway. The size anomaly must be a quirk of GCC.Mercury,nicely done.As for the "Java or C" thing,is Java even a good operating system code?To clarify,shouldn't we write our operating system code in something OTHER than Java?Java is a great programming language for Applications and the "bells and whistles" of the OS,but the actual OS itself should be programmed in C or assembly.
Hey,Check out this wiki article on building a cross compiler.GCC can probably be built specifically for NightDOS.-Tony
It's in Cygwin which only runs on Windows.The output can be pure binary or i686 ELF (which doesn't matter for NightDOS). Loading a .EXE file for DOS or PE .EXE is just a matter of reading the program file and executing the code.
Unfortunately, it won't work in FreeDOS, primarily because of its 16-bit nature. However, if you'd prefer Linux over Windows I'll research that.
To answer your question about building the kernel, the rest of the OS can be built in C and linked to the assembly code that has been written or will be written.
This is where that stage 2 loader comes in. Build a parser to handle the PE EXE format or COFF format. Just jumping past the header info is all you need to do. I will look into it though.
I have a real mode keyboard section in one of my files. Also the most what I did was in real mode...
Maarten
Nah, you just work the ports Maarten. In MASM/TASM/NASM parlance it would be in port and out port, accumulator. In GAS parlance (GNU assembler), the assembler mnemonic is outb an inb (since the keyboard is a byte port). You can wrap an interrupt around this if you'd like to provide some similarity to BIOS Int 16h. I'm assuming you have the ICW and PIC stuff coded already.
Should we give users a choice of 16 bit or 32 bit at boot time,like a selection menu?