News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

MASM Phase Error

Started by FORTRANS, October 01, 2022, 09:49:54 PM

Previous topic - Next topic

FORTRANS

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.

jj2007

What is a phase error? Do you have an example?

FORTRANS

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

zedd151

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:

jj2007

Could you declare the object, like myalgo Proto? Or externdef Brett:dword?

HSE

Hi Steve

Why you can't to move Brett definition?

HSE
Equations in Assembly: SmplMath

FORTRANS

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.

zedd151

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.

FORTRANS

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.

zedd151

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:

FORTRANS

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

zedd151

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.