FXCH Exchange register contents Exceptions: I
C3 C2 C1 C0: ? ? 0 ?
FXCH [destination]
; FXCH ; FXCH dest
Logic temp ← ST(1) temp ← ST(i)
ST(1) ← ST ST(i) ← ST
ST ← temp ST ← temp
FXCH swaps the contents of the destination and stack-top registers.
If no destination is specified, ST is exchanged with ST(1).
Note
Many FPU instructions operate only on ST. FXCH provides a handy way
to operate on lower stack elements.
Example
; compute SQRT of ST(4)
fxch ST(4)
fsqrt
fxch ST(4)
Opcode Format
D9 C8 + i FXCH ST(i)
D9 C9 FXCH
Timing
Operand 8087 287 387 486 Pentium
- 10-15 10-15 18 4 0-1 *
* FCXH is pairable in the V pipe with all FX pairable instructions