flat assembler
Message board for the users of flat assembler.

Index > Main > [SOLVED] REPE instruction fails when paired with CMP

Author
Thread Post new topic Reply to topic
Krecik



Joined: 19 Jul 2012
Posts: 13
Krecik 22 Aug 2012, 08:24
I try to write comparing loop. It should work but it doesn't
Code:
mov ecx,6
mov ebx,my_string
repe cmp byte[ebx+ecx],0
...
my_string db "Hello",0     

Is there anything that I must know about?


Last edited by Krecik on 23 Aug 2012, 08:49; edited 1 time in total
Post 22 Aug 2012, 08:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 22 Aug 2012, 08:51
REP only works with the string instructions: MOVS, CMPS, LODS, STOS

The Intel and AMD manuals state this quite clearly.
Post 22 Aug 2012, 08:51
View user's profile Send private message Visit poster's website Reply with quote
Krecik



Joined: 19 Jul 2012
Posts: 13
Krecik 22 Aug 2012, 12:06
I tested and REP works also with SCAS and others instructions.

Are the REP operations faster than looping by J# conditions?
Post 22 Aug 2012, 12:06
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 22 Aug 2012, 17:56
SCAS is also string instruction. revolution simply forgot about it. REP (of all kinds) does not work with CMP.
Use SCAS instead.
Post 22 Aug 2012, 17:56
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 23 Aug 2012, 05:32
JohnFound wrote:
SCAS is also string instruction. revolution simply forgot about it.
Yes, I did forget about it. Sorry if it caused some confusion.
Krecik wrote:
Are the REP operations faster than looping by J# conditions?
We don't know. Speed of execution depends upon many many factors. There could be some situations where one is faster than the other, and other situations where the outcome is reversed.
Post 23 Aug 2012, 05:32
View user's profile Send private message Visit poster's website Reply with quote
Krecik



Joined: 19 Jul 2012
Posts: 13
Krecik 23 Aug 2012, 08:48
Thank you both.
I learn something new every day!
Post 23 Aug 2012, 08:48
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.