FIX: Optimization Removes SS Override from Inline Assembly

ID: Q115536

1.00 WINDOWS kbtool kbfixlist kbbuglist

The information in this article applies to:

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:

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

Last Reviewed: September 22, 1997