Bug 840 – incorrect code generation for asm{fidv ST(1), ST;}

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-01-13T06:14:00Z
Last change time
2014-02-15T13:13:29Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
thomas-dloop

Comments

Comment #0 by thomas-dloop — 2007-01-13T06:14:15Z
# asm{ # fidv ST(1), ST; # } 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
Comment #1 by thomas-dloop — 2007-01-13T06:45:50Z
Comment #2 by clugdbug — 2009-04-08T05:05:24Z
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. ----------