D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2942 - asm fadd; accepted, but generates code for faddp.
Summary: asm fadd; accepted, but generates code for faddp.
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 minor
Assignee: Walter Bright
URL:
Keywords: accepts-invalid, patch, wrong-code
Depends on:
Blocks:
 
Reported: 2009-05-05 17:32 UTC by Don
Modified: 2014-02-15 13:13 UTC (History)
0 users

See Also:


Attachments
Patch against DMD 2.029 (1.53 KB, patch)
2009-05-06 03:55 UTC, Don
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2009-05-05 17:32:37 UTC
Discovered in LDC/DMD consistency comparisons.
asm {
  fadd;
  fmul;
  fsub;
  fdiv;
  fsubr;
  fdivr;
}
is accepted, but I don't think it should be. The AMD and Intel manuals don't mention it, they only have 
asm {
  faddp;
  fmulp;
  fsubp;
  fdivp;
  fsubrp;
  fdivrp;
}
DMD's behaviour _is_ what DOS "debug" does, but it's error prone and confusing -- why isn't fadd; the same as fadd ST, ST(1); How the heck did it become faddp ST(1), ST;???
The bare forms without 'p' and with no arguments should simply be made illegal.
Comment 1 Don 2009-05-06 03:55:03 UTC
Created attachment 352 [details]
Patch against DMD 2.029

This simple patch comments out the problematic instructions.
Comment 2 Don 2009-05-08 14:48:47 UTC
It gets worse. DMD also copies some hideous DEBUG bugs. This garbage compiles:

void main() {
 double x;
  asm {
  fld x, ST(6);
 }
}

Even though there's no such instruction, you can't load into ST(6).
This wasn't included in my patch.
Comment 3 Walter Bright 2009-09-30 23:03:03 UTC
These pseudo-ops *are* documented in older Intel manuals, like the 387 DX User's Manual. I'm reluctant to change it. The last issue should be in a separate report.
Comment 4 Don 2009-10-01 00:27:56 UTC
(In reply to comment #3)
> These pseudo-ops *are* documented in older Intel manuals, like the 387 DX
> User's Manual. I'm reluctant to change it. The last issue should be in a
> separate report.

Interesting. They aren't present in any manual which is still available. I found a website with material which was copied from the 386 manual (not 387),  but it said that even in 1997, the manual was no longer officially available.
I suspect that a lot of those pseudo-ops were bugs in DEBUG. (DEBUG also accepts fld addr, ST(6);).

However, I just checked MSVC, and it _does_ accept fadd;
(But it doesn't accept the legal faddp; !!)
Pretty useless, and I think they should be abandoned, but no big deal if you want to keep them.