gcc question for inline assembly.
Brian Budge
brian.budge@gmail.com
Tue Sep 12 06:14:00 GMT 2006
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
>
>
>
More information about the Gcc-help
mailing list