Dear all,
My question is not exactly aligned with this post, but it is about MinGW
and mostly the IDE using it.
First my goal :) :
* I would like to compile a software source meant to be for GCC under
linux or mac-os (more specifically jamvm a GPL Java VM) in Windows CE.
In other words, port it to Windows CE :)
I found a port of the GCC compiler for Windows CE, but I consider that
compiling in such small device could take a long time :) Then, I have
tried to find a compiler where I could use the GCC port for Windows CE
but compile the code in a regular PC (I hope I am explaining myself fine).
Any hint of how to achieve this?
Best Regards,
Miguel
Thanks a lot for your answer John! Since then I managed to get this
code working but I still have a few questions, for you or others ;-) :
1.- Is there an official help for the clobbered register list and its
use ? I could not find any relevant section in the GCC manual
2.- Is there a place where I could find up to date examples (all
example around the web I could find use registers in both input and
clobbered list, which GCC no longer supports as far as I understand,
and results in the compilation error : can't find a register in class
`CREG' while reloading `asm')
3.- What is the difference in the clobber list between “cc” and “st”?
When do I have to use them ? Only when I modified the flag registers
and intend to read them thereafter or as soon as I use an instruction
which might modify them ?
4.- Is using “cld” or “std” instructions considered modifying the
flags register ?
5.- Is the proposed snippet I wrote below as good as it can be ?
Thanks in advance,
Charles
I have made several versions of my assembly code until I got one
perfectly working. I went through several pitfalls :
- an early clobbered registers is not considered as clobbered
register… This means that though I put an ampersand in front of an
input operant, GCC would use it as if it had not changed thereafter…
- an asm block which provides no output variable is optimized away by
the compiler with the –O2 flag. This happens, even when the “memory”
clobber is used… You have to use the __volatile__ keyword additionally…
Here is the working version :
{
uint32 dummy_ecx;
uint32 dummy_esi;
uint32 dummy_edi;
__asm__ __volatile__
(
"cld\n\t"
"movl %3, %%esi\n\t"
"movl %4, %%edi\n\t"
"movl %5, %%ecx\n\t"
"rep\n\t"
"movsl"
: "=&c"(dummy_ecx), "=&S"(dummy_esi), "=&D"(dummy_edi)
: "g"(from), "g"(where), "g"(times)
: "memory"
);
}
And here is all the snippets I tried :
////First version (no clobber)
//{
// __asm__ __volatile__
// (
// "cld\n\t"
// "rep\n\t"
// "movsl"
// :
// : "S"(from), "D"(where), "c"(times)
// : "memory"
// );
//}
//Version 2 (cant remember what happened on this one)
//{
// std::size_t ecx_dummy;
// std::size_t esi_dummy;
// std::size_t edi_dummy;
// __asm__ __volatile__
// (
// "cld\n\t"
// "rep\n\t"
// "movsl"
// : "=S"(esi_dummy), "=D"(edi_dummy), "=c"(ecx_dummy)
// : "S"(from), "D"(where), "c"(times)
// : "memory"
// );
//}
//Version 3 (early clobber)
//{
// __asm__
// (
// "cld\n\t"
// "movl %0, %%esi\n\t"
// "movl %1, %%edi\n\t"
// "movl %2, %%ecx\n\t"
// "rep\n\t"
// "movsl"
// :
// : "g"(from), "g"(where), "g"(times)
// : "%esi", "%edi", "%ecx", "memory"
// );
//}
//Version 4 (lacking volatile… should never had suppressed it…)
//{
// uint32 dummy_ecx;
// uint32 dummy_esi;
// uint32 dummy_edi;
// __asm__
// (
// "cld\n\t"
// "movl %3, %%esi\n\t"
// "movl %4, %%edi\n\t"
// "movl %5, %%ecx\n\t"
// "rep\n\t"
// "movsl"
// : "=&c"(dummy_ecx), "=&S"(dummy_esi), "=&D"(dummy_edi)
// : "g"(from), "g"(where), "g"(times)
// : "memory"
// );
//}
//Version 5 (does not compile)
//{
// uint32 dummy_ecx;
// uint32 dummy_esi;
// uint32 dummy_edi;
// __asm__ __volatile__
// (
// "cld\n\t"
// "rep\n\t"
// "movsl"
// : "=&c"(dummy_ecx), "=&S"(dummy_esi), "=&D"(dummy_edi)
// : "S"(from), "D"(where), "c"(times)
// : "memory"
// );
//}
--
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°
Miguel González Castaños
Telefónica Investigación y Desarrollo
Parque Tecnológico Walqa
Edificio Uno
Ctra. Zaragoza N-330a Km.556
22197 Cuarte
Huesca
Spain
Tel.: +34 913129876
Fax: +34 974215500
E-mail: mgc@xxxxxx
Internet: http://www.tid.es
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°