Volume 1 Application Programming (794095), страница 64
Текст из файла (страница 64)
Although Figure 6-7 shows register images of the datatypes, the three signed-integer data types can exist only in memory. All data types are converted into an80-bit format when they are loaded into an x87 register.250x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 TechnologyFloating-Point79s063exp79s63Double-ExtendedPrecisionsignificandiexpDouble Precisionsignificand51sexp31Single Precisionsignificand220Signed Integer8 bytess63Quadwords4 bytes31sDoubleword2 bytes15Word0Binary-Coded Decimal (BCD)Packed Decimalss79710513-317.epsFigure 6-7.x87 Data TypesFloating-Point Data Types.
The floating-point data types, shown in Figure 6-8 on page 252, include32-bit single precision, 64-bit double precision, and 80-bit double-extended precision. The defaultprecision is double-extended precision, and all operands loaded into registers are converted intodouble-extended precision format.All three floating-point formats are compatible with the IEEE Standard for Binary Floating-PointArithmetic (ANSI/IEEE Std 754 and 854).x87 Floating-Point Programming251AMD64 Technology24592—Rev.
3.13—July 200731 30Single PrecisionS23 220Significand(also Fraction)BiasedExponentS = Sign BitDouble Precision63 62S052 51BiasedExponentSignificand(also Fraction)S = Sign BitDouble-Extended Precision64 63 6279 78BiasedExponentSS = Sign Bit0IFractionI = Integer BitSignificandFigure 6-8. x87 Floating-Point Data TypesAll of the floating-point data types consist of a sign (0 = positive, 1 = negative), a biased exponent(base-2), and a significand, which represents the integer and fractional parts of the number.
The integerbit (also called the J bit) is either implied (called a hidden integer bit) or explicit, depending on the datatype. The value of an implied integer bit can be inferred from number encodings, as described in“Number Encodings” on page 257. The bias of the exponent is a constant which makes the exponentalways positive and allows reciprocation, without overflow, of the smallest normalized numberrepresentable by that data type.Specifically, the data types are formatted as follows:•••Single-Precision Format—This format includes a 1-bit sign, an 8-bit biased exponent whose valueis 127, and a 23-bit significand. The integer bit is implied, making a total of 24 bits in thesignificand.Double-Precision Format—This format includes a 1-bit sign, an 11-bit biased exponent whosevalue is 1023, and a 52-bit significand.
The integer bit is implied, making a total of 53 bits in thesignificand.Double-Extended-Precision Format—This format includes a 1-bit sign, a 15-bit biased exponentwhose value is 16,383, and a 64-bit significand, which includes one explicit integer bit.252x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 TechnologyTable 6-5 shows the range of finite values representable by the three x87 floating-point data types.Table 6-5.Range of Finite Floating-Point ValuesRange of Finite Values1Data TypePrecisionBase 2Base 10Single Precision2–126 to 2127 * (2 – 2–23)1.17 * 10–38 to +3.40 * 103824 bitsDouble Precision2–1022 to 21023 * (2 – 2–52)2.23 * 10–308 to +1.79 * 1030853 bitsDouble-ExtendedPrecision2–16382 to 216383 * (2 – 2–63)3.37 * 10–4932 to +1.18 * 10493264 bitsNote:1.
See “Number Representation” on page 254.For example, in the single-precision format, the largest normal number representable has an exponentof FEh and a significand of 7FFFFFh, with a numerical value of 2127 * (2 – 2–23). Results that overflowabove the maximum representable value return either the maximum representable normalized number(see “Normalized Numbers” on page 255) or infinity, with the sign of the true result, depending on therounding mode specified in the rounding control (RC) field of the x87 control word. Results thatunderflow below the minimum representable value return either the minimum representablenormalized number or a denormalized number (see “Denormalized (Tiny) Numbers” on page 255),with the sign of the true result, or a result determined by the x87 exception handler, depending on therounding mode, precision mode, and underflow-exception mask (UM) in the x87 control word (see“Unmasked Responses” on page 289).Integer Data Type.
The integer data types, shown in Figure 6-7 on page 251, include two’s-complement 16-bit word, 32-bit doubleword, and 64-bit quadword. These data types are used in x87instructions that convert signed integer operands into floating-point values. The integers can be loadedfrom memory into x87 registers and stored from x87 registers into memory. The data types cannot bemoved between x87 registers and other registers.For details on the format and number-representation of the integer data types, see “Data Types” onpage 36.Packed-Decimal Data Type. The 80-bit packed-decimal data type, shown in Figure 6-9 on page 254,represents an 18-digit decimal integer using the binary-coded decimal (BCD) format. Each of the 18digits is a 4-bit representation of an integer.
The 18 digits use a total of 72 bits. The next-higher sevenbits in the 80-bit format are reserved (ignored on loads, zeros on stores). The high bit (bit 79) is a signbit.x87 Floating-Point Programming253AMD64 Technology24592—Rev. 3.13—July 200779 78 72 710Ignoreor ZeroSPrecision — 18 Digits, 72 Bits Used, 4-Bits/DigitDescriptionIgnored on Load, Zeros on StoreSign BitBits78-7279Figure 6-9. x87 Packed Decimal Data TypeTwo x87 instructions operate on the packed-decimal data type. The FBLD (floating-point load binarycoded decimal) and FBSTP (floating-point store binary-coded decimal integer and pop) instructionspush and pop, respectively, a packed-decimal memory operand between the floating-point stack andmemory.
FBLD converts the value being pushed to a double-extended-precision floating-point value.FBSTP rounds the value being popped to an integer.For details on the format and use of 4-bit BCD integers, see “Binary-Coded-Decimal (BCD) Digits”on page 38.6.3.3 Number RepresentationOf the following types of floating-point values, six are supported by the architecture and three are notsupported:••Supported Values- Normal- Denormal (Tiny)- Pseudo-Denormal- Zero- Infinity- Not a Number (NaN)Unsupported Values- Unnormal- Pseudo-Infinity- Pseudo-NaNThe supported values can be used as operands in x87 floating-point instructions.
The unsupportedvalues cause an invalid-operation exception (IE) when used as operands.In common engineering and scientific usage, floating-point numbers—also called real numbers—arerepresented in base (radix) 10. A non-zero number consists of a sign, a normalized significand, and asigned exponent, as in:254x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 Technology+2.71828 e0Both large and small numbers are representable in this notation, subject to the limits of data-typeprecision.
For example, a million in base-10 notation appears as +1.00000 e6 and -0.0000383 isrepresented as -3.83000 e-5. A non-zero number can always be written in normalized form—that is,with a leading non-zero digit immediately before the decimal point. Thus, a normalized significand inbase-10 notation is a number in the range [1,10). The signed exponent specifies the number ofpositions that the decimal point is shifted.Unlike the common engineering and scientific usage described above, x87 floating-point numbers arerepresented in base (radix) 2.
Like its base-10 counterpart, a normalized base-2 significand is writtenwith its leading non-zero digit immediately to the left of the radix point. In base-2 arithmetic, a nonzero digit is always a one, so the range of a binary significand is [1,2):+1.fraction±exponentThe leading non-zero digit is called the integer bit, and in the x87 double-extended-precision floatingpoint format this integer bit is explicit, as shown in Figure 6-8. In the x87 single-precision and thedouble-precision floating-point formats, the integer bit is simply omitted (and called the hiddeninteger bit), because its implied value is always 1 in a normalized significand (0 in a denormalizedsignificand), and the omission allows an extra bit of precision.The following sections describe the supported number representations.Normalized Numbers.