Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #285 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

inline asm generates code different from dmd

Reported by: ChristianK Assigned to: lindquist
Priority: major Milestone:
Component: backend Version: hg tip
Keywords: Cc:

Description

The asm syntax used is the one generated by objdump -d.

  • fmul
    • dmd: fmulp %st, %st(1)
    • ldc: fmul %st(1), %st
  • fadd
    • dmd: faddp $st, $st(1)
    • ldc: fadd $st(1), $st
  • fstsw AX
    • dmd: fnstsw %ax
    • ldc: fstsw %ax
  • fmul ST(0), ST
    • dmd: fmul %st, %st(0)
    • ldc: fmul %st(0), %st

Change History

05/05/09 17:58:24 changed by Don Clugston

I don't know why DMD accepts "fmul". It should be illegal, I reckon. But anyway, the old DOS program "debug" seems to be the ultimate test of Intel asm syntax. And for "fmul", it creates fmulp:

-a
13AC:0100 fmul
13AC:0102
-u
13AC:0100 DEC9                  FMULP   ST(1),ST
The same is true for fadd: it creates faddp.

fstsw AX

There's actually no such instruction, that's actually fwait; fnstsw AX; Encoding should be: 9B DF E0. Which is not what DMD's doing -- LDC is correct, and DMD has a bug.

fmul ST(0), ST and fmul ST, ST(0).

These two are equivalent (since ST(0) is ST!), but have different encodings. A better test is fmul ST(1), ST, which should be DC C9, whereas fmul ST, ST(1) is D8 C9.

05/06/09 16:12:57 changed by ChristianK

Thanks for the hints. The mentioned issues have been fixed by [1304]. Only the IEEE and GammaFunction? unittests fail now. This could be the issue:

int y;
asm { fistp y, ST(0); }

gets translated to fistp (DF) instead of fistpl (DB).

05/13/09 14:53:18 changed by ChristianK

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [1314], [1320].

Copyright © 2008, LDC Development Team.