The MASM Forum

General => The Campus => Topic started by: FORTRANS on October 01, 2022, 09:49:54 PM

Title: MASM Phase Error
Post by: FORTRANS on October 01, 2022, 09:49:54 PM
Hi,

   When MASM generates a phase error, is there a switch or directive
to change its behavior?  Just looking for an easy out.  I have solved
similar problems before.  Lazy maybe.

Regards,

Steve N.
Title: Re: MASM Phase Error
Post by: jj2007 on October 01, 2022, 09:57:42 PM
What is a phase error? Do you have an example?
Title: Re: MASM Phase Error
Post by: FORTRANS on October 01, 2022, 11:03:43 PM
Hi Jochen.

   Well that obviates the hope for a lazy solution.  ;)
MASM is a two pass assembler.  A phase error occurs when
MASM makes an assumption about code size in the first
pass that was too small.  In the second pass labels are
at a different location than in the first pass,  And
therefor erroneous.  This is normally caused by forward
references being undefined in the first pass.  And the
item referenced not being the default (expected) type.

   An example shows this.


First pass listing.

0142  8B 36 0000 U         MOV     ESI,Brett
sudoc.ASM(182): error A2009: Symbol not defined: BRETT

Second pass listing.
     176 0142  66| 8B 36 0499 R         MOV     ESI,Brett
     177 ;!      move.l  #81,r2
     178 ;?
     179 0147  66| B9 00000051         MOV     ECX,51H
     180 ENDIF
     181 ;! _50: move.l  (r5),r0
     182 LOOP_50a:                                       ;  xref 44EF:01A8
sudoc.ASM(188): error A2006: Phase error between passes


Regards,

Steve
Title: Re: MASM Phase Error
Post by: zedd151 on October 01, 2022, 11:24:50 PM
Quote from: FORTRANS on October 01, 2022, 11:03:43 PM

Second pass listing.
     176 0142  66| 8B 36 0499 R              MOV     ESI,Brett
     177            ;!      move.l  #81,r2
     178            ;?
     179 0147  66| B9 00000051              MOV     ECX,51H

Hmmm. That looks suspiciously familiar. Have you gone and dusted the cobwebs off of some old stuff, eh? Glad to see that I have rekindled your interest.   :biggrin:
Title: Re: MASM Phase Error
Post by: jj2007 on October 01, 2022, 11:27:18 PM
Could you declare the object, like myalgo Proto? Or externdef Brett:dword?
Title: Re: MASM Phase Error
Post by: HSE on October 01, 2022, 11:58:40 PM
Hi Steve

Why you can't to move Brett definition?

HSE
Title: Re: MASM Phase Error
Post by: FORTRANS on October 02, 2022, 04:15:10 AM
Hi,

@zedd151

   Yep, cobwebs off old code.

@jj2007

   Apparently not.  The version I am using is far too old for those.
There should be something else, but so far, no go.

@HSE

   Yes, that is what I will most likely end up doing.  For esthetic reasons,
I was hoping to avoid that.  And of course, find out how to use unfamiliar
MASM constructs.

Cheers,

Steve N.
Title: Re: MASM Phase Error
Post by: zedd151 on October 02, 2022, 04:19:42 AM
Quote from: FORTRANS on October 02, 2022, 04:15:10 AM
@zedd151

   Yep, cobwebs off old code.
:biggrin:
Can't wait to see the results...
Seems what you have is close to how far I had gotten. So, at least I know I was on the right track...sort of.
But I had to put it on the back burner to get on with other things.
Title: Re: MASM Phase Error
Post by: FORTRANS on October 03, 2022, 03:53:11 AM
Hi,

   There are at least three ways around the problem.

   One; move the data to be before the reference to the data.
This is probably the best solution.

   Two; insert a NOP before the MOV instruction and place an EVEN
directive after it.  This works, but is a bad solution if one wants to
further  edit the file.

   Three; MOV ESI, DWORD PTR Brett seems to work.  (Hunh.)

Cheers,

Steve N.
Title: Re: MASM Phase Error
Post by: zedd151 on October 03, 2022, 07:59:39 AM
Quote from: FORTRANS on October 03, 2022, 03:53:11 AM
Hi,

   There are at least three ways around the problem.

Cheers,

Steve N.
I may reinvestigate this sometime soon, before I forget that is on the back burner.  :biggrin:
Title: Re: MASM Phase Error
Post by: FORTRANS on October 12, 2022, 07:59:55 AM
Hi,

   Well the DWORD PTR got rid of the error message, but it does
not generate the wanted code.  Back to the drawing board.

Regards,

Steve
Title: Re: MASM Phase Error
Post by: zedd151 on October 12, 2022, 08:34:56 AM
Quote from: FORTRANS on October 12, 2022, 07:59:55 AM
Hi,
... Back to the drawing board ...
Well shoot, Steve. Sorry to hear that, you were getting soooo close.