Unformatted text preview: tructions. These instructions allow some forms of conditionals to be implemented without any branch instructions. With the IA32 instruction set, a number of different cmov instructions were added starting with the PentiumPro. These are supported by all recent Intel and Intel-compatible processors. These instructions perform an operation similar to the C code:
if (COND) x = y; where y is the source operand and x is the destination operand. The condition COND determining whether the copy operation takes place is based on some combination of condition code values, similar to the test and conditional jump instructions. As an example, the cmovll instruction performs a copy when the condition codes indicate a value less than zero. Note that the ﬁrst ‘l’ of this instruction indicates “less,” while the second is the GAS sufﬁx for long word. The following assembly code shows how to implement absolute value with conditional move.
1 2 3 4 5 movl 8(%ebp),%eax movl %eax,%edx negl %edx testl %eax,%eax
Conditionally move %edx to %eax Get val as result Copy to %edx Negate %edx Test val If < 0, copy %edx to...
View Full Document