PRB: CRT0DAT.ASM Requires Changes for Far Stack to Work in DOS

ID Number: Q71976

6.00 6.00a 6.00ax

MS-DOS

buglist6.00 buglist6.00a buglist6.00ax

Summary:

SYMPTOMS

By following the instructions in the Microsoft C version 6.0

STARTUP.DOC file, you can recompile/reassemble the C startup code

and modify existing libraries so that the stack will be moved out

of DGROUP for programs linked with these modified libraries. When

using the MS-DOS version of these modified libraries, stdout and

stderr unexpectedly appear to be buffered. Also, in programs that

use floating-point math, the program may generate the following

run-time error message:

run-time error R6002

-floating point support not loaded

In other cases, the program may hang. The two sample programs below

and their corresponding sample output illustrate these problems.

RESOLUTION

The OS/2 versions of the modified libraries perform as expected;

however, to achieve the correct behavior with the MS-DOS versions

of the modified libraries, you must modify the following lines,

which are located around line 340, of the file CRT0DAT.ASM:

callos ; set divide error interrupt

push ss

pop ds

assumes ds,data

The code for these lines should be changed to the following:

callos ; set divide error interrupt

ifdef FARSTACK

mov ax, DGROUP

mov ds, ax

else

push ss

pop ds

endif

assumes ds,data

When using a far stack, the SS register will not contain the

segment of DGROUP that it would contain with a default stack. The

code in CRT0DAT.ASM on line 340 incorrectly assumes that the SS

register does contain the DGROUP segment value. In other locations

in CRT0DAT.ASM where DS needs to be reset to DGROUP, the code is

conditionally assembled depending on whether FARSTACK is defined or

not.

STATUS

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

6.0a, and 6.0ax. We are researching this problem and will post new

information here as it becomes available.

More Information:

Sample Code 1

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

/* Compile options needed: /c /ALw /Zi /Od

Link options needed: /CO /NOD (plus you must specify the

modified MS-DOS C run-time library)

*/

#include <stdio.h>

int number;

void main(void)

{

printf("\nEnter a number: ");

scanf("%d", &number);

printf("\nThe number is %1d\n", number);

}

Sample 1 Output

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

22 /* User enters a number (without prompt) */

Enter a number: /* printf() output is buffered, so output does */

The number is 22 /* Not appear until exit code flushes buffers */

Sample Code 2

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

/* Compile options needed: /c /ALw /Zi /Od

Link options needed: /CO /NOD (plus you must specify the

modified MS-DOS C run-time library)

*/

#include <stdio.h>

float number;

void main( )

{

number = 2.3456;

printf( "The number is %f\n", number);

}

Sample 2 Output

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

run-time error R6002

-floating point support not loaded

Additional reference words: 6.00 6.00a 6.00ax