flat assembler
Message board for the users of flat assembler.

Index > Main > repe cmpsb "bug?"

Author
Thread Post new topic Reply to topic
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 22 Dec 2006, 10:08
While writing up a parser for commandline arguments I noted a curious
REPE CMSPB behaviour:

- if first letter don't match: ESI and EDI +1, NZ, ECX-1
- if first letter MATCHES but second letter don't match: same as above!!

For example:
Code:
        mov     esi,test1
        mov     edi,test2
        mov     ecx,4
.scan:  cmpsb
        loope .scan

test1   db 'abcd'
test2   db 'afgh'    


gives the same result as

Code:
        mov     esi,test1
        mov     edi,test2
        mov     ecx,4
.scan:  cmpsb
        loope .scan

test1   db 'abcd'
test2   db 'efgh'    


This bothers me because I want my commandline argument parser to parse partial arguments (so the user can use the option /extract and /e synonymously), and this unexpected behaviour of REPE CMPSB took me sometime to resolve.

Anyway, I wonder how many people are aware of this curious behaviour of REPE CMPSB.
Post 22 Dec 2006, 10:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20341
Location: In your JS exploiting you and your system
revolution 22 Dec 2006, 10:34
I think you had better check your DS and ES segment registers. Don't forget it is DS:ESI and ES:EDI that are used.
Post 22 Dec 2006, 10:34
View user's profile Send private message Visit poster's website Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 22 Dec 2006, 10:42
Thanks, I think it's okay now. My mistake Wink
Post 22 Dec 2006, 10:42
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.