[Mono-devel-list] Question regarding ASM in mini-x86.c
J Lothian
rhalin at gmail.com
Sat Feb 12 15:39:41 EST 2005
Ah, much thanks, it compiles, which may not be saying much at this
point, but I can work out bugs later when it all links correctly.
stuck this in the cpu_init, think its going to work, I'm not
-entirely- sure if it's doing the same thing ( I may be way off here)
#ifndef _MSC_VER
__asm__ __volatile__ ("fnstcw %0\n": "=m" (fpcw));
fpcw &= ~X86_FPCW_PRECC_MASK;
fpcw |= X86_FPCW_PREC_DOUBLE;
__asm__ __volatile__ ("fldcw %0\n": : "m" (fpcw));
__asm__ __volatile__ ("fnstcw %0\n": "=m" (fpcw));
#else
_control87( _PC_64, MCW_PC );
#endif
Thanks for the help though!
On Sat, 12 Feb 2005 09:22:00 +0100, Jeroen Frijters <jeroen at sumatra.nl> wrote:
> Hi,
>
> If you don't know x86 then these parts will be quite tricky to convert
> to MSVC, due to the fact that GCC doesn't follow the Intel conventions
> in instruction naming and parameter order.
>
> For the two cases below, you could probably use the compiler intrinsincs
> _control87() and __cpuid() though.
>
> Here's an example of what the part of cpuid you quoted would look like:
>
> int have_cpuid = 0;
> __asm {
> pushfd
> pop eax
> mov edx, eax
> xor eax, 0x200000
> push eax
> popfd
> pushfd
> pop eax
> xor eax, edx
> and eax, 0x200000
> mov have_cpuid, eax
> }
>
> Regards,
> Jeroen
>
> > -----Original Message-----
> > From: mono-devel-list-admin at lists.ximian.com
> > [mailto:mono-devel-list-admin at lists.ximian.com] On Behalf Of J Lothian
> > Sent: Saturday, February 12, 2005 06:35
> > To: mono-devel-list at lists.ximian.com
> > Subject: [Mono-devel-list] Question regarding ASM in mini-x86.c
> >
> > Heyyas,
> >
> > I seem to have hit a minor roadblock in my quest to get an MSVC 6
> > build working, mini-x86 seems to do some interesting things dealing
> > with inline ASM, and this is one of those fields I have nearly zero
> > experience with. Before I go and muck about too much, I thought I'd
> > ask you all opinions on what I can do here.
> >
> > firstly, MSVC doesn't understand __asm__ __volatile__, it has __asm,
> > and a volatile keyword, but I don't believe they can be used together
> > in this manner.
> >
> > Here's the blocks giving me trouble:
> > cpuid (int id, int* p_eax, int* p_ebx, int* p_ecx, int* p_edx)
> > {
> > int have_cpuid = 0;
> > __asm__ __volatile__ (
> > "pushfl\n"
> > "popl %%eax\n"
> > "movl %%eax, %%edx\n"
> > "xorl $0x200000, %%eax\n"
> > "pushl %%eax\n"
> > "popfl\n"
> > "pushfl\n"
> > "popl %%eax\n"
> > "xorl %%edx, %%eax\n"
> > "andl $0x200000, %%eax\n"
> > "movl %%eax, %0"
> > : "=r" (have_cpuid)
> > :
> > : "%eax", "%edx"
> > );
> >
> > and
> >
> > void
> > mono_arch_cpu_init (void)
> > {
> > guint16 fpcw;
> >
> > /* spec compliance requires running with double precision */
> > __asm__ __volatile__ ("fnstcw %0\n": "=m" (fpcw));
> > fpcw &= ~X86_FPCW_PRECC_MASK;
> > fpcw |= X86_FPCW_PREC_DOUBLE;
> > __asm__ __volatile__ ("fldcw %0\n": : "m" (fpcw));
> > __asm__ __volatile__ ("fnstcw %0\n": "=m" (fpcw));
> >
> > }
> >
> > The most I can do with these is replace the __asm__ with __asm and
> > remove the volatile, but I have a feeling it's not going to perform
> > how it's supposed to and that the asm itself probably needs to be
> > alterered. Can anyone help me with this at all? I'll keep digging
> > at it a bit, see if I can figure it out, but this looks like one of
> > those times when I'm really gonna need a bit of a hand. I can add in
> > the relavant #ifdef _MSC_VER's to my build notes and svn diff if I can
> > figure out what to put in there.
> >
> > Thanks for anything you can come up with!
> >
> > -J Lothian
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
>
More information about the Mono-devel-list
mailing list