FIX: Forward Reference to Segment Name Gives Phase Error (32762)



The information in this article applies to:

  • Microsoft Macro Assembler (MASM) 5.1
  • Microsoft Macro Assembler (MASM) 5.1a

This article was previously published under Q32762

SYMPTOMS

A forward reference to a segment name in the Microsoft Macro Assembler (MASM) versions 5.0, 5.1, and 5.1a will incorrectly cause the following error to occur
error A2006: phase error between passes

RESOLUTION

A workaround is to declare empty segments at the top of your MASM source code, defining all segments in the order needed.

STATUS

Microsoft has confirmed this to be a problem in MASM versions 5.1 and 5.1a. This problem was corrected in MASM version 6.0.

MORE INFORMATION

The following source example demonstrates the problem. As a work around, place the following code fragment at the top of the source file.
      CSEG segment para public 'CODE'
      CSEG ends
      SSEG segment stack 'STACK'
      SSEG ends
				
Because the sseg segment is declared before the MOV instruction references it, the phase error is eliminated. The cseg segment is also declared to ensure that the ordering of the two segments is unchanged.

Note that this problem does not occur with MASM 6.0 or later since phase errors are only generated by two pass assemblers and MASM 6.0 and later are N-pass assemblers.

Sample Code:

;Assemble options needed: none

cseg SEGMENT para public 'CODE'
     assume cs:cseg

main PROC near
     MOV bx, seg sseg               ;will generate phase error
     RET
main ENDP

cseg ENDS

sseg SEGMENT stack 'STACK'
     db 100h dup(?)
sseg ENDS

END main
				

Modification Type:MajorLast Reviewed:10/22/2003
Keywords:kbfix KB32762