gcc question for inline assembly.

Stuart Cracraft cracraft@cox.net
Tue Sep 12 04:25:00 GMT 2006


Hi - someone supplied the following code
in a C++ program to me that g++ compiled.

However, I want to convert it to use it in
a regular C program that gcc can compile.

Needless to say, the construct does not work
for GNU C.

I've tried placing each line of the assembly
in asm("...."); and that also fails to get
gcc to compile it.

What would the equivalent GNU C function for the
below be?

static unsigned int bitScanAndReset(unsigned long long & bb) {

       __asm
       {
               xor     edx, edx
               mov     ebx, [bb]
               xor     eax, eax
               inc     edx
               bsf     ecx, [ebx]
               jnz     found
               bsf     ecx, [ebx+4]
               lea     ebx, [ebx+4]
               xor     eax, 32
       found:
               shl     edx, cl
               xor     eax, ecx
               xor     [ebx], edx
       }
}

Thanks,

Stuart




More information about the Gcc-help mailing list