/* * NOTE: This code will not run. It will compile though ;-). It is intended * as a sample of how to use the inline assembly features of gcc * */ int main() { int sample_output, sample_input1, sample_input2; __asm__ __volatile__ ( /* Part 1 is the actual text that gets inserted */ "xorl %%eax,%%eax; movl %%eax,%%fs; movl %%eax,%%gs\n" "movl %1,%%esp\n" "small_loop:\n" "addl %0, %%eax\n" "addl %%eax, %2\n" "jmp small_loop\n" /* Part 2 is the outputs */ : "=r" (sample_output) /* Part 3 is the intputs */ : "r" (sample_input1), "r" (sample_input2) /* Finally, Part 4 is the part that tells gcc what got messed with in the machine state */ : "eax", "edx" /* modified registers */); }