[Mono-devel-list] Question regarding ASM in mini-x86.c

J Lothian rhalin at gmail.com
Sat Feb 12 00:34:43 EST 2005


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



More information about the Mono-devel-list mailing list