Certain parts of an operating system can only be written in Assembly. Others can be implemented using InlineAssembly, but still require knowledge outside the realm of your high-level language of choice.

The canonical example of code that must be written in pure Assembly is the first-stage bootloader. If you choose to write your own instead of using an existing solution such as GRUB, it must be written in Assembly, as it requires direct manipulation of certain registers; specifically, the segment selectors and the stack pointer, which would not be possible in C itself.

Other functions, such as loading the Global Descriptor Table (on the IA32 architecture), also require special opcodes which are not available within C language (but can be implemented in InlineAssembly). In the (unlikely) case your compiler does not support InlineAssembly, you have the option of writing 'support functions' in a separate assembly file. Note that we have a page with SampleInlineFunctions for basic operations using GCC.

InterruptServiceRoutines also require some special handling, because they are called directly by the CPU, not by the C environment.