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:
mov esi,test1
mov edi,test2
mov ecx,4
.scan: cmpsb
loope .scan
test1 db 'abcd'
test2 db 'afgh'
gives the same result as
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.