Volume 1 Application Programming (794095), страница 72
Текст из файла (страница 72)
3.13—July 2007AMD64 TechnologyTable 6-20. x87 Floating-Point (#MF) Exception MasksException Maskand Mnemonicx87 Control-WordBit1Invalid-operation exception mask (IM)0Denormalized-operand exception mask (DM)1Zero-divide exception mask (ZM)2Overflow exception mask (OM)3Underflow exception mask (UM)4Precision exception mask (PM)5Note:1. See “x87 Status Word Register (FSW)” on page 241 for a summary of each exception.Each mask bit, when set to 1, inhibits invocation of the #MF exception handler and instead continuesnormal execution using the default response for the exception type.
During initialization with FINIT orFNINIT, all exception-mask bits in the x87 control word are set to 1 (masked). At processor reset, allexception-mask bits are cleared to 0 (unmasked).Masked Responses. The occurrence of a masked exception does not invoke its exception handlerwhen the exception condition occurs. Instead, the processor handles masked exceptions in a defaultway, as shown in Table 6-21 on page 286.x87 Floating-Point Programming285AMD64 Technology24592—Rev. 3.13—July 2007Table 6-21.
Masked Responses to x87 Floating-Point ExceptionsException andMnemonicType ofOperation1Any Arithmetic Operation:Source operand is an SNaN.Invalid-operationexception (IE)2Processor ResponseSet IE flag, and return a QNaN value.Any Arithmetic Operation:Source operand is anunsupported data typeorFADD, FADDP: Sourceoperands are infinities withopposite signsorFSUB, FSUBP, FSUBR,FSUBRP: Source operands areinfinities with same signorFMUL, FMULP: Sourceoperands are zero and infinitySet IE flag, and return the floating-point indefiniteorvalue3.FDIV, FDIVP, FDIVR, FDIVRP:Source operands are bothinfinities or both are zerosorFSQRT: Source operand is lessthan zero (except ±0 whichreturns ±0)orFYL2X: Source operand is lessthan zero (except ±0 whichreturns ±∞)orFYL2XP1: Source operand isless than minus one.Note:1.
See “Instruction Summary” on page 262 for the types of instructions.2. Includes invalid-operation exception (IE) together with stack fault (SF).3. See “Indefinite Values” on page 259.286x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 TechnologyTable 6-21. Masked Responses to x87 Floating-Point Exceptions (continued)Type ofOperation1Exception andMnemonicProcessor ResponseFCOS, FPTAN, FSIN,FSINCOS: Source operand is∞orFPREM, FPREM1: Dividend isinfinity or divisor is 0.Set IE flag, return the floating-point indefinite value3,and clear condition code C2 to 0.FCOM, FCOMP, or FCOMPP:One or both operands is a NaNSet IE flag, and set C3–C0 condition codes to reflectorthe result.FUCOM, FUCOMP, orFUCOMPP: One or bothoperands is an SNaN.Invalid-operationexception (IE)2FCOMI or FCOMIP: One orboth operands is a NaNorFUCOMI or FUCOMIP: One orboth operands is an SNaN.Sets IE flag, and sets the result in eflags to"unordered."FIST, FISTP, FISTTP: Sourceoperand overflows thedestination size.Set IE flag, and return the integer indefinite value3.FXCH: A source register isspecified empty by its tag bits.Set IE flag, and perform exchange using floatingpoint indefinite value3 as content for emptyregister(s).FBSTP: Source operandoverflows packed BCD datasize.Set IE flag, and return the packed-decimal indefinitevalue3.Denormalized-operand exception (DE)FDIV, FDIVP, FDIVR, FDIVRP,FIDIV, or FIDIVR: Divisor is 0.Zero-divideexception (ZE)Set DE flag, and return the result using the denormaloperand(s).Set ZE flag, and return signed ∞ with sign bit = XORof the operand sign bits.FYL2X: ST(0) is 0 and ST(1) is Set ZE flag, and return signed ∞ with sign bit =a non-zero floating-point value.
complement of sign bit for ST(1) operand.FXTRACT: Source operand is0.Set ZE flag, write ST(0) = 0 with sign of operand, andwrite ST(1) = –∞.Note:1. See “Instruction Summary” on page 262 for the types of instructions.2. Includes invalid-operation exception (IE) together with stack fault (SF).3. See “Indefinite Values” on page 259.x87 Floating-Point Programming287AMD64 Technology24592—Rev. 3.13—July 2007Table 6-21. Masked Responses to x87 Floating-Point Exceptions (continued)Type ofOperation1Exception andMnemonicProcessor ResponseRound to nearest.• If sign of result is positive, set OE flag, and return+∞ .• If sign of result is negative, set OE flag, and return-∞.Round toward +∞.• If sign of result is positive, set OE flag, and return+∞ .• If sign of result is negative, set OE flag, and returnfinite negative number with largest magnitude.Round toward -∞.• If sign of result is positive, set OE flag, and returnfinite positive number with largest magnitude.• If sign of result is negative, set OE flag, and return-∞.Round toward 0.• If sign of result is positive, set OE flag and returnfinite positive number with largest magnitude.• If sign of result is negative, set OE flag and returnfinite negative number with largest magnitude.Overflow exception(OE)Underflow exception (UE)• If result is both denormal (tiny) and inexact, set UEflag and return denormalized result.• If result is denormal (tiny) but not inexact, returndenormalized result but do not set UE flag.Without overflow or underflowSet PE flag, return rounded result, write C1 conditioncode to specify round-up (C1 = 1) or not round-up(C1 = 0).With masked overflow orunderflowSet PE flag and respond as for the OE or UEexceptions.Precision exceptionWith unmasked overflow or(PE)underflow for registerdestinationWith unmasked overflow orunderflow for memorydestinationSet PE flag, respond to the OE or UE exception bycalling the #MF service routine.Do not set PE flag, respond to the OE or UEexception by calling the #MF service routine.
Thedestination and the TOP are not changed.Note:1. See “Instruction Summary” on page 262 for the types of instructions.2. Includes invalid-operation exception (IE) together with stack fault (SF).3. See “Indefinite Values” on page 259.288x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 TechnologyUnmasked Responses. The processor handles unmasked exceptions as shown in Table 6-22 onpage 289.Table 6-22.Unmasked Responses to x87 Floating-Point ExceptionsException andMnemonicType ofOperationInvalid-operation exception (IE)Invalid-operation exception (IE)with stack fault (SF)Processor Response1Set IE and ES flags, and call the #MF service routine2.
Thedestination and the TOP are not changed.Denormalized-operand exception (DE)Set DE and ES flags, and call the #MF service routine2. Thedestination and the TOP are not changed.Zero-divide exception (ZE)Set ZE and ES flags, and call the #MF service routine2. Thedestination and the TOP are not changed.• If the destination is memory, set OE and ES flags, andcall the #MF service routine2. The destination and theTOP are not changed.• If the destination is an x87 register:Overflow exception (OE)- divide true result by 224576,- round significand according to PC precision controland RC rounding control (or round to double-extendedprecision for instructions not observing PC precisioncontrol),- write C1 condition code according to rounding (C1 = 1for round up, C1 = 0 for round toward zero),- write result to destination,- pop or push stack if specified by the instruction,- set OE and ES flags, and call the #MF service routine2.Note:1.
For all unmasked exceptions, the processor’s response also includes assertion of the FERR# output signal at thecompletion of the instruction that caused the exception.2. When CR0.NE is set to 1, the #MF service routine is taken at the next non-control x87 instruction.
If CR0.NE iscleared to zero, x87 floating-point instructions are handled by setting the FERR# input signal to 1, which externallogic can use to handle the interrupt.x87 Floating-Point Programming289AMD64 TechnologyTable 6-22.24592—Rev. 3.13—July 2007Unmasked Responses to x87 Floating-Point Exceptions (continued)Exception andMnemonicType ofOperationProcessor Response1• If the destination is memory, set UE and ES flags, and callthe #MF service routine2.
The destination and the TOPare not changed.• If the destination is an x87 register:Underflow exception (UE)- multiply true result by 224576,- round significand according to PC precision controland RC rounding control (or round to double-extendedprecision for instructions not observing PC precisioncontrol),- write C1 condition code according to rounding (C1 = 1for round up, C1 = 0 for round toward zero),- write result to destination,- pop or push stack if specified by the instruction,- set UE and ES flags, and call the #MF service routine2.Without overflow orunderflowSet PE and ES flags, return rounded result, write C1condition code to specify round-up (C1 = 1) or not round-up(C1 = 0), and call the #MF service routine2.With masked overflow orunderflowSet PE and ES flags, respond as for the OE or UEPrecision exceptionWith unmasked overflow(PE)exception, and call the #MF service routine2.or underflow for registerdestinationWith unmasked overflow Do not set PE flag, respond to the OE or UE exception byor underflow for memory calling the #MF service routine.