Mail Archives: djgpp/1996/12/12/19:06:09
Ok, I've been scouring the info files for help, but they don't
mention this problem, so...
I have a function that is declared inline, it has inline assembly
in it. It works fine with optimization off, but doesn't compile with it
on. The error message is 'symbol not defined', where the symbol is the
label that I'm trying to jump to. It only complains when I'm jumping to
a label prior to the jump instruction. I tried someones suggestion of
appending 'b' to 'jnz label1', but that would't compile. Anyways, here
is the soure.
extern __inline__ fixed32 FixedSqrtLP(fixed32 n)
{
fixed32 value=0;
__asm__ __volatile__ ("xor %%eax, %%eax \n"
"mov $0x40000000, %%ebx \n"
"sqrtLP1: mov %%ecx, %%edx \n" // This is the label that I'm
jumping to
"sub %%ebx, %%edx \n"
"jl sqrtLP2 \n"
"sub %%eax, %%edx \n"
"jl sqrtLP2 \n"
"mov %%edx, %%ecx \n"
"shr $1, %%eax \n"
"or %%ebx, %%eax \n"
"shr $2, %%ebx \n"
"jnz sqrtLP1 \n" // this jump won't work
"shl $8, %%eax \n"
"jmp sqrtLP3 \n"
"sqrtLP2: shr $1, %%eax \n"
"shr $2, %%ebx \n"
"jnz sqrtLP1 \n" // this one won't either
"shl $8, %%eax \n"
"sqrtLP3: nop \n"
: "=a" (value)
: "c" (n)
: "eax", "ebx", "ecx", "edx");
return value;
}
I'm calling it like this:
int main() {
FixedSqrtLP(num);
FixedSqrtLP(num);
return 0;
}
And compile it like this:
gcc -O3 -o test.exe test.cc
thanks,
aaron
- Raw text -