Page 1 of 1

Writing the kernel(in asm & c)

Posted: Thu Dec 09, 2004 12:00 am
by john2496
Okay, well I got my crappy bootloader done and that stuff, now its time to write the kernel. My question is this, should I lean more torwards C or ASM?

I've read many tutorials, all of them mixing between C and ASM. The parr I'm confused on is what pieces of the kernel should I be writing in asm and which parts in C?

Should I write functions that deal with the i/o in C and the main parts of the kernel in asm, or vice-vera

Re: Writing the kernel(in asm & c)

Posted: Thu Dec 09, 2004 12:00 am
by [AlAdDiN]
My question is this, should I lean more torwards C or ASM?
U must learn the two languages, coz there is no alternative to asm to do arch dependent code and some IO ...

I've read many tutorials, all of them mixing between C and ASM. The parr I'm confused on is what pieces of the kernel should I be writing in asm and which parts in C?
U can write all ur OS in ASM (like BeOS :p ) but this makes it very hard to maintain.
C is in higher level than asm, that makes it easy to understand, so ...
the convention is to write arch. independent parts in C, and arch dependent parts in ASM

exception : if u have a code that u want make fast to run, u may write it in asm ;)


u can use also C++ but personnaly i preffer C for kernel developping, and C++ for other stuff (shells, servers, etc...)

Re: Writing the kernel(in asm & c)

Posted: Thu Dec 09, 2004 12:00 am
by pepito
Hello:

Try to write all your the kernel using C, and only use ASM where it be strictly necessary.

I wrote a complete OS using ASM but I am now migrating it to C because it is practically impossible to extend and maintain it.

Sincerely,

Re: Writing the kernel(in asm & c)

Posted: Sun Dec 12, 2004 12:00 am
by JAAman
it can be done entirely in ASM (minuet) but not very easy to change or debug

one more note ASM is niether slower nor faster (on P4) than C -- even if your the BEST ASM programmer in the world!!

intel doesnt even release cycle timming info anymore since it cant even be couted properly anymore

the biggest advantage with ASM for pentium+ was making sure you pair instructions correctly but this isnt even important anymore since almost all instructions can be paired and it can execute farther out of order than most entire subrutines and can even change the instruction encodeing to more efficient writeing as its translated(multiply into shift for ex.)

another misconception about optimisation is unrolled loops: they avoid branch mis-predicts
prescott will NOT recieve ANY branch mis penalty unless the loop cycles more than (16? I cant remember for sure)times because the predicter fetches BOTH paths and if it loops more than that than looping improves performance by more than the penalty

this is also true of all P4s and some P3s (not sure about P2)

Re: Writing the kernel(in asm & c)

Posted: Sun Dec 12, 2004 12:00 am
by carbonBased
U can write all ur OS in ASM (like BeOS :p ) but this makes it very hard to maintain.
The BeOS was writtin primarily in C++...

Re: Writing the kernel(in asm & c)

Posted: Sun Dec 04, 2005 12:00 am
by luke
I started off writing the whole thing in ASM but I am trying out C.
I have discovered it takes far more linking though.