The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: cork on August 05, 2010, 12:17:14 AM

Title: Does MOV ever affect the flags?
Post by: 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?

Title: Re: Does MOV ever affect the flags?
Post by: Rockoon on August 05, 2010, 12:56:51 AM
MOV never effects the flags.
Title: Re: Does MOV ever affect the flags?
Post by: Neo on August 05, 2010, 12:58:28 AM
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
Title: Re: Does MOV ever affect the flags?
Post by: 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.
Title: Re: Does MOV ever affect the flags?
Post by: cork on August 06, 2010, 07:21:35 AM
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.