This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc question for inline assembly.


Hi Stuart -

This is really a C/C++ question, and not really a gcc/c++ question.

However, in C, you can't pass things by reference (the &), you should
pass by address instead, and then dereference to set the values.

Brian

On 9/11/06, Stuart Cracraft <cracraft@cox.net> wrote:
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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]