C: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
Line 22: Line 22:
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.
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 inline Assembly, 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.
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 [[Inline Assembly]]). In the (unlikely) case your compiler does not support inline Assembly, you have the option of writing 'support functions' in a separate assembly file. Note that we have a page with [[Inline Assembly/Examples|examples]] for basic operations using GCC.


[[Interrupt Service Routines]] (ISRs) also require some special handling, because they are called directly by the CPU, not by the C environment.
[[Interrupt Service Routines]] (ISRs) also require some special handling, because they are called directly by the CPU, not by the C environment.
Retrieved from "https://osdev.wiki/wiki/C"