Conditional Control Instructions
Objectives
We would like to :
- Investigate the flags register
Notes
- Reference
- The FLAGS register in intel contains information about the current state of the CPU
- Many different contiditons set the FLAGS register in intel
- This includes
- If the last instuction had a carry
- If the last instruction produced a 0
- If the last operation produced a negative number.
- If the last operation had overflow.
- Wikipedia has many more.
- We don't have direct access to the flags register,
- But pushf, pushfd, pushfq will push it onto the stack.
- And then we can pop it off into another register.
- There are logical instructions in assembly
-
and dest, src will and the src with the dest
- This is a bitwise and.
- There are also or, not, and xor
- We need to be careful not to mess up the values over function call
- registers 12, 13, 14, 15 are Preserved
- If a function changes these, it should restore them.
- I do this with r12 in my PrintFlags function
- See flags.asm.
- These are checked with
- jz, (je) - zero
- jnz, (jne) - not zero
- jc, jnc - carry
- jo, jno - overflow
- js, jns - sign
- jp, (jpe) - even parity
- jnp, (jpo) - odd parity
- See loop.asm.