Do I need to know assembler to hack the kernel?


In fact, even if you do know assembler it is better if you stick to C in most of the kernel, so your code is more portable, is more easily read and maintained and can be optimized by the compiler, which gets confused a lot less than humans do.

The kernel uses assembler code only where it is really needed:

Note that many of the things above need to be done from C code, for example device drivers need to poke at I/O ports. This is done through architecture defined C macros like inb, inw, inl, outb, outw and outl. These macros will automatically do the right thing by including the bits of inline assembler that are needed to make your driver work on the architecture on which it is compiled.

This means that the same device driver, written in C, can work on i386, x86-64, MIPS, PPC and other architectures. If the driver is written carefully, taking little/big endianness and 32 vs 64 bitness into account, no changes will be needed to run the driver on multiple architectures.

What about C++?

No. God no. Please see the [ LKML FAQ] on that.

KernelNewbies: FAQ/DoINeedToKnowAssembler (last edited 2006-08-10 02:52:42 by RikvanRiel)