DOCUMENT:Q78862 04-MAY-2001 [masm] TITLE :FIX: Incorrect Code Generated If Operand Is [eax][eax] PRODUCT :Microsoft Macro Assembler PROD/VER::6.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Macro Assembler (MASM), version 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== In the Microsoft Macro Assembler (MASM) version 6.0, incorrect code is generated for instructions, such as the following, using the operand [eax][eax]: lea edi, [eax][eax] mov edi, [eax][eax] RESOLUTION ========== A workaround for this problem is to embed the opcode for the instruction directly in the code. The sample code below demonstrates this method. STATUS ====== Microsoft has confirmed this to be a problem in MASM version 6.0. This problem was corrected in MASM version 6.0a. MORE INFORMATION ================ A listing file from the following program will show that the instruction lea edi, [eax][eax] is encoded as 8D 3C 3A. However, the code actually placed into the executable is 8D 3C. The correct code in the case of lea edi, [eax][eax] is 8D 3C 00. Note that the operand [eax][eax] is available only when using the .386 or .486 directives. Sample Code ----------- ; Assembler options needed: none .386 .MODEL small CODE32 SEGMENT DWORD PUBLIC USE32 'CODE' ASSUME CS:CODE32 main PROC lea edi, [eax][eax] ; Replace this by BYTE 8Dh, 3Ch, 00h ; since the code generated by it is ; 8D 3C 3A, which is incorrect. mov edi, [eax][eax] ; Replace this by BYTE 8Bh, 3Ch, 00h ; since the code generated by it is ; 8B 3C 3A, which is incorrect. ret main ENDP CODE32 ENDS END main Additional query words: 6.00 buglist6.00 fixlist6.00a ====================================================================== Keywords : Technology : kbMASMsearch kbAudDeveloper kbMASM600 Version : :6.0 Solution Type : kbfix ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.