is used to make requests to the operating system. This is rarely a feature in a higher-level language, and so wrapper functions for system calls are written using inline assembler. The following C code example shows an x86 system call wrapper in AT&T assembler syntax, using the GNU Assembler. Such calls are normally written with the aid of macros; the full code is included for clarity. In this particular case, the wrapper performs a system call of a number given by the caller with three operands, returning the result. To recap, GCC supports both basic and extended assembly. The former simply passes text verbatim to the assembler, while the latter performs some substitutions for register locations. extern int errno; int syscall3(int num, int arg1, int arg2, int arg3) { int res; __asm__ ( "int $0x80" /* make the request to the OS */ : "=a" (res), /* return result in eax ("a") */ "+b" (arg1), /* pass arg1 in ebx ("b") [as a "+" output because the syscall may change it] */ "+c" (arg2), /* pass arg2 in ecx ("c") [ditto] */ "+d" (arg3) /* pass arg3 in edx ("d") [ditto] */ : "a" (num) /* pass system call number in eax ("a") */ : "memory", "cc", /* announce to the compiler that the memory and condition codes have been modified */ "esi", "edi", "ebp"); /* these registers are clobbered [changed by the syscall] too */ /* The operating system will return a negative value on error; * wrappers return -1 on error and set the errno global variable */ if (-125 <= res && res < 0) { errno = -res; res = -1; } return res; } in "moderne" architecture like x86_64, must use syscall Input are precised in documentation returns values can be on two registers according to architecture #include <errno.h> long int syscall3(unsigned int num, int arg1, int arg2, int arg3){ int retA, retB; long int ret; asm ( "syscall\n\t" :"=a"(retA),"=d"(retB) :"a"(num),"d"(arg3),"D"(arg1),"S"(arg2) :"cc","memory" ); ret=retA; /* here, only one */ if (-125 <= ret && ret < 0) { errno = -ret; ret = -1; } return ret; } Processor-specific instruction in D This example of inline assembly from the D programming language shows code that computes the tangent of x using the x86's FPU (x87) instructions. // Compute the tangent of x real tan(real x) { asm { fld x[EBP] ; // load x fxam