[alt.msdos.programmer] assembler problem

cornish@ecr.mu.oz.au (Simon Cornish.) (09/25/90)

Hi, I have a problem with MASM v3.00 that a friend lent me
The following is an excerpt from the listing output..
(I'm new to 8088 assembly, so if I'm doing something silly, just tell me)


 
 Addr  Machine Code                       Instruction
 
 004E  A2 0381 R	 	         MOV   W_FLAG,AL
 0051  FF 26 0382 R	 	         JMP   [WAITING]
 	 	 	 	 
 	 	 	 	MNLOOP:
 E r r o r   ---	6:Phase error between passes    
 004F  AC	 	 	        LODSB         
 0050  3C 1F	 	 	         CMP   AL,CTRL

I can see that the indirect jump should be a four byte instr,
 but the LODSB Is placed at 4F.   WHY DOES IT DO THIS?????

Thanx in advance for your help


       .simon.

    " Fasten your seatbelts, we're in for a funky evening. "
                                             -- All about Eve.
     cornish@ecr.mu.oz.au  or   cornish@gondwana.UUCP

shurr@cbnews.att.com (Larry A. Shurr) (09/26/90)

In article <5622@munnari.oz.au>, cornish@ecr.mu.oz.au (Simon Cornish.) writes:
> (I'm new to 8088 assembly, so if I'm doing something silly, just tell me)

>  004E  A2 0381 R	 	         MOV   W_FLAG,AL
>  0051  FF 26 0382 R	 	         JMP   [WAITING]

>  	 	 	 	MNLOOP:
>  E r r o r   ---	6:Phase error between passes    
>  004F  AC	 	 	        LODSB         
>  0050  3C 1F	 	 	         CMP   AL,CTRL

> I can see that the indirect jump should be a four byte instr,
>  but the LODSB Is placed at 4F.   WHY DOES IT DO THIS?????

Hmmm.... Is [WAITING] a forward reference (i.e., not defined until later in
the program)?  Is it defined in your data segment (or in your DGROUP if you
aren an intermediate-level or higher experienced 8086 programmer)?  Is your
ASSUME DS:etc.. statement correct?

If WAITING is a forward reference symbol which is not defined in your DGROUP,
MASM will not know it needs a segment override until the second pass and will
not have allocated the extra byte for it.  This a phase error - in general,
phase error between passes means that MASM learned something between the 1st
and 2nd passes which causes the address allocations for each instruction to
change.  Frequently, but not exclusively, this means it learned of the need 
for a segment override prefix in an instruction with a forward reference.
If the problem is not with WAITING, what about W_FLAG?  If not W_FLAG, the
problem may have occurred earlier in the program - MASM has an annoying habit
of postponing the "Phase error" message until it encounters a line with a 
symbol definition.

Good luck, Larry
-- 
Larry A. Shurr (cbnmva!las@att.ATT.COM or att!cbnmva!las)
The end of the world has been delayed due to a shortage of trumpet players.
(The above reflects my opinions, not those of AGS or AT&T, but you knew that.)