Fresh IDE . file_module_x86_id_126.html at [59c17aeab1]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

File doc/x86/html/file_module_x86_id_126.html artifact 83a0f37b50 part of check-in 59c17aeab1


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style/style.css" />
<title>FXCH: Exchange Register Contents (x86 Instruction Set Reference)</title>
</head>
<body>
<div class="main_container"><h1>x86 Instruction Set Reference</h1>
<title>FXCH: Exchange Register Contents (x86 Instruction Set Reference)</title>
<h1>FXCH</h1>
<h2>Exchange Register Contents</h2>
<object>
<table class="box">
<tr>
<th>Opcode</th>
<th>Mnemonic</th>
<th>Description</th>
</tr>
<tr>
<td class="grid"><code>D9 C8+i</code></td>
<td class="grid"><code>FXCH ST(i)</code></td>
<td class="grid">Exchange the contents of ST(0) and ST(i).</td>
</tr>
<tr>
<td class="grid"><code>D9 C9</code></td>
<td class="grid"><code>FXCH</code></td>
<td class="grid">Exchange the contents of ST(0) and ST(1).</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Description</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<p>Exchanges the contents of registers ST(0) and ST(i). If no source operand is specified, the contents of ST(0) and ST(1) are exchanged.</p>
<p>This instruction provides a simple means of moving values in the FPU register stack to the top of the stack [ST(0)], so that they can be operated on by those floating-point instructions that can only operate on values in ST(0). For example, the following instruction sequence takes the square root of the third register from the top of the register stack:</p>
<p>FXCH ST(3);</p>
<p>FSQRT;</p>
<p>FXCH ST(3);</p>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Operation</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<pre><span class="keyword">if</span><span class="operator">(</span>NumberOfOperands <span class="operator">==</span> <span class="number">1</span><span class="operator">)</span> {
	Temporary <span class="operator">=</span> ST<span class="operator">(</span><span class="number">0</span><span class="operator">)</span><span class="operator">;</span>
	ST<span class="operator">(</span><span class="number">0</span><span class="operator">)</span> <span class="operator">=</span> Source<span class="operator">;</span>
	Source <span class="operator">=</span> Temporary<span class="operator">;</span>
}
<span class="keyword">else</span> {
	Temporary <span class="operator">=</span> ST<span class="operator">(</span><span class="number">0</span><span class="operator">)</span><span class="operator">;</span>
	ST<span class="operator">(</span><span class="number">0</span><span class="operator">)</span> <span class="operator">=</span> ST<span class="operator">(</span><span class="number">1</span><span class="operator">)</span><span class="operator">;</span>
	ST<span class="operator">(</span><span class="number">1</span><span class="operator">)</span> <span class="operator">=</span> Temporary<span class="operator">;</span>
}
</pre>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>FPU flags affected</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<p>C1 Set to 0 if stack underflow occurred; otherwise, set to 0.
C0, C2, C3 Undefined.
</p>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Floating-Point Exceptions</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<div>
<table class="operations_table">
<tr><td><code>#IS</code></td><td>Stack underflow occurred.</td></tr>
</table>
</div>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Protected Mode Exceptions</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<div>
<table class="operations_table">
<tr><td><code>#NM</code></td><td>EM or TS in CR0 is set.</td></tr>
</table>
</div>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Real-Address Mode Exceptions</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<div>
<table class="operations_table">
<tr><td><code>#NM</code></td><td>EM or TS in CR0 is set.</td></tr>
</table>
</div>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Virtual-8086 Mode Exceptions</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<div>
<table class="operations_table">
<tr><td><code>#NM</code></td><td>EM or TS in CR0 is set.</td></tr>
</table>
</div>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Instruction</th>
<th>Latency</th>
<th>Throughput</th>
<th>Execution Unit</th>
</tr>
<tr><td class="grid"><code>CPUID</code></td><td class="grid">0F3n/0F2n</td><td class="grid">0F3n/0F2n</td><td class="grid">0F2n</td></tr>
<tr><td class="grid"><code>FXCH</code></td><td class="grid">0</td><td class="grid">1</td><td class="grid">FP_MOVE</td></tr>
</table>
</object>
</div>
</body>
</html>