For example we have seen that the behavior of oating

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: where the latter outcome only occurs when one of the values is a Æ Æ . As an example, consider the following procedure: 1 2 3 4 int less(double x, double y) { return x < y; } The compiled code for the function body is shown below: 1 2 3 4 5 6 fldl 16(%ebp) fcompl 8(%ebp) fnstsw %ax andb $69,%ah sete %al movzbl %al,%eax Push y Compare y:x Store floating point status word in %ax Mask all but bits 0, 2, and 6 Test for comparison outcome of 0 (>) Copy low order byte to result, and set rest to 0 Practice Problem 3.29: Show how by inserting a single line of assembly code into the code sequence shown above you can implement the following function: 1 2 3 4 int greater(double x, double y) { return x > y; } This completes our coverage of assembly-level, floating-point programming with IA32. Even experienced programmers find this code arcane and difficult to read. The stack-based operations, the awkwardness of getting status results from the FPU to the main processor, and the many subtleties of floating-point co...
View Full Document

Ask a homework question - tutors are online