FIX: Bad Code Generated for Inline Assembly Using EnumeratorsLast reviewed: September 19, 1997Article ID: Q149696 |
4.10
WINDOWS NT
kbprg kbbuglist kbfixlist
The information in this article applies to:
SYMPTOMSWhen 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. } } STATUSMicrosoft 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 INFORMATIONThis 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 reference words: 4.10 10.10 4.20 10.20 vcbuglist410 vcfixlist420
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |