[net.micro.pc] Bug in MASM 3.0 and therefore Lattice 2.15.

hhoeksma@watmath.UUCP (Henry Hoeksma) (08/01/85)

The Lattice 2.15C that I just bought has a library function called
movmem() that doesn't seem to work.  Programs which use it tend to
crash randomly.  (This is for the S-model, but probably applies to
the other models as well.)  I disassembled movmem() and discovered
that it used the instruction REPZ MOVSB, when it should have been
REP MOVSB.  I then wrote my own movmem() with the correct REP prefix,
and to my surprise, when I disassembled the resulting object file
it contained the REPZ prefix!  It seems that MASM 3.0 (from MicroSoft)
generates the wrong opcode for the REP - namely a REPZ.
Assembler and C programmers beware!

slerner@sesame.UUCP (Simcha-Yitzchak Lerner) (08/05/85)

>                             I disassembled movmem() and discovered
> that it used the instruction REPZ MOVSB, when it should have been
> REP MOVSB.  I then wrote my own movmem() with the correct REP prefix,
> and to my surprise, when I disassembled the resulting object file
> it contained the REPZ prefix!  It seems that MASM 3.0 (from MicroSoft)
> generates the wrong opcode for the REP - namely a REPZ.
> Assembler and C programmers beware!

I don't have my reference library at hand, but if memory serves me
correctly this is not an error.  I believe that there is not a
seperate REP opcode at the machine level.  Rather, for non-comparative
string operations (MOVS vs CMPS) the sign (Z vs NZ) is ignored.

Similarly, you may code JZ and disassemble JE.  In truth they are the
same opcode.  What you are seeing here is an artifact of your
disassembler.  Some (most?) use a simple minded one to one mapping,
while a few look at content to gain a little clarity (doesn't help
with the JE JZ problem, but fixes up REP confusion.)

PS- I verified this with several debuggers.  They all assemble REP
as REPZ.  (One won't even recognize REP as a valid opcode, you
have to be smart enought to know to use REPZ...)

-- 
Opinions expressed are public domain, and do not belong to Lotus
Development Corp.
----------------------------------------------------------------

Simcha-Yitzchak Lerner

              {genrad|ihnp4|ima}!wjh12!talcott!sesame!slerner
                      {cbosgd|harvard}!talcott!sesame!slerner
                                slerner%sesame@harvard.ARPA 

sambo@ukma.UUCP (Inventor of micro-S) (08/05/85)

In article <15959@watmath.UUCP> hhoeksma@watmath.UUCP (Henry Hoeksma) writes:
>I disassembled movmem() and discovered
>that it used the instruction REPZ MOVSB, when it should have been
>REP MOVSB.  I then wrote my own movmem() with the correct REP prefix,
>and when I disassembled the resulting object file
>it contained the REPZ prefix!  It seems that MASM 3.0 (from MicroSoft)
>generates the wrong opcode for the REP - namely a REPZ.

I happen to have an old (July 1981) iAPX88 Book from Intel handy.  Here is a
quote from page 2-132 referring to the REP and REPZ prefixes:
     "Repeat, Repeat While Equal, Repeat While Zero, Repeat While Not Equal,
     and Repeat While Not Zero are mnemonics for two forms of the prefix
     byte that controls subsequent string instruction repetition.  The dif-
     ferent mnemonics are provided to improve program clarity...  REPE and
     REPZ operate identically and are physically the same prefix byte as REP."
Thus, neither the Lattice C compiler nor MASM 3.0 is at fault in this parti-
cular instance.
-----------------------------------------
Samuel A. Figueroa, Dept. of CS, Univ. of KY, Lexington, KY  40506-0027
ARPA: ukma!sambo<@ANL-MCS>, or sambo%ukma.uucp@anl-mcs.arpa,
      or even anlams!ukma!sambo@ucbvax.arpa
UUCP: {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!sambo,
      or cbosgd!ukma!sambo

	"Micro-S is great, if only people would start using it."