C9112003: L1103 Caused By Coprocessor Instruction f2xm1

ID Number: Q78864

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax fixlist7.00

Summary:

PROBLEM ID: C9112003

SYMPTOMS

Code that includes the coprocessor instruction f2xm1 and is

compiled with either the medium (/AM), large (/AL), or huge (/AH)

memory model with C version 6.0, 6.0a, or 6.0ax will cause the

following error at link time:

fatal error L1103: attempt to access data outside segment bounds

RESOLUTION

Use one of the following workarounds:

- Compile with the small (/AS) or compact (/AC) memory model.

-or-

- Compile with /qc.

-or-

- Use _asm _emit to generate the appropriate opcode for _asm f2xm1,

depending on the math type:

Coprocessor (/FPi87) Example Emulator (/FPi) Example

---------------------------- -----------------------

_asm { _asm {

_emit 0x9B _emit 0xcd

_emit 0xD9 _emit 0x35

_emit 0xF0 _emit 0xf0

} }

See the sample below for a complete example using these fragments.

STATUS

Microsoft has confirmed this to be a problem in C versions 6.0,

6.0a, and 6.0ax. This problem was corrected in C version 7.0.

More Information:

Sample Code 1

-------------

/* The following code will demonstrate the error. A complete example of

the third workaround (above) for emulator math follows. */

/* Compile options needed: /AM or /AL or /AH

*/

#include <stdio.h>

float x = 0.25;

float y = 0.0;

void main()

{

_asm fld x

_asm f2xm1

_asm fst y

printf( "2 raised to %f minus 1 = %f\n", x, y );

}

Sample Code 2

-------------

// Workaround (emulator version):

#include <stdio.h>

float x = 0.25;

float y = 0.0;

void main( )

{

_asm fld x

_asm {

_emit 0xcd

_emit 0x35

_emit 0xf0

}

_asm fst y

printf( "2 raised to %f minus 1 = %f\n", x, y );

}

Additional reference words: 6.00 6.00a 6.00ax