FIX: Optimization Removes SS Override from Inline Assembly

Q115536

1.00 WINDOWS kbtool kbfixlist kbbuglist ---------------------------------------------------------------------- The information in this article applies to: - The Microsoft C/C++ Compiler (CL.EXE), included with: Microsoft Visual C++ for Windows, version 1.0 ---------------------------------------------------------------------- SYMPTOMS ======== If optimizations are used, the version 8.0 C/C++ compiler may remove the use of the stack segment register (SS) override in a pointer reference in an inline assembly block. RESOLUTION ========== To get around this problem, do one of the following: - Disable optimization using the /Od compiler switch. -or- - Use the fast compiler option, /f. -or- - Disable optimization during the function where the problem occurs, using #pragma optimize before and after the function. -or- - In the case of the sample code (in the "MORE INFORMATION" section, below), remove the line of code before the assembly block to allow the compiler to also generate correct code. STATUS ====== Microsoft has confirmed this to be a problem with the C/C++ compiler version 8.0. The problem was corrected in C/C++, version 8.0c, included with Visual C++ for Windows, version 1.5. MORE INFORMATION ================ The sample code below can be used to reproduce the problem. Use the /Fc compiler option to generate a source/assembly listing of the code. Sample Code ----------- /* Compile options needed: /c /Ox (or any optimization) */ unsigned char tbl[256]; static void Bug(unsigned char _far *Font, unsigned char c) { unsigned char _far *font_data = Font + c*33; __asm { push ds mov al, byte ptr ss:[bx] mov bl, es:[di] } } main() { Bug((unsigned char _far *)0, 0); } Additional reference words: 8.00 1.00 KBCategory: kbtool kbfixlist kbbuglist KBSubcategory: CodeGen

Keywords : kb16bitonly kbCodeGen
Issue type :
Technology :


Last Reviewed: September 24, 1997
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.