News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CMP Problem?

Started by HiddenDragon, November 22, 2010, 04:27:52 PM

Previous topic - Next topic

dedndave

the "sizeof" operator returns the length in bytes of the data define named Yes
in this case, it is 4 - the length of "Yes" and the null terminator
comparing all 4 bytes insures that, not only are the first 3 bytes the same, but that the strings are the same length

REPZ CMPSB is a repeated string instruction that compares the byte at [ESI] with the byte at [EDI]
it then increments ESI (source index) and EDI (destination index), and also decrements ECX (count register) if REP is used
REPZ makes the instruction repeat as long as the result is zero, and the count is non-zero
in other words, it will stop at the first comparison inequality, or until ECX becomes zero
when done, the zero flag will be set if the strings are equal

here is a good reference by Randy Hyde - in particular, chapter 6 - it covers the string instructions

http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/toc.html

HiddenDragon

Thanks. That takes care of all my questions on that.