Skip to content

Latest commit

 

History

History

Q94408

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
layout title permalink
page
Q94408: FIX: A2138 Error--Structure Member Span-Dependent Equate
/kb/094/Q94408/

Q94408: FIX: A2138 Error--Structure Member Span-Dependent Equate

{% raw %}

Article: Q94408
Product(s): Microsoft Macro Assembler
Version(s): 6.0,6.0a,6.0b,6.1,6.1a
Operating System(s): 
Keyword(s): 
Last Modified: 06-MAY-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Macro Assembler (MASM), versions 6.0, 6.0a, 6.0b, 6.1, 6.1a 
-------------------------------------------------------------------------------

SYMPTOMS
========

The process of assembling an application fails and the assembler generates an
A2138 error message.

CAUSE
=====

A structure member is initialized with an equate value that is computed as the
difference between the addresses of two labels in the code (a span-dependent
value).

RESOLUTION
==========

To work around this problem, code an expression that evaluates to the difference
between the addresses of the two labels. Initialize the structure using the
expression.

STATUS
======

Microsoft has confirmed this to be a problem in MASM versions 6.0, 6.0a, 6.0b,
6.1, and 6.1a. This problem was corrected in MASM for MS-DOS version 6.11.

MORE INFORMATION
================

In the code below, the structure member Member2 is initialized with the
TableSize equate. The value of TableSize is generated by subtracting the value
of label Table1 from value of label Table2. Assembling the following code causes
the A2138 error.

Sample Code
-----------

  ; Assemble options needed: /Fl

  data SEGMENT para public 'DATA'

  Table1 LABEL WORD
      DW 0, 1
  Table2 LABEL WORD

      TableSize EQU Table2-Table1

  InStruc STRUC
      Member1 DW Table2-Table1    ; This works correctly
      Member2 DW TableSize        ; This triggers the error
  InStruc ENDS

  Inside InStruc <>               ; The error is generated here

  OutsideOK DW TableSize          ; Using the equate outside
                                  ; the structure works
  data ENDS

  _text SEGMENT para public 'CODE'
  start:
      mov ax, 4C00h
      int 21h
  _text ENDS
  END start

Additional query words: 6.00 6.00a 6.00b 6.10 6.10a buglist6.00a buglist6.00b buglist6.10 buglist6.10a fixlist6.11

======================================================================
Keywords          :  
Technology        : kbMASMsearch kbAudDeveloper kbMASM600 kbMASM610 kbMASM610a kbMASM600a kbMASM600b
Version           : :6.0,6.0a,6.0b,6.1,6.1a
Solution Type     : kbfix

=============================================================================

{% endraw %}