Summary

On one level, this chapter has completed a survey of nearly all of the Itanium instructions that operate on 64-bit integer data. The logical instructions, corresponding to certain operations of Boolean algebra, work on bit patterns by performing the same operation at every bit position in parallel. Several parallel compare instructions can target the same pair of predicate registers with the same logical results.

Shift instructions also work on ensembles of bits, sliding them in unison to the left or right by some number of bit positions given by a count encoded as an immediate value. The important distinctions among the shift instructions include the treatment of the sign bit and the shift of a 128-bit pattern from two registers. Shifts offer fast ways to multiply or divide by exact powers of two. Bit masks are versatile, as illustrated by making a distinction between the decimal value and the ASCII character representation of a digit.

Extract and deposit instructions can be related to certain specialized shift operations. In general, they create a hole in a bit pattern, stuff some narrow bit pattern into a wider bit pattern, or isolate some span of bits into the least significant end of a general register. The Itanium ISA does not restrict these operations to any byte-aligned span of bits.

Computer arithmetic is built upon a foundation of Boolean logic, as we explicitly demonstrated for single-bit addition. Later, we investigated Booth's algorithm for signed multiplication, finding that instructions of several kinds (logical, shifts, add, subtract) can be combined into a loop in order to implement a fully general multiplication of two signed 64-bit quantities. The full 128-bit product is available to register-level programming and can be adjusted quite simply if the operands are unsigned. However elegant this method might be, the number of CPU cycles needed to run a loop 64 times emphasizes the importance of simpler instruction sequences with arithmetic shifts for "easy cases" of multiplication.

We also investigated a special case of unsigned integer division, where the divisor is expressed as a reciprocal to be used in multiplication. This technique is easily extended to compute the remainder, once the quotient has been found.

After exploring the debugger in previous chapters, we introduced basic input and output using C functions. Having rudimentary ways to multiply, divide, and perform I/O opens up a wider universe of still-simple algorithms for example programs and exercises, without the need for full explanation of the software conventions for register usage and function calling. These conventions will be further explored and explained in subsequent chapters.

In Chapters 1 through 6 we have discussed nearly all types of integer-related Itanium instructions. With a basic selection of programming techniques, including a workable method for full-line input and output, the reader now has a basic toolset for writing whole programs involving character-string or integer data on an Itanium system having a C compiler/assembler.



ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net