10 Dec 2002 madhatter   » (Journeyer)

GCC quirk

i was fooling around with SIMD instructions on my notebook today and found something with gcc inline assembly:

asm volatile("xor %%eax,%%eax\n");

it looks like a pretty reasonable statement, but unfortunately it will not compile. gas will tell you that %%eax is an invalid register. it was throwing me for a loop for a while until mpr pointed out to me that gcc did not strip the first parentheses from the register name for some reason. gas doesn't want "%%eax", it wants "%eax", so I was sitting there with my thumb up my butt for about 5 minutes until I started messing with my inline statement, then doing gcc -S to see what the assembler output looked like. I couldn't get gcc to strip the first parentheses until I changed it to this:

asm volatile("xor %%eax,%%eax\n" : );

no, that's not supposed to be a smiley face. If you at least put the output operand colon there gcc will strip the first parentheses, otherwise it will assemble it without touching it and gas will go kaput. does anyone know why this happens?

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!