FIX: Inline Assembly Instruction Removed With /O1

ID: Q114078

1.00 WINDOWS kbtool kbfixlist kbbuglist

The information in this article applies to:

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          : kb16bitonly kbCompiler kbbuglist kbfixlist
Version           : 1.00
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: September 22, 1997