On 02/15/2011 11:58 PM, Andi Hellmund wrote:
On 02/16/2011 12:11 AM, kevin diggs wrote:
Hi,
Does the asm in:
#include<stdio.h>
int main(int argc, char *argv[])
{
unsigned int pc;
asm("\n\t"
"call 1f\n\t"
"1: pop %0\n"
:"=g"(pc)
);
printf(__FILE__"`%s()-%d: %%pc is %p\n",__func__,__LINE__,pc);
return 0;
}
need volatile?
no, you don't need the volatile keyword since the output operand
(pc) is live after the asm statement which puts a side-effect on the
asm statement.
I'm not sure about that. Because there is no input operand, gcc is
free to move the asm. Volatile will prevent that from happening.
I'd do this:
#include <stdio.h>
int main(int argc, char *argv[])
{
unsigned int pc;
pc = (unsigned int)&&label;
label:
printf(__FILE__"`%s()-%d: %%pc is %p\n",__func__,__LINE__,pc);
return 0;
}
Andrew.