hello guys,
I'm writing a program, in which there 's a need to find a specific string in a block of memeory. And I would like to implement it in assembly. Here is how i do it:

mov esi,StringAddress
mov edi,MemoryAddress
cld
mov ecx,LengthInByte
rep cmpsb <----------------error, can't compile here

je @somewhere
jne @somewhereelse

but the program can't be compiled successfully, the error message is:
error A2068: instrunction prefix not allowed

what's the problem? i use "rep movsb" in other part of the program, there is no problem , why can't "rep cmpsb" work?

Thank you for any advice~~
p.s. I'm using MASM
Posted on 2004-05-03 09:46:07 by FredLiu
use repe cmpsb or repne cmpsb instead
Posted on 2004-05-03 09:48:18 by roticv
wow~~
really quick reply~
thank you very much, now it compiles correctly!
by the way, why can't i use rep? what 's the difference?
(from some assembly tutorial, i saw them using rep with cmpsb)
thank you !
Posted on 2004-05-03 09:50:44 by FredLiu
By right, rep is a prefix to stosx, movsx,lodsx while repe is a prefix for cmpsx, scasx. However both rep and repe when turned to machine code are the same prefix, F3h. Just take it that masm is being fussy, but right in that sense.
Posted on 2004-05-03 11:22:29 by roticv