Newsgroups: comp.os.msdos.djgpp From: "Pin F. Sun" Subject: Re: inline assembly - jumps Sender: news AT undergrad DOT math DOT uwaterloo DOT ca (news spool owner) Message-ID: <32B229D3.41C6@undergrad.math.uwaterloo.ca> Date: Sat, 14 Dec 1996 04:15:16 GMT Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii References: <19961213 DOT 064349 DOT 4351 DOT 1 DOT aclemmer AT juno DOT com> Nntp-Posting-Host: zeno20.math.uwaterloo.ca Mime-Version: 1.0 Organization: University of Waterloo Lines: 67 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Aaron m Clemmer wrote: > > 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 I had this problem, too. Everytime a label is defined before a jump instruction calls it, the compiler generates error messages. I've tried things like: asm (" cmp %edx, $1200 jge SKIP inc edx SKIP: ... "); No error messages generated if the label is defined after the jump. I am using DJGPP v2.0, would v2.01 better?