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
Writing the kernel(in asm & c)
Re: Writing the kernel(in asm & c)
U must learn the two languages, coz there is no alternative to asm to do arch dependent code and some IO ...My question is this, should I lean more torwards C or ASM?
U can write all ur OS in ASM (like BeOS :p ) but this makes it very hard to maintain.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?
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...)
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
There are 10 types of people in this world... those that understand binary, and those that don't.
Re: Writing the kernel(in asm & c)
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,
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,
Pepito
Re: Writing the kernel(in asm & c)
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)
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)
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: Writing the kernel(in asm & c)
The BeOS was writtin primarily in C++...U can write all ur OS in ASM (like BeOS :p ) but this makes it very hard to maintain.
Re: Writing the kernel(in asm & c)
I started off writing the whole thing in ASM but I am trying out C.
I have discovered it takes far more linking though.
I have discovered it takes far more linking though.