Q43810: C: PUSH CS Caused by Far Call Translation
Article: Q43810
Product(s): See article
Version(s): 5.00 5.10 | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 22-MAY-1989
Question:
When I look at an assembly listing generated by the Microsoft C
Version 5.10 Optimizing Compiler, I notice that the compiler produced
PUSH CS instructions. Should the compiler be generating PUSH CS
instructions?
Response:
One of the optimizations made by the Microsoft C 5.10 compiler is Far
Call Translation. Far Call Translation optimization results in
slightly faster code and smaller executable files.
The compiler normally generates far calls and corresponding far
returns for large and medium-memory-model programs. Far Call
Translation is performed if optimizations are enabled and a call is
being made from one function to another in the same source file. The
usual CALL FAR LABEL is replaced with the following instruction
sequence:
PUSH CS
CALL NEAR LABEL
The called function is in the same code segment because it is located
in the same source file, so a near call is possible in this case. The
PUSH CS instruction allows the far return from the called function to
retrieve CS from the stack and return to the correct location.
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.