Get ZF Value

Source: Internet
Author: User

To obtain the ZF value, you can use the sete command (put the ZF value in Al) or the jnz JNE jump command to obtain it indirectly. See the following code:

Char x S1 = "123 ";
Char * S2 = "1234 ";

_ ASM
{
XOR Al, Al
MoV EDI, S1
MoV ECx,-1
Repnz scasb
Not ECx // get the length of string S1 (including the trailing null character '\ 0 ')
MoV EDI, S1
MoV ESI, S2
Repz cmpsb

Jnz another
MoV eax, 1 // use 1 to indicate that S1 is the same as S2
JMP end
Another:
MoV eax, 0 // use 0 to indicate that S1 is different from S2.
End:
}

NOTE: If ECx is 0, it is inaccurate to determine whether the two strings are the same. In this example, when the repe cmpsb loop ends, ECx is equal to 0, but the two strings are not equal, at this time, ZF = 0.
Therefore, to determine whether the two strings are equal, check whether ZF is always set to 1 instead of ECx.

Get ZF Value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.