C: Difference between revisions

21 bytes added ,  17 years ago
no edit summary
[unchecked revision][unchecked revision]
No edit summary
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.
 
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[[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 SampleInlineFunctions[[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.
Anonymous user