Volume 1 Basic Architecture (794100), страница 26
Текст из файла (страница 26)
The natural boundaries for words, double words, and quadwords areeven-numbered addresses, addresses evenly divisible by four, and addresses evenlydivisible by eight, respectively. However, to improve the performance of programs,data structures (especially stacks) should be aligned on natural boundaries whenever possible. The reason for this is that the processor requires two memoryaccesses to make an unaligned memory access; aligned accesses require only onememory access.
A word or doubleword operand that crosses a 4-byte boundary or aquadword operand that crosses an 8-byte boundary is considered unaligned andrequires two separate memory bus cycles for access.Some instructions that operate on double quadwords require memory operands to bealigned on a natural boundary. These instructions generate a general-protectionexception (#GP) if an unaligned operand is specified. A natural boundary for a doublequadword is any address evenly divisible by 16. Other instructions that operate ondouble quadwords permit unaligned access (without generating a general-protectionexception). However, additional memory bus cycles are required to access unaligneddata from memory.4-2 Vol. 1DATA TYPES4.2NUMERIC DATA TYPESAlthough bytes, words, and doublewords are fundamental data types, some instructions support additional interpretations of these data types to allow operations to beperformed on numeric data types (signed and unsigned integers, and floating-pointnumbers).
See Figure 4-3.Byte Unsigned Integer70Word Unsigned Integer015Doubleword Unsigned Integer031Quadword Unsigned Integer063SignByte Signed Integer760SignWord Signed Integer15 140SignDoubleword Signed Integer31 300SignQuadword Signed Integer63 620Sign31 3023 220Sign63 62Sign79 7852 510Integer Bit064 63 62Single PrecisionFloating PointDouble PrecisionFloating PointDouble Extended PrecisionFloating PointFigure 4-3. Numeric Data TypesVol. 1 4-3DATA TYPES4.2.1IntegersThe Intel 64 and IA-32 architectures define two types of integers: unsigned andsigned. Unsigned integers are ordinary binary values ranging from 0 to the maximumpositive number that can be encoded in the selected operand size.
Signed integersare two’s complement binary values that can be used to represent both positive andnegative integer values.Some integer instructions (such as the ADD, SUB, PADDB, and PSUBB instructions)operate on either unsigned or signed integer operands. Other integer instructions(such as IMUL, MUL, IDIV, DIV, FIADD, and FISUB) operate on only one integer type.The following sections describe the encodings and ranges of the two types ofintegers.4.2.1.1Unsigned IntegersUnsigned integers are unsigned binary numbers contained in a byte, word, doubleword, and quadword. Their values range from 0 to 255 for an unsigned byte integer,from 0 to 65,535 for an unsigned word integer, from 0 to 232 – 1 for an unsigneddoubleword integer, and from 0 to 264 – 1 for an unsigned quadword integer.Unsigned integers are sometimes referred to as ordinals.4.2.1.2Signed IntegersSigned integers are signed binary numbers held in a byte, word, doubleword, orquadword.
All operations on signed integers assume a two's complement representation. The sign bit is located in bit 7 in a byte integer, bit 15 in a word integer, bit 31 ina doubleword integer, and bit 63 in a quadword integer (see the signed integerencodings in Table 4-1).4-4 Vol. 1DATA TYPESTable 4-1. Signed Integer EncodingsClassTwo’s Complement EncodingSignPositiveLargest011..11....000..01000..00111..11....100..00100..00Signed Byte Integer:Signed Word Integer:Signed Doubleword Integer:Signed Quadword Integer:← 7 bits →← 15 bits →← 31 bits →← 63 bits →SmallestZeroNegativeSmallestLargestInteger indefiniteThe sign bit is set for negative integers and cleared for positive integers and zero.Integer values range from –128 to +127 for a byte integer, from –32,768 to +32,767for a word integer, from –231 to +231 – 1 for a doubleword integer, and from –263 to+263 – 1 for a quadword integer.When storing integer values in memory, word integers are stored in 2 consecutivebytes; doubleword integers are stored in 4 consecutive bytes; and quadword integers are stored in 8 consecutive bytes.The integer indefinite is a special value that is sometimes returned by the x87 FPUwhen operating on integer values.
For more information, see Section 8.2.1, “Indefinites.”4.2.2Floating-Point Data TypesThe IA-32 architecture defines and operates on three floating-point data types:single-precision floating-point, double-precision floating-point, and double-extendedprecision floating-point (see Figure 4-3). The data formats for these data typescorrespond directly to formats specified in the IEEE Standard 754 for Binary FloatingPoint Arithmetic.Table 4-2 gives the length, precision, and approximate normalized range that can berepresented by each of these data types.
Denormal values are also supported in eachof these types.Vol. 1 4-5DATA TYPESTable 4-2. Length, Precision, and Range of Floating-Point Data TypesData TypeSingle PrecisionLength32Precision(Bits)24Approximate Normalized RangeBinary2–126–1022127to 2Double Precision64532Double ExtendedPrecision80642–16382 to2163831023to 2Decimal–381.18 × 10to 3.40 × 1038–3082.23 × 1010308to 1.79 ×3.37 × 10–4932 to 1.18 ×104932NOTESection 4.8, “Real Numbers and Floating-Point Formats,” gives anoverview of the IEEE Standard 754 floating-point formats and definesthe terms integer bit, QNaN, SNaN, and denormal value.Table 4-3 shows the floating-point encodings for zeros, denormalized finite numbers,normalized finite numbers, infinites, and NaNs for each of the three floating-pointdata types.
It also gives the format for the QNaN floating-point indefinite value. (SeeSection 4.8.3.7, “QNaN Floating-Point Indefinite,” for a discussion of the use of theQNaN floating-point indefinite value.)For the single-precision and double-precision formats, only the fraction part of thesignificand is encoded. The integer is assumed to be 1 for all numbers except 0 anddenormalized finite numbers. For the double extended-precision format, the integeris contained in bit 63, and the most-significant fraction bit is bit 62. Here, the integeris explicitly set to 1 for normalized numbers, infinities, and NaNs, and to 0 for zeroand denormalized numbers.Table 4-3. Floating-Point Number and NaN EncodingsClassPositive4-6 Vol.
1SignBiased ExponentSignificandInteger1Fraction+∞011..11100..00+Normals0..011..10..00..011..111..11..00..00+Denormals0..000..00..00..000..011.11..00..01+Zero000..00000..00DATA TYPESTable 4-3. Floating-Point Number and NaN EncodingsNegativeNaNs−Zero100..00000..00−Denormals1..100..00..00..000..000..01..11..11−Normals1..100..01..11..101..100..00..11..11-•111..11100..00SNaNX11..1110X..XX2QNaNX11..1111X..XXQNaNFloating-PointIndefinite111..11110..00Single-Precision:Double-Precision:Double Extended-Precision:← 8 Bits →← 11 Bits →← 15 Bits →← 23 Bits →← 52 Bits →← 63 Bits →NOTES:1.
Integer bit is implied and not stored for single-precision and double-precision formats.2. The fraction for SNaN encodings must be non-zero with the most-significant bit 0.The exponent of each floating-point data type is encoded in biased format; seeSection 4.8.2.2, “Biased Exponent.” The biasing constant is 127 for the singleprecision format, 1023 for the double-precision format, and 16,383 for the doubleextended-precision format.When storing floating-point values in memory, single-precision values are stored in 4consecutive bytes in memory; double-precision values are stored in 8 consecutivebytes; and double extended-precision values are stored in 10 consecutive bytes.The single-precision and double-precision floating-point data types are operated onby x87 FPU, and SSE/SSE2/SSE3 instructions. The double-extended-precisionfloating-point format is only operated on by the x87 FPU.
See Section 11.6.8,“Compatibility of SIMD and x87 FPU Floating-Point Data Types,” for a discussion ofthe compatibility of single-precision and double-precision floating-point data typesbetween the x87 FPU and SSE/SSE2/SSE3 extensions.Vol.