Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/38216

From BetaArchive Wiki
Knowledge Base

PRB: Possible Cause of L2002 for Mixed C, MASM in Large Model

Article ID: 38216

Article Last Modified on 10/17/2003


  • Microsoft Macro Assembler 5.0
  • Microsoft Macro Assembler 5.1 Standard Edition
  • Microsoft Macro Assembler 5.1a
  • Microsoft Macro Assembler 6.0 Standard Edition
  • Microsoft Macro Assembler 6.0a
  • Microsoft Macro Assembler 6.0b

This article was previously published under Q38216


If a variable is referenced externally in an assembler routine in the following manner:

   .model large, c


and declared globally in a large model C program as follows:

   int Var;

the following error is generated:

error L2002: fixup overflow


This error occurs because the assembler would expect to find Var in the segment _DATA in DGROUP. The C declaration, however, will put var in the segment FAR_BSS, since it is an uninitialized global data item in the large memory model.

Note that the same is true for the compact memory model.


One way to eliminate this error is to initialize Var in the C code:

   int Var=0;

This will put it in the _DATA logical segment in DGROUP.

Another work-around is to delcare Var in the Assembly code so that the assembler would expect to find Var in FAR_BSS, as follows:

   .model large, c


In addition, be sure to use a segment override to access Var:

   MOV ax, SEG Var
   MOV es, ax
   MOV bx, es:Var

Additional query words: 5.00 5.10 5.10a 6.00 6.00a 6.00b

Keywords: KB38216