help-gplusplus
[Top][All Lists]
Advanced

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

Re: Inline Assembly


From: John V. Shahid
Subject: Re: Inline Assembly
Date: Sun, 30 Sep 2007 23:21:41 -0400

On Sun, 2007-09-30 at 08:27 -0700, scarvenger wrote:
> The following code seems to be considered ilegal in GCC, why?
> 
> movb 2(%1, %%ecx), (%0, %%ecx);

It looks like you're compiling for a 80x86 machine. The 80x86
architecture doesn't have any instruction that moves values between two
memory locations, which is basically what you're trying to do here.

> Why when i try to compile my program with the following code and the option
> -O3 the compiler says to me that the symbol bgrLoop was already defined?
> 
>     __asm__ __volatile__ (
>          "xorl %%ecx, %%ecx;"
>          "bgrLoop:;"
>          "movb  (%1, %%ecx), %%al;"
>          "movb 2(%1, %%ecx), %%ah;"
>          "movb %%al, 2(%0, %%ecx);"
>          "movb %%ah,  (%0, %%ecx);"
>          "addl $3, %%ecx;"
>          "decl %2;"
>          "jnz bgrLoop;" : "=r" (buffer) : "r" (buffer), "r" (size) : "ah",
> "al", "ecx");

Please post a compilable piece of code (even if the code produce
compilation errors) in order for others to help you. Assuming buffer is
of type char* and size is of type size_t, the above code compile with no
compilation errors, even when I use -O3.

-- 
John V. Shahid <jvshahid@gmail.com>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]