News:

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

Does MOV ever affect the flags?

Started by cork, August 05, 2010, 12:17:14 AM

Previous topic - Next topic

cork

Is it safe to do a CMP or TEST, then do a MOV, then do a conditional jump based on flags... in that order?


Rockoon

When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

Neo

#2
Quote from: cork on August 05, 2010, 12:17:14 AM
Is it safe to do a CMP or TEST, then do a MOV, then do a conditional jump based on flags... in that order?
In those words, yes, it is always safe.  :U

In the words "Does MOV ever affect the flags?", technically yes, since if you MOV to certain control registers, it can affect certain control flags, but not condition flags.  That's probably way more information than you needed, though, since I don't know if I've ever encountered a case where I did a MOV that affected the flags.  :wink

Edit: Whoops, "yes" (in italics), instead of "no", as the rest of the sentence suggested.  :lol

hutch--

Yes it is safe as it does not modify flags. Its useful to know this as it also allows you to re-order code at times to try and find a better scheduling of instructions.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

cork

Quote from: hutch-- on August 05, 2010, 02:01:08 AM
Yes it is safe as it does not modify flags. Its useful to know this as it also allows you to re-order code at times to try and find a better scheduling of instructions.

Thanks Rockoon, Neo and Hutch.