The Reversers.org Vault : FlagsDef

HomePage :: Categories :: PageIndex :: Files :: RecentChanges :: RecentlyCommented :: Login/Register

Definition of flags


Required Knowledge
Register memory.

Flags
As well as the registers the CPU uses there is also another register which acts as many small 'flags'. These flags provide extended information for certain operations, such as the compare and test instructions.
The flags' states are useful in many situations, notably conditional jumps.

The following flags are used under the x86 architecture:

The zero flag is set when an operation finds a register to be 0. Various operations can set the zero flag, among these are 'dec', 'test', 'cmp' and others. It is worth noting that the zero flag is the equivalent to an 'equals' flag (which doesn't exist seperately). If you compare two values and they are equal, the zero flag will be set. It is for this reason that "jnz" and "jne" (jump if not zero and jump if not equal) are synonamous.
The zero flag is used in many loops, take the following code as an example:
mov ecx, 5
start:
dec ecx
jnz start
...

When the ecx register becomes 0, the dec operation will set the zero flag and thus the 'jnz' will not be taken and execution will continue. This is similar to the code created using a for loop in various high level languages.
A test on an instruction with itself, such as "test eax, eax" will also set the zero flag if the aforementioned register is zero.


Related links

  Attachment Size Date Added
    


Categories
CategoryDefinitions

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.0
Page was generated in 0.2269 seconds