Page 1 of 1
Writing the kernel(in asm & c)
Posted: Thu Dec 09, 2004 7:36 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 7:46 am
by Pype.Clicker
well, considering the amount of code in a kernel, you're *strongly* suggested to write it in C rather than in 100% pure asm ... That'll give you a better overview of what's happening, what depends on what, etc. than if the code was 10 times longer ...
Now, that doesn't mean writing an OS kernel in pure ASM is not feasible. Some projects exists and have been rather successful.
I suggest you look at
http://www.osdev.org/osfaq2/index.php/T ... notDoWithC for further enlightenment ...
Re:Writing the kernel(in asm & c)
Posted: Thu Dec 09, 2004 8:05 am
by john2496
Alright thanks
I'm going to use c and asm, its a really a question of which to use more. For example, consider this...
If I was to write most of the kernerl in asm, and call c functions
main:
call _somecfunc
void somecfunc() {
int bob = 10;
}
OR
If I was to write most of the kernel in c, and call asm functions
void
main() {
someasmfunc()
}
_someasmfunc:
push ax
mov ah, 00
int 10h
Re:Writing the kernel(in asm & c)
Posted: Thu Dec 09, 2004 9:45 am
by stonedzealot
Well, it depends on what you're going for. If you're going for speed, then you should probably lean more towards ASM... if you're going for code clarity you should probably do everything you can in C. Most people just survey the problem and see which language they'd be most comfortable implementing a solution in.
Re:Writing the kernel(in asm & c)
Posted: Thu Dec 09, 2004 10:17 am
by ASHLEY4
You need to ask your self which language you know best.
I am writing a pure assembly OS, but most of the help is for C OS.
I do not think pure asm OS, are any faster the a C OS.
To me if you know C best do as little in asm as you can, but if you know assembly best do a pure asm OS is best, stick with what you know.
\\\\||////
(@@)
ASHLEY4.
Batteries not included, Some assembly required.
Re:Writing the kernel(in asm & c)
Posted: Fri Dec 10, 2004 4:11 am
by Pype.Clicker
ASM kernel will be faster than C kernel only if you're better at ASM than at C. And C kernel will be faster than ASM kernel only if you're better at C than at ASM. This is really a matter of religion and human skill. Not of the language or compiler. You can write obfuscating/unmaintainable/damn-slow code in whatever language you dislike and clear/easy-to-maintain/fast code in whatever language you like.
That being said (and i hope it will be agnostic enough to avoid Yet Another Flamewar About ASM speed and C maintainability), in a pmode kernel (i mean, once pmode runtime is set up), you barely need asm, while realmode system programming was way easier in asm because of all those register-passing services in bios INTerrupts ...
Things like memory management algorithms, dynamic linkers, filesystems, etc. are probably easier to write in C than in any other language ... And interrupt stubs, graphics rendering, audio mixing and things alike are probably easier to write in ASM ...
In most mainstream OS (and virtually any UNIx derivative), ASM is only used for platform-specific bits, and C is used everywhere else.
Re:Writing the kernel(in asm & c)
Posted: Fri Dec 10, 2004 12:04 pm
by ASHLEY4
I agree with Clicker, you are well on your own in pmode using assembly, with out all thouse bios/dos int's to help you.
\\\\||////
(@@)
ASHLEY4.
Batteries not included, Some assembly required.