
CS485G Spring 2015 18
5. The test instruction (testl b, a) also sets the flags; it’s like com-
puting a&b without modifying the destination. Usually, one of the
two operands is a mask.
(a) sets ZF if a ∧ b = 0
(b) sets SF if a ∧ b < 0
6. Many instructions in the setXX dest family test the condition codes
and set the destination (a single byte) to 0 or 1 based on the result.
sete ZF Equal/Zero
setne ¬ZF Not Equal / Not Zero
sets SF Negative
setns ¬SF Nonnegative
setg ¬(SF⊕OF)∧¬ZF Greater (Signed)
setge ¬(SF⊕OF) Greater or Equal (Signed)
setl (SF⊕OF) Less (Signed)
setle (SF⊕OF)∨ZF Less or Equal (Signed)
seta ¬CF∧¬ZF Above (unsigned)
setb CF Below (unsigned)
7. Many instructions in the jXX dest family jump depending on the con-
dition codes.
jmp true Unconditional
je ZF Equal/Zero
jne ¬ZF Not Equal / Not Zero
js SF Negative
jns ¬SF Nonnegative
jg ¬(SF⊕OF)∧¬ZF Greater (Signed)
jge ¬(SF⊕OF) Greater or Equal (Signed)
jl (SF⊕OF) Less (Signed)
jle (SF⊕OF)∨ZF Less or Equal (Signed)
ja ¬CF∧¬ZF Above (unsigned)
jb CF Below (unsigned)
8. Lecture 11, 2/9/2015
9. Example
Comentarios a estos manuales