KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q69011: Bad Conditional Jump Generated in Inline Assembly

Article: Q69011
Product(s): See article
Version(s): 6.00 6.00a | 6.00 6.00a
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | buglist6.00 buglist6.00a | mspl13_c
Last Modified: 6-FEB-1991

Under the following conditions, C 6.00 and C 6.00a will generate bad
code for conditional jumps in inline assembly blocks. If, prior to the
conditional jump, an align or even directive is used that causes NOP
instructions to be inserted into the code, the conditional jump
address will be off by the number of NOPs inserted into the code. This
will happen only when using the /Od switch for disabling optimizations
on the compile. Optimizations should not have an affect similar to
this on inline assembly.

Using /Os, /Ot, or /Ox will resolve the problem. Removing any align or
even directives will also eliminate the source of the problem.
Finally, using the /qc option will also generate correct code;
however, the /qc option does not generate the NOP instructions for the
align and even directives as it should.

Microsoft has confirmed this to be a problem in C version 6.00 and
6.00a. We are researching this problem and will post new information
here as it becomes available.

Sample Code
-----------

void main (void)
{
   _asm
   {
      even
      push  ds
      even
      jb    foo
foo:  pop   ds
   }
}

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 1986-2002.