bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong machine code


From: Alan Modra
Subject: Re: Wrong machine code
Date: Wed, 16 Jul 2003 08:54:15 +0930
User-agent: Mutt/1.4i

On Tue, Jul 15, 2003 at 09:14:08AM -0400, Dong Jianxiong wrote:
> Dear GNU community,
>     Recently I found a bug from GNU Assembler. It translates the
> "fsubr %st, %st(1)" into the incorrect machine code. The bug summary is

This extract from include/opcode/i386.h explains the situation.

/* The SystemV/386 SVR3.2 assembler, and probably all AT&T derived
   ix86 Unix assemblers, generate floating point instructions with
   reversed source and destination registers in certain cases.
   Unfortunately, gcc and possibly many other programs use this
   reversed syntax, so we're stuck with it.

   eg. `fsub %st(3),%st' results in st = st - st(3) as expected, but
   `fsub %st,%st(3)' results in st(3) = st - st(3), rather than
   the expected st(3) = st(3) - st

   This happens with all the non-commutative arithmetic floating point
   operations with two register operands, where the source register is
   %st, and destination register is %st(i).  See FloatDR below.

   The affected opcode map is dceX, dcfX, deeX, defX.  */

#ifndef SYSV386_COMPAT
/* Set non-zero for broken, compatible instructions.  Set to zero for
   non-broken opcodes at your peril.  gcc generates SystemV/386
   compatible instructions.  */
#define SYSV386_COMPAT 1
#endif
#ifndef OLDGCC_COMPAT
/* Set non-zero to cater for old (<= 2.8.1) versions of gcc that could
   generate nonsense fsubp, fsubrp, fdivp and fdivrp with operands
   reversed.  */
#define OLDGCC_COMPAT SYSV386_COMPAT
#endif

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]