[theora-dev] "Xiph needs someone to help with assembly for MSVC!"
chris.brien at tandberg.com
Thu Oct 2 07:14:37 PDT 2008
Fernando Pelliccioni wrote:
> I write to you for the announcement in this blog:
> 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
#define asm_op_3(instruction, a, b, c) instruction %a,%b,%c
#define asm_op_3(instruction, a, b, c) instruction c,b,a
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.
#define asm_c_var(x) %x
#define bind_asm_c_var(name, constraint) (name) constraint (name)
#define asm_c_var(x) x
#define bind_asm_c_var(name, constraint)
So you can then write
asm_op_2(movd, asm_c_var(foo), xmm1);
asm_op_3(pushfd, 0xd, xmm1, xmm2);
More information about the theora-dev