Volume 1 Application Programming (794095), страница 67
Текст из файла (страница 67)
These prefixes aresummarized in “Instruction Prefixes” on page 71.Mnemonics. The following characters are used as prefixes in the mnemonics of integer instructions:•F—x87 Floating-pointIn addition to the above prefix characters, the following characters are used elsewhere in themnemonics of x87 instructions:••••••••••••B—Below, or BCDBE—Below or EqualCMOV—Conditional Movec—Variable conditionE—EqualI—IntegerLD—LoadN—No WaitNB—Not BelowNBE—Not Below or EqualNE—Not EqualNU—Not Unorderedx87 Floating-Point Programming263AMD64 Technology••••••24592—Rev.
3.13—July 2007P—PopPP—Pop TwiceR—ReverseST—StoreU—Unorderedx—One or more variable characters in the mnemonicFor example, the mnemonic for the store instruction that stores the top-of-stack and pops the stack isFSTP. In this mnemonic, the F means a floating-point instruction, the ST means a store, and the Pmeans pop the stack.6.4.2 Data Transfer and ConversionThe data transfer and conversion instructions copy data—in some cases with data conversion—between x87 stack registers and memory or between stack positions.Load or Store Floating-Point• FLD—Floating-Point Load• FST—Floating-Point Store Stack Top• FSTP—Floating-Point Store Stack Top and PopThe FLD instruction pushes the source operand onto the top-of-stack, ST(0). The source operand maybe a single-precision, double-precision, or double-extended-precision floating-point value in memoryor the contents of a specified stack position, ST(i).The FST instruction copies the value at the top-of-stack, ST(0), to a specified stack position, ST(i), orto a 32-bit or 64-bit memory location.
If the destination is a memory location, the value copied isconverted to the precision allowed by the destination and rounded, as specified by the rounding control(RC) field of the x87 control word. If the top-of-stack value is a NaN or an infinity, FST truncates thestack-top exponent and significand to fit the destination size. (For details, see “FST FSTP” in AMD64Architecture Programmer’s Manual Volume 5: 64-bit Media and x87 Floating-Point Instructions,order# 26569.The FSTP instruction is similar to FST, except that FSTP can also store to an 80-bit memory locationand it pops the stack after the store.
FSTP can be used to clean up the x87 stack at the end of an x87procedure by removing one register of preloaded data from the stack.Convert and Load or Store Integer••••FILD—Floating-Point Load IntegerFIST—Floating-Point Integer StoreFISTP—Floating-Point Integer Store and PopFISTTP—Floating-Point Integer Truncate and Store264x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 TechnologyThe FILD instruction converts the 16-bit, 32-bit, or 64-bit source signed integer in memory into adouble-extended-precision floating-point value and pushes the result onto the top-of-stack, ST(0).The FIST instruction converts and rounds the source value in the top-of-stack, ST(0), to a signedinteger and copies it to the specified 16-bit or 32-bit memory location.
The type of rounding isdetermined by the rounding control (RC) field of the x87 control word.The FISTP instruction is similar to FIST, except that FISTP can also store the result to a 64-bitmemory location and it pops ST(0) after the store.The FISTTP instruction converts a floating-point value in ST(0) to an integer by truncating thefractional part of the number and storing the integer result to the memory address specified by thedestination operand. FISTTP then pops the floating point register stack. The FISTTP instructionignores the rounding mode specified by the x87 control word.Convert and Load or Store BCD• FBLD—Floating-Point Load Binary-Coded Decimal• FBSTP—Floating-Point Store Binary-Coded Decimal Integer and PopThe FBLD and FBSTP instructions, respectively, push and pop an 80-bit packed BCD memory valueon and off the top-of-stack, ST(0). FBLD first converts the value being pushed to a double-extendedprecision floating-point value.
FBSTP rounds the value being popped to an integer, using the roundingmode specified by the RC field, and converts the value to an 80-bit packed BCD value. Thus, noFRNDIT (round-to-integer) instruction is needed prior to FBSTP.Conditional Move• FCMOVB—Floating-Point Conditional Move If Below• FCMOVBE—Floating-Point Conditional Move If Below or Equal• FCMOVE—Floating-Point Conditional Move If Equal• FCMOVNB—Floating-Point Conditional Move If Not Below• FCMOVNBE—Floating-Point Conditional Move If Not Below or Equal• FCMOVNE—Floating-Point Conditional Move If Not Equal• FCMOVNU—Floating-Point Conditional Move If Not Unordered• FCMOVU—Floating-Point Conditional Move If UnorderedThe FCMOVcc instructions copy the contents of a specified stack position, ST(i), to the top-of-stack,ST(0), if the specified rFLAGS condition is met. Table 6-13 on page 266 specifies the flagcombinations for each conditional move.x87 Floating-Point Programming265AMD64 Technology24592—Rev. 3.13—July 2007Table 6-13.
rFLAGS Conditions for FCMOVccConditionMnemonicrFLAGS Register StateBelowBCarry flag is set (CF = 1)Below or EqualBEEither carry flag or zero flag is set(CF = 1 or ZF = 1)EqualEZero flag is set (ZF = 1)Not BelowNBCarry flag is not set (CF = 0)Not Below or EqualNBENeither carry flag nor zero flag is set(CF = 0, ZF = 0)Not EqualNEZero flag is not set (ZF = 0)Not UnorderedNUParity flag is not set (PF = 0)UnorderedUParity flag is set (PF = 1)Exchange• FXCH—Floating-Point ExchangeThe FXCH instruction exchanges the contents of a specified stack position, ST(i), with the top-ofstack, ST(0).
The top-of-stack pointer is left unchanged. In the form of the instruction that specifies nooperand, the contents of ST(1) and ST(0) are exchanged.Extract• FXTRACT—Floating-Point Extract Exponent and SignificandThe FXTRACT instruction copies the unbiased exponent of the original value in the top-of-stack,ST(0), and writes it as a floating-point value to ST(1), then copies the significand and sign of theoriginal value in the top-of-stack and writes it as a floating-point value with an exponent of zero to thetop-of-stack, ST(0).6.4.3 Load ConstantsLoad 0, 1, or Pi• FLDZ—Floating-Point Load +0.0• FLD1—Floating-Point Load +1.0• FLDPI—Floating-Point Load PiThe FLDZ, FLD1, and FLDPI instructions, respectively, push the floating-point constant value, +0.0,+1.0, and Pi (3.141592653...), onto the top-of-stack, ST(0).Load Logarithm• FLDL2E—Floating-Point Load Log2 e• FLDL2T—Floating-Point Load Log2 10266x87 Floating-Point Programming24592—Rev.
3.13—July 2007••AMD64 TechnologyFLDLG2—Floating-Point Load Log10 2FLDLN2—Floating-Point Load Ln 2The FLDL2E, FLDL2T, FLDLG2, and FLDLN2 instructions, respectively, push the floating-pointconstant value, log2e, log210, log102, and loge2, onto the top-of-stack, ST(0).6.4.4 ArithmeticThe arithmetic instructions support addition, subtraction, multiplication, division, change-sign, round,round to integer, partial remainder, and square root.
In most arithmetic operations, one of the sourceoperands is the top-of-stack, ST(0). The other source operand can be another stack entry, ST(i), or afloating-point or integer operand in memory.The non-commutative operations of subtraction and division have two forms, the direct FSUB andFDIV, and the reverse FSUBR and FDIVR. FSUB, for example, subtracts the right operand from theleft operand, and writes the result to the left operand. FSUBR subtracts the left operand from the rightoperand, and writes the result to the left operand.
The FADD and FMUL operations have no reversecounterparts.Addition• FADD—Floating-Point Add• FADDP—Floating-Point Add and Pop• FIADD—Floating-Point Add Integer to Stack TopThe FADD instruction syntax has forms that include one or two explicit source operands. In the oneoperand form, the instruction reads a 32-bit or 64-bit floating-point value from memory, converts it tothe double-extended-precision format, adds it to ST(0), and writes the result to ST(0). In the twooperand form, the instruction adds both source operands from stack registers and writes the result tothe first operand.The FADDP instruction syntax has forms that include zero or two explicit source operands. In thezero-operand form, the instruction adds ST(0) to ST(1), writes the result to ST(1), and pops the stack.In the two-operand form, the instruction adds both source operands from stack registers, writes theresult to the first operand, and pops the stack.The FIADD instruction reads a 16-bit or 32-bit integer value from memory, converts it to the doubleextended-precision format, adds it to ST(0), and writes the result to ST(0).Subtraction• FSUB—Floating-Point Subtract• FSUBP—Floating-Point Subtract and Pop• FISUB—Floating-Point Integer Subtract• FSUBR—Floating-Point Subtract Reverse• FSUBRP—Floating-Point Subtract Reverse and Popx87 Floating-Point Programming267AMD64 Technology•24592—Rev.
3.13—July 2007FISUBR—Floating-Point Integer Subtract ReverseThe FSUB instruction syntax has forms that include one or two explicit source operands. In the oneoperand form, the instruction reads a 32-bit or 64-bit floating-point value from memory, converts it tothe double-extended-precision format, subtracts it from ST(0), and writes the result to ST(0). In thetwo-operand form, both source operands are located in stack registers. The instruction subtracts thesecond operand from the first operand and writes the result to the first operand.The FSUBP instruction syntax has forms that include zero or two explicit source operands.