In computer programming, the inline assembler is a feature of some compilers that allows very low level code written in assembly to be embedded in a high level language like C or Ada. This embedding is usually done for one of three reasons:
- Optimization: when assembly language is inlined for optimization, the most performance-sensitive parts of an algorithm are replaced by hand-written assembly. This allows the programmer to use the full extent of his ingenuity, without being limited by a compiler's higher-level constructs.
- Access to processor specific instructions: some processors offer special instructions, such as Compare and Swap and Test and Set — instructions which may be used to construct semaphores or other synchronization and locking primitives. Nearly every modern processor has these or similar instructions, as they are necessary to implement multitasking. To name a few, specialized instructions are found in the SPARC VIS, Intel MMX and SSE, and Motorola Altivec instruction sets.
- System calls: high-level languages rarely have a direct facility to make system calls, so assembly code is used.
Read more about Inline Assembler: Example of Optimization and Processor-specific Instructions, Example of A System Call