First, get yourself a list of x86 op codes, should be easy to find online.
The asm()
function follows this order:
asm ( "assembly code"
: output operands /* optional */
: input operands /* optional */
: list of clobbered registers /* optional */
);
Second, one major problem you have is you can't "jump" to a C label, you need to make your label an "assembly" label to be able to jump to it. ex:
int main()
{
asm("jmp .end"); // make a call to jmp there
printf("Hello ");
asm(".end:"); //make a "jumpable" label
printf("World\n");
return 0;
}
Output of this program is simply "World" as we jumped over the "Hello ". Here's the same example but with a comparative jump:
int main()
{
int x = 5, i = 0;
asm(".start:");
asm("cmp %0, %1;" // compare input 1 to 2
"jge .end;" // if i >= x, jump to .end
: // no output from this code
: "r" (x), "r" (i)); // input's are var x and i
printf("Hello ");
i++;
asm("jmp .start;");
asm(".end:");
printf("World\n");
return 0;
}