www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 840] New: incorrect code generation for asm{fidv ST(1), ST;}

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=840

           Summary: incorrect code generation for asm{fidv ST(1), ST;}
           Product: D
           Version: 1.00
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn






output:
dc f9                   fdivr  st(1),st

expected output:
dc f1                   fdiv   st(1),st

test case:
http://dstress.kuehne.cn/run/a/asm_fdiv_01_D.d


-- 
Jan 13 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=840






other test cases with similar issues are:

http://dstress.kuehne.cn/run/a/asm_fdivp_01_A.d
http://dstress.kuehne.cn/run/a/asm_fdivp_01_B.d
http://dstress.kuehne.cn/run/a/asm_fdivr_01_D.d
http://dstress.kuehne.cn/run/a/asm_fdivrp_01_A.d
http://dstress.kuehne.cn/run/a/asm_fdivrp_01_B.d
http://dstress.kuehne.cn/run/a/asm_fsubp_01_A.d
http://dstress.kuehne.cn/run/a/asm_fsubp_01_B.d
http://dstress.kuehne.cn/run/a/asm_fsubrp_01_A.d
http://dstress.kuehne.cn/run/a/asm_fsubrp_01_B.d


-- 
Jan 13 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=840


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





Actually, DMD is correct. Here's the output from the old DOS DEBUG.
-u 0100 0102
13A9:0100 DCF9                  FDIV    ST(1),ST
13A9:0102 DCF1                  FDIVR   ST(1),ST

The bug is in majority of *nix assemblers. Here's a link.
===========

http://gcc.gnu.org/ml/gcc-bugs/2003-04/msg01454.html
-----
   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.
----------


-- 
Apr 08 2009