INF: PUSH CS Caused by Far Call Translation

ID Number: Q43810

5.00 5.10 6.00 6.00a 6.00ax | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

One of the optimizations made by the Microsoft C versions 5.1, 6.0,

6.0a, and 6.0ax 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.

Additional reference words: 5.10 6.00 6.00a 6.00ax