D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2941 - Wrong code for inline asm because CPU type is set too late
Summary: Wrong code for inline asm because CPU type is set too late
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2009-05-05 17:23 UTC by Don
Modified: 2014-02-15 13:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2009-05-05 17:23:36 UTC
fstsw AX;
should be producing fwait; fnstsw AX;  (9B DF E0).

Instead, it simply produces fnstsw AX; (DF E0).
Comment 1 Don 2009-05-06 02:23:44 UTC
I've found the cause: iasm.c, line 1650-1651 is:
	else if ((ptb.pptb0->usFlags & _fwait) &&
	    config.target_cpu >= TARGET_80386) {

Turns out that at this point, config.target_cpu is uninitialized! It's 0!
It doesn't get initialized until much later. (In obj_start() in glue.c).
I suspect that there should be a call to out_config_init() (in msc.c) at a very much earlier point, possibly even in mars.c.

As this could be causing all sorts of problems elsewhere, I'm raising the severity.