119 views
# cs6332: inline assembly ```= asm ( assembler template : output operands // (optional) : input operands // (optional) : clobbered registers list // (optional) ); ``` * *clobbered registers* list: A comma-separated list of registers or other values changed by the AssemblerTemplate, beyond those listed as outputs. An empty list is permitted ![](https://codimd.syssec.org/uploads/29dcaccb-3290-4673-86fe-62aba3ac1dd5.png) ## Example ```c= int main(void) { int foo = 10, bar = 15; __asm__ __volatile__("addl %%ebx,%%eax" :"=a"(foo) :"a"(foo), "b"(bar) ); printf("foo+bar=%d\n", foo); return 0; } ``` ## Resources * [How to Use Inline Assembly Language in C Code] * [GAS examples] * [GCC inline assembly howto] [GAS examples]:https://cs.lmu.edu/~ray/notes/gasexamples/ [How to Use Inline Assembly Language in C Code]:https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html [GCC inline assembly howto]:https://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html ###### tags: `cs6332`,`inline`,`assembly`