Re: gcc question for inline assembly.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Stuart Cracraft 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
> 
> 

Notice that the assembler used by gcc (as) uses by default the at&t assembly
syntax, and you have intel code.
You can either, translate the code to at&t syntax or use the -masm=intel
flag to compile (mount) this code.

read more on at&t syntax at:
http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

Regards,
Marcelo Slomp
-- 
View this message in context: http://www.nabble.com/gcc-question-for-inline-assembly.-tf2256651.html#a6264969
Sent from the gcc - Help forum at Nabble.com.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux