FIX: Inline Assembly Instruction Removed With /O1

Last reviewed: September 18, 1997
Article ID: Q114078
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, versions 1.0
    

SYMPTOMS

An inline assembly instruction is not executed when the /O1 compiler switch is use with the optimizing compiler.

RESOLUTION

To workaround this problem either remove the /O1 optimization, use the fast compiler, or upgrade to Visual C++ for Windows, version 1.5, which provides version 8.0c of the C/C++ compiler. Use of the fast compiler can be forced by specifying the /f compiler switch.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed above. This problem was corrected in Visual C++ version 1.5.

Sample Code

/* Compile options needed: /c /f- /O1 /Fc
* * The /Fc switch is not necessary to reproduce the problem. However, * it will generate a code listing file which can be used to see the * problem code generated by the compiler.
*/

void (far *fn_ptr)( void );

int TestFunc( void )
{
    unsigned hma_ass;
    unsigned char hma_err;
    unsigned handle;
    unsigned han_err;

    _asm {
      mov   ah, 0x01
      mov   dx, 0xffff
      call  [fn_ptr]
      mov   hma_ass, ax
      mov   hma_err, bl
    }

    _asm {
      mov   ah, 0x09          /* This is removed with -O1  */
      mov   dx, 1             /* and so is this line       */
      call  [fn_ptr]
      mov   handle, dx
      mov   han_err, ax
    }

   return( handle );
}


Additional reference words: 1.00 8.00
KBCategory: kbtool kbfixlist kbbuglist
KBSubcategory: CLIss
Keywords : CLIss kb16bitonly kbbuglist kbfixlist kbtool
Version : 1.00
Platform : WINDOWS
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.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.