views:

205

answers:

2

Hi

Silly question, but I just can not find the necessary flag in gcc. Basically, I have in my C program the following inline assembler code

asm volatile ("lea ebx, [timings] \n\t");

When compiling, I get an errormessage which says: Error: invalid char '[' beginning operand 2 `[timings]'

Now I remember that a long time ago I used some kind of flag that told the compiler that it is x86 inline assembly. But cant find it online, could maybe someone please tell me which flag i have to use?

Thank you so much!

A: 

Try using __asm__ instead. Look here for more.

Also, try removing the \n\t from inside the assembly code.

samoz
+6  A: 

You can't specify variables that way with GCC. See this document for a detailed description of how to use inline assembler. Also, keep in mind that GCC uses AT&T syntax, not Intel syntax, so you have to put your destinations on the right.

Adam Rosenfield
I did it in the past, you can specify with the compiler that you use intel syntax but silly me has forgotten how to to that
I don't know how well it works, but from the GCC documentation: `-masm=DIALECT' Output asm instructions using selected DIALECT. Supported choices are `intel' or `att' (the default one). Darwin does not support `intel'.
ephemient