inline assembly, C++
I have some C++ code and it contains inline assembly.
It uses the __asm keyword that is VC++ specific.
gcc doess't like it. How to compile this thing?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Thanks, you are the best.
I hwas searching for gcc+assembly and gcc+sse and it was giving topics I was not interested in.
I hwas searching for gcc+assembly and gcc+sse and it was giving topics I was not interested in.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
For SSE, you might want to look into using compiler intrinsics instead of inline asm
The code has been written a long time ago and also there is IA32 code.
gcc seems to have a different format for the inline assmebly
asm ("mov eax, 0;
mov ecx, 1;
call _foo"
: /* no outputs */
: "g" (from), "g" (to)
: "eax", "ecx"
);
while in VC++ it's
__asm
{
mov eax, 0
mov ecx, 1
call _foo
}
There is some other formats in gcc but they all require a lot of change that is best for a automation tool. Anyone have one handy?
gcc seems to have a different format for the inline assmebly
asm ("mov eax, 0;
mov ecx, 1;
call _foo"
: /* no outputs */
: "g" (from), "g" (to)
: "eax", "ecx"
);
while in VC++ it's
__asm
{
mov eax, 0
mov ecx, 1
call _foo
}
There is some other formats in gcc but they all require a lot of change that is best for a automation tool. Anyone have one handy?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
I tried to compile this but it keeps given a error message.
It gives the same error message for the mov instruction : "too many memory references"
/////// I typed this to compile
linux:/MyDocuments # gcc -fPIC -fomit-frame-pointer -g -c asm.cpp
/tmp/cckuMs2Z.s: Assembler messages:
/tmp/cckuMs2Z.s:32: Error: too many memory references for `xor'
//////CODE
int main()
{
__asm__ __volatile__
(
//"mov eax,eax"
"xor eax, eax"
: //No output registers
: //No input registers
: "eax", "ecx", "edx" //Clobber list
);
//".byte 0x0f; .byte 0x31" return 1;
}
It gives the same error message for the mov instruction : "too many memory references"
/////// I typed this to compile
linux:/MyDocuments # gcc -fPIC -fomit-frame-pointer -g -c asm.cpp
/tmp/cckuMs2Z.s: Assembler messages:
/tmp/cckuMs2Z.s:32: Error: too many memory references for `xor'
//////CODE
int main()
{
__asm__ __volatile__
(
//"mov eax,eax"
"xor eax, eax"
: //No output registers
: //No input registers
: "eax", "ecx", "edx" //Clobber list
);
//".byte 0x0f; .byte 0x31" return 1;
}
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Try looking at this. It's for DJGPP, but the information applies to any GCC.
For your current problem, you need to prefix the register names with '%', or they will instead be considered to be memory accesses.
For your current problem, you need to prefix the register names with '%', or they will instead be considered to be memory accesses.
I think I tried that one. It didn't work.
Also, I consulted that page. It says the % is for the AT&T syntax.
I use Intel.
Also, I consulted that page. It says the % is for the AT&T syntax.
I use Intel.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
October 04, 2006 05:48 AM
int main()
{
__asm__ __volatile__
(
//"mov eax,eax"
"xor %%eax, %%eax"
: //No output registers
: //No input registers
: "eax", "ecx", "edx" //Clobber list
);
//".byte 0x0f; .byte 0x31" return 1;
}
should work, note double %
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement