This preview shows page 1. Sign up to view the full content.
Unformatted text preview: he destination operand for the setae instruction, since the operand must be a single byte. Instead, we write a code sequence based on a speciﬁc register and then use an extra data movement instruction to copy the resulting value to some part of the program state. Practice Problem 3.30:
G CC provides a facility for extended-precision arithmetic. This can be used to implement function ok_smul, with the advantage that it is portable across machines. A variable declared as type “ long long” will have twice the size of normal long variable. Thus, the statement: long long prod = (long long) x * y; will compute the full 64-bit product of x and y. Write a version of ok_smul that does not use any asm statements. One would expect the same code sequence could be used for ok_umul, but GCC uses the imull (signed multiply) instruction for both signed and unsigned multiplication. This generates the correct value for either product, but it sets the carry ﬂag according to the rules for signed multiplication. We therefore ne...
View Full Document
- Spring '10
- The American