KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q46380: -P1 One-Pass Assembly Can Result in A2006 Phase Error

Article: Q46380
Product(s): See article
Version(s): 2.01
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist2.01 | mspl13_masm
Last Modified: 26-JUL-1989

A phase error message is generated by the QuickAssembler Version 2.01
if the -P1 one pass assembly option is chosen and the following
scenario is fulfilled:

1. On any binary arithmetic instruction (AND, ADD, OR, CMP, SUB, XOR,
   SBB, ADC) where the first operand contains a forward reference to a
   WORD data label

2. The second operand is a nonforward referenced symbolic immediate
   whose value could be represented in a sign-extended byte (i.e.,
   007fh, 0ff84h, -1, 12, but not 0081h since it sign-extends to
   0ff81h)

Any of the following actions will resolve this error:

1. Use -P2.

2. Define the data label before the point of reference.

3. Use a BYTE PTR type cast operation on the immediate symbol (i.e.,
   "cmp foo, byte ptr bar").

Microsoft has confirmed this to be a problem in QuickAssembler Version
2.01. We are researching this problem and will post new information as
it becomes available.

The following example will reproduce this problem:

TRUE            equ     1               ; Boolean True value
CSEG    SEGMENT PARA PUBLIC 'CODE'
        ASSUME  CS:CSEG,DS:CSEG,SS:CSEG ; Already set by DOS loader (COM File
        ASSUME  CS:CSEG,SS:CSEG         ; Already set by DOS loader (COM File

        org     100h
entry:                                  ; Program entry point
queueScreen proc near                   ; Procedure declaration
        cmp     cs:screenQueued,TRUE    ; screenQueued is forward referenced.
        ret
queueScreen endp

screenQueued    dw      0

CSEG    ENDS
        END     entry

to resolve the phase error in this specific example, do one of the
following:

1. Select -P2, the two-pass assembly option.

2. Change the following line

      cmp     cs:screenQueued, TRUE

   to the following:

      cmp     cs:screenQueued, byte ptr TRUE

3. Move the definition of screenQueued so that it is defined prior to
   the compare instruction, for example:

                screenQueued    dw      0
                .
                .
                .
                cmp     cs:screenQueued, TRUE

Any of these solutions will work around this phase error problem in
this specific example. These solutions prevent many phase errors from
occurring when assembling similar kinds of data references with either
QuickAssembler or MASM since the source of phase errors is usually due
to the assembler making an incorrect assumption about the type of a
variable that is referred to before it is defined.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.