Microsoft KB Archive/149696

= FIX: Bad Code Generated for Inline Assembly Using Enumerators =

Article ID: 149696

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft Visual C++ 4.1 Subscription

-



This article was previously published under Q149696



SYMPTOMS
When you use an enumerator in an inline assembly statement, incorrect code will be generated for the enumerator value. The following code fragment demonstrates the problem: void main {  enum { FALL=1, WINTER, SPRING, SUMMER };

_asm { mov eax, WINTER ; <--- This will incorrectly load 'eax' ;     with something other than 2. }  }



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 32- bit Edition version 4.2.



MORE INFORMATION
This problem will impact developers that are using the Microsoft Windows 95 Device Driver Kit (DDK) or other tools that are used to build VXD drivers with C/C++. The DDK provides C/C++ header files that use enumerators and inline assembly in this fashion.

There are no workarounds for this problem. The following are possible alternatives if the developer is at liberty to modify the source code: void main {

#define FALL  1 #define WINTER 2 #define SPRING 3 #define SUMMER 4

_asm { mov eax, WINTER }  } The drawback to the #define directive method is that it has no scope. Another method that does have scope is this: void main {

const int FALL  = 1, WINTER = 2, SPRING = 3, SUMMER = 4;

_asm { mov eax, WINTER }  }

Additional query words: InLineAsmIss

Keywords: kbbug kbfix kbvc420fix kbcode KB149696

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.