Volume 1 Basic Architecture (794100), страница 27
Текст из файла (страница 27)
1 4-7DATA TYPES4.3POINTER DATA TYPESPointers are addresses of locations in memory.In non-64-bit modes, the architecture defines two types of pointers: a near pointerand a far pointer. A near pointer is a 32-bit (or 16-bit) offset (also called an effective address) within a segment. Near pointers are used for all memory references ina flat memory model or for references in a segmented model where the identity ofthe segment being accessed is implied.A far pointer is a logical address, consisting of a 16-bit segment selector and a 32-bit(or 16-bit) offset.
Far pointers are used for memory references in a segmentedmemory model where the identity of a segment being accessed must be specifiedexplicitly. Near and far pointers with 32-bit offsets are shown in Figure 4-4.Near PointerOffset310Far Pointer or Logical AddressSegment Selector47Offset32 310Figure 4-4. Pointer Data Types4.3.1Pointer Data Types in 64-Bit ModeIn 64-bit mode (a sub-mode of IA-32e mode), a near pointer is 64 bits.
Thisequates to an effective address. Far pointers in 64-bit mode can be one of threeforms:•••16-bit segment selector, 16-bit offset if the operand size is 32 bits16-bit segment selector, 32-bit offset if the operand size is 32 bits16-bit segment selector, 64-bit offset if the operand size is 64 bitsSee Figure 4-5.4-8 Vol. 1DATA TYPES1HDU3RLQWHUELW2IIVHW)DU3RLQWHUZLWKELW2SHUDQG6L]HELW6HJPHQW6HOHFWRUELW2IIVHW )DU3RLQWHUZLWKELW2SHUDQG6L]HELW6HJPHQW6HOHFWRUELW2IIVHW 20Figure 4-5. Pointers in 64-Bit Mode4.4BIT FIELD DATA TYPEA bit field (see Figure 4-6) is a contiguous sequence of bits. It can begin at any bitposition of any byte in memory and can contain up to 32 bits.Bit FieldField LengthLeastSignificantBitFigure 4-6.
Bit Field Data Type4.5STRING DATA TYPESStrings are continuous sequences of bits, bytes, words, or doublewords. A bit stringcan begin at any bit position of any byte and can contain up to 232 – 1 bits. A bytestring can contain bytes, words, or doublewords and can range from zero to 232 – 1bytes (4 GBytes).4.6PACKED SIMD DATA TYPESIntel 64 and IA-32 architectures define and operate on a set of 64-bit and 128-bitpacked data type for use in SIMD operations. These data types consist of fundaVol.
1 4-9DATA TYPESmental data types (packed bytes, words, doublewords, and quadwords) and numericinterpretations of fundamental types for use in packed integer and packed floatingpoint operations.4.6.164-Bit SIMD Packed Data TypesThe 64-bit packed SIMD data types were introduced into the IA-32 architecture in theIntel MMX technology.
They are operated on in MMX registers. The fundamental64-bit packed data types are packed bytes, packed words, and packed doublewords(see Figure 4-7). When performing numeric SIMD operations on these data types,these data types are interpreted as containing byte, word, or doubleword integervalues.Fundamental 64-Bit Packed SIMD Data TypesPacked Bytes063Packed Words063Packed Doublewords06364-Bit Packed Integer Data TypesPacked Byte Integers630Packed Word Integers630Packed Doubleword Integers630Figure 4-7.
64-Bit Packed SIMD Data Types4.6.2128-Bit Packed SIMD Data TypesThe 128-bit packed SIMD data types were introduced into the IA-32 architecture inthe SSE extensions and used with SSE2, SSE3 and SSSE3 extensions. They are operated on primarily in the 128-bit XMM registers and memory. The fundamental 128-bitpacked data types are packed bytes, packed words, packed doublewords, andpacked quadwords (see Figure 4-8). When performing SIMD operations on these4-10 Vol. 1DATA TYPESfundamental data types in XMM registers, these data types are interpreted ascontaining packed or scalar single-precision floating-point or double-precisionfloating-point values, or as containing packed byte, word, doubleword, or quadwordinteger values.Fundamental 128-Bit Packed SIMD Data TypesPacked Bytes1270Packed Words1270Packed Doublewords12701270Packed Quadwords128-Bit Packed Floating-Point and Integer Data TypesPacked Single PrecisionFloating Point1270Packed Double PrecisionFloating Point1270Packed Byte Integers1270Packed Word Integers1270Packed Doubleword Integers1270Packed Quadword Integers1270Figure 4-8.
128-Bit Packed SIMD Data TypesVol. 1 4-11DATA TYPES4.7BCD AND PACKED BCD INTEGERSBinary-coded decimal integers (BCD integers) are unsigned 4-bit integers with validvalues ranging from 0 to 9. IA-32 architecture defines operations on BCD integerslocated in one or more general-purpose registers or in one or more x87 FPU registers(see Figure 4-9).BCD IntegersX7BCD430Packed BCD IntegersBCD BCD743080-Bit Packed BCD Decimal IntegersSignX79 78D17 D16 D15 D14 D13 D12 D11 D10D9D8D7D6D5D4D3D2D1D072 7104 Bits = 1 BCD DigitFigure 4-9. BCD Data TypesWhen operating on BCD integers in general-purpose registers, the BCD values can beunpacked (one BCD digit per byte) or packed (two BCD digits per byte).
The value ofan unpacked BCD integer is the binary value of the low half-byte (bits 0 through 3).The high half-byte (bits 4 through 7) can be any value during addition and subtraction, but must be zero during multiplication and division. Packed BCD integers allowtwo BCD digits to be contained in one byte. Here, the digit in the high half-byte ismore significant than the digit in the low half-byte.When operating on BCD integers in x87 FPU data registers, BCD values are packed inan 80-bit format and referred to as decimal integers. In this format, the first 9 byteshold 18 BCD digits, 2 digits per byte.
The least-significant digit is contained in thelower half-byte of byte 0 and the most-significant digit is contained in the upper halfbyte of byte 9. The most significant bit of byte 10 contains the sign bit (0 = positiveand 1 = negative; bits 0 through 6 of byte 10 are don’t care bits).
Negative decimalintegers are not stored in two's complement form; they are distinguished from positive decimal integers only by the sign bit. The range of decimal integers that can beencoded in this format is –1018 + 1 to 1018 – 1.The decimal integer format exists in memory only. When a decimal integer is loadedin an x87 FPU data register, it is automatically converted to the double-extendedprecision floating-point format. All decimal integers are exactly representable indouble extended-precision format.Table 4-4 gives the possible encodings of value in the decimal integer data type.4-12 Vol. 1DATA TYPESTable 4-4.
Packed Decimal Integer EncodingsMagnitudeClassPositiveSigndigitdigitdigitdigit...digit1001100110011001...100100000000......Smallest000000000000000000000000...0001Zero000000000000000000000000...0000Zero100000000000000000000000...0000Smallest100000000000000000000000...0001......Largest100000001001100110011001...1001PackedBCDIntegerIndefinite111111111111111111000000...0000LargestNegative← 1 byte →← 9 bytes →The packed BCD integer indefinite encoding (FFFFC000000000000000H) is stored bythe FBSTP instruction in response to a masked floating-point invalid-operationexception. Attempting to load this value with the FBLD instruction produces an undefined result.4.8REAL NUMBERS AND FLOATING-POINT FORMATSThis section describes how real numbers are represented in floating-point format inx87 FPU and SSE/SSE2/SSE3 floating-point instructions.
It also introduces termssuch as normalized numbers, denormalized numbers, biased exponents, signedzeros, and NaNs. Readers who are already familiar with floating-point processingtechniques and the IEEE Standard 754 for Binary Floating-Point Arithmetic may wishto skip this section.Vol. 1 4-13DATA TYPES4.8.1Real Number SystemAs shown in Figure 4-10, the real-number system comprises the continuum of realnumbers from minus infinity (− ∞) to plus infinity (+ ∞).Because the size and number of registers that any computer can have is limited, onlya subset of the real-number continuum can be used in real-number (floating-point)calculations.
As shown at the bottom of Figure 4-10, the subset of real numbers thatthe IA-32 architecture supports represents an approximation of the real numbersystem. The range and precision of this real-number subset is determined by theIEEE Standard 754 floating-point formats.4.8.2Floating-Point FormatTo increase the speed and efficiency of real-number computations, computers andmicroprocessors typically represent real numbers in a binary floating-point format.In this format, a real number has three parts: a sign, a significand, and an exponent(see Figure 4-11).The sign is a binary value that indicates whether the number is positive (0) or negative (1).
The significand has two parts: a 1-bit binary integer (also referred to asthe J-bit) and a binary fraction. The integer-bit is often not represented, but insteadis an implied value. The exponent is a binary integer that represents the base-2power by which the significand is multiplied.Table 4-5 shows how the real number 178.125 (in ordinary decimal format) is storedin IEEE Standard 754 floating-point format. The table lists a progression of realnumber notations that leads to the single-precision, 32-bit floating-point format.
Inthis format, the significand is normalized (see Section 4.8.2.1, “NormalizedNumbers”) and the exponent is biased (see Section 4.8.2.2, “Biased Exponent”). Forthe single-precision floating-point format, the biasing constant is +127.4-14 Vol. 1DATA TYPES-100Binary Real Number System10-1 0-101100ςςςςSubset of binary real numbers that can be represented withIEEE single-precision (32-bit) floating-point format10-1 0100-100-101ςςςς+1010.0000000000000000000000Precision1.1111111111111111111111124 Binary DigitsNumbers within this rangecannot be represented.Figure 4-10.