FPU instructions

FPU instructions are executed by the x87 floating-point unit (FPU) and operate on floating point, integer, or binary coded decimal values. These instructions are grouped by their purpose:

  • FPU data transfer instructions
  • FPU basic arithmetic instructions
  • FPU comparison instructions
  • FPU load constant instructions
  • FPU control instructions

Another important aspect of the FPU operation is the fact that, unlike the registers of the processor, floating point registers are organized in the form of a stack. Instructions like fld are used to push the operand onto the top of the stack, instructions like fst are used for reading a value from the top of the stack, and instructions like fstp are used for popping the value from the top of the stack and moving other values toward the top.

The following example shows the calculation of the circumference for a circle with radius of 0.2345:

; This goes in '.text' section
fld [radius] ; Load radius to ST0
; ST0 <== 0.2345
fldpi ; Load PI to ST0
; ST1 <== ST0
; ST0 <== 3.1415926
fmulp ; Multiply (ST0 * ST1) and pop
; ST0 = 0.7367034
fadd st0, st0 ; * 2
; ST0 = 1.4734069
fstp [result] ; Store result
; result <== ST0

; This goes in '.data' section
radius dt 0.2345
result dt 0.0
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset