One useful technique is to use checking code to test

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 first ‘l’ of this instruction indicates “less,” while the second is the GAS suffix 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

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online