1 Jul 2011 17:28
Re: Can a float volatile asm be used as optimization barrier?
Parmenides <mobile.parmenides <at> gmail.com>
2011-07-01 15:28:05 GMT
2011-07-01 15:28:05 GMT
>
> As is documented in the gcc manual, "asm
> volatile" means that the instruction has side effects which are not
> described in the outputs, and thus may not be deleted.
I think it necessary to get my feet wet for side effects. I try to
modify an example in gcc manual to make it adapt to IA32.
#define add(new) \
({ int __old; \
asm ("addl %1, %0" \
: "=g" (__old) : "g" (new)); \
__old; \
})
void tst(void)
{
int x = 15;
add(x);
}
Then, I invoked gcc to compile it :
gcc -S -O tst.c
and, get the following asm code :
tst:
pushl %ebp
movl %esp, %ebp
popl %ebp
ret
(Continue reading)
Thanks a lot.
RSS Feed