The MASM Forum

General => The Campus => Topic started by: flipflop on February 27, 2013, 09:17:56 PM

Title: Problem with SCASB
Post by: flipflop on February 27, 2013, 09:17:56 PM
Hi all,
I've wrote this piece of code. It replaces char "a" with "#". It goes from end of string to begin. I exptect that code will go through string but it stop on first char. I've watched how code runs in Olly and repne scasb even not moves EDI to next char. What i'm doing wrong?
this is code:

include \masm32\include\masm32rt.inc
.586
.data?

.data
TestStr db "This is a test string",13,10,0
.code
start:
mov edi, [offset TestStr + 21]
std
mov al, "a"

repne scasb

cld
mov byte ptr [edi + 1], "#"

invoke StdOut, addr TestStr
inkey
invoke ExitProcess, 0
end start


thanks in advance
Title: Re: Problem with SCASB
Post by: sinsi on February 27, 2013, 09:34:54 PM
A rep needs ECX with the count, sounds like (lucky for you) that ECX is zero.
Title: Re: Problem with SCASB
Post by: flipflop on February 27, 2013, 09:42:23 PM
Thanks, that is really stupid bug. I forgot about it.