18: Floating-Point Instructions
- Page ID
- 19980
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
This chapter provides a basic overview for a subset of the x86-64 floating-point instructions. Only the most basic instructions are covered. The text focuses on the x86-64 floating-point operations, which are not the same as the 32-bit floating-point operations. The instructions are presented in the following order:
- Data Movement
- Integer / Floating-point Conversion Instructions
- Arithmetic Instructions
- Floating-point Control Instructions
A complete listing of the instructions covered in this text is located in Appendix B for reference. It should be noted that the floating-point arithmetic operations do not require the use of a specific register and do not change types (sizes). This makes the floating-point instructions easier to use.
- 18.1: Floating-Point Values
- Floating-point values are typically represented as either single precision (32-bits) or double precision (64-bits).
- 18.2: Floating-Point Registers
- There are a set of dedicated registers, referred to as XMM registers, used to support floating-point operations. Floating-point operations must use the floating-point registers. The XMM registers are 128-bits and 256-bits on the later processors. Initially, we will only use the lower 32 or 64-bits.
- 18.3: Data Movement
- Typically, data must be moved into a CPU floating-point register in order to be operated upon. Once the calculations are completed, the result may be copied from the register and placed into a variable. There are a number of simple formulas in the example program that perform these steps. This basic data movement operations are performed with the move instruction.
- 18.4: Integer / Floating-Point Conversion Instructions
- If integer values are required during floating-point calculations, the integers must be converted into floating-point values. If single precision and double precision floating-point values are required for a series of calculations, they must be converted to single or double so that the operations are performed on a consistent size/type.