[theora-dev] "Xiph needs someone to help with assembly for MSVC!"

xiphmont at xiph.org xiphmont at xiph.org
Thu Oct 2 08:04:42 PDT 2008


On Thu, Oct 2, 2008 at 10:30 AM, Fernando Pelliccioni
<fpelliccioni at gmail.com> wrote:
> I think that the idea is to have a utility that makes the code
> portable. Like the boost philosophy.

Boost is not a good example of good.

The problem with coming up for an indirection layer is that you have
to maintain it.  If it's someone else's you have to rely on them to
maintain it.  And by abstracting away the differences of each
platform, you tend to eliminate the unique advantages of each at the
same time.

I don't mind using tools as an 'offline' assistant to help maintain
and translate code, but I'd like to see the GCC inline assebler remain
GCC assembler, and the MSVC assembler remain MSVC assembler.  Rather
than some monster that no hacker versed in either system will
recognize or be comfortable with.  For one thing, all these macros
will make using a debugger... annoying... to say the least.  These are
not large chunks of code and shouldn't change often.

>
> int val1, val2;
>
> GNU Assembler:
>    asm
>    (
>        "movl %%eax, %0;"
>        "movl %%ebx, %1;"
>
>         : "=r" ( val1 ), "=r" ( val2 )
>    );
>
> MASM:
>   __asm
>    {
>         movl val1, eax
>         movl val2, ebx
>     };
>
>
> En Preprocessor code:
>
>    asm_open
>            asm_op_2(movl , asm_c_var(val1), eax);
>            asm_op_2(movl , asm_c_var(val2), ebx);
>            asm_outputs
>            bind_asm_reg(val1, "=r")
>            bind_asm_reg(val2, "=r")
>            asm_inputs
>            asm_clobbers
>    asm_close
>
>
> I don't known how to count the 'asm_c_var' entries to convert to '%0',
> '%1', ... '%n' ...
>
> Regards,
> Fernando Pelliccioni.
>
> On Thu, Oct 2, 2008 at 11:14 AM, Chris Brien <chris.brien at tandberg.com> wrote:
>> Fernando Pelliccioni wrote:
>>>
>>> Hello,
>>>
>>> I write to you for the announcement in this blog:
>>> http://blog.hartwork.org/?p=86.
>>>
>>> I am interested in the open-source solution proposed in this article
>>> (the preprocessor-macros solution).
>>
>> I would suggest using a compiler which understands GCC-style assembly syntax
>> such as Intel's ICC, rather than making the effort to rewrite. Since this is
>> for MSVC users, the fact that it is non-free is moot.
>>
>> Otherwise, it is relatively straightforward to write macros which expand to
>> MSVC or GCC style syntax, such as
>>
>> #ifdef GCC
>> #define asm_op_3(instruction, a, b, c) instruction %a,%b,%c
>> #else
>> #define asm_op_3(instruction, a, b, c) instruction c,b,a
>> #endif
>>
>> The major difference being the order of operands is exactly reversed, which
>> is easy to deal with using a macro. The only other thing to worry about is
>> how to specify C variables from assembly. GCC uses complicated constraints
>> whereas MSVC can refer to variables directly.
>>
>> #ifdef GCC
>> #define asm_c_var(x) %x
>> #define bind_asm_c_var(name, constraint) (name) constraint (name)
>> #else
>> #define asm_c_var(x) x
>> #define bind_asm_c_var(name, constraint)
>> #endif
>>
>> So you can then write
>> asm
>> {
>>        asm_op_2(movd, asm_c_var(foo), xmm1);
>>        asm_op_3(pushfd, 0xd, xmm1, xmm2);
>>        asm_inputs
>>        bind_asm_reg(foo, "m,r")
>>        asm_outputs
>>        asm_clobbers
>> };
>>
>> Etcetera.
>>
>> Chris
>>
> _______________________________________________
> theora-dev mailing list
> theora-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/theora-dev
>


More information about the theora-dev mailing list