help with different treatment of asms in 3.2 and 3.3?

Andrew Haley aph@redhat.com
Tue Nov 5 08:30:00 GMT 2002


Brad Lucier writes:
 > 3.2 compiles the following code without complaint (beyond the warnings)
 > and 3.3 rejects it.  The code is from the MLton ML compiler runtime; I
 > know nothing about inline asms; could someone offer some advice?
 > 
 > int Int_quot(int numerator, int denominator) {
 >         register int eax asm("eax");
 > 
 >         eax = numerator ;
 > 
 >         __asm__ __volatile__ ("cdq\n        idivl %1"
 >                 :
 >                 : "r" (eax), "m" (denominator)
 >                 : "eax", "edx");
 > 
 >         return eax;
 > }

Do this:

int Int_quot(int numerator, int denominator) {
  int eax;
  
  __asm__ __volatile__ ("cdq\n        idivl %2"
			: "=a" (eax)
			: "0" (numerator), "rm" (denominator)
			: "edx");
  
  return eax;
}

Andrew.



More information about the Gcc mailing list