Fresh IDE . file_module_x86_id_222.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_222.html artifact 6d609387c3 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>OUT: Output to Port (x86 Instruction Set Reference)</title>
</head>
<body>
<div class="main_container"><h1>x86 Instruction Set Reference</h1>
<title>OUT: Output to Port (x86 Instruction Set Reference)</title>
<h1>OUT</h1>
<h2>Output to Port</h2>
<object>
<table class="box">
<tr>
<th>Opcode</th>
<th>Mnemonic</th>
<th>Description</th>
</tr>
<tr>
<td class="grid"><code>E6 ib</code></td>
<td class="grid"><code>OUT imm8, AL</code></td>
<td class="grid">Output byte in AL to I/O port address imm8.</td>
</tr>
<tr>
<td class="grid"><code>E7 ib</code></td>
<td class="grid"><code>OUT imm8, AX</code></td>
<td class="grid">Output word in AX to I/O port address imm8.</td>
</tr>
<tr>
<td class="grid"><code>E7 ib</code></td>
<td class="grid"><code>OUT imm8, EAX</code></td>
<td class="grid">Output doubleword in EAX to I/O port address imm8.</td>
</tr>
<tr>
<td class="grid"><code>EE</code></td>
<td class="grid"><code>OUT DX, AL</code></td>
<td class="grid">Output byte in AL to I/O port address in DX.</td>
</tr>
<tr>
<td class="grid"><code>EF</code></td>
<td class="grid"><code>OUT DX, AX</code></td>
<td class="grid">Output word in AX to I/O port address in DX.</td>
</tr>
<tr>
<td class="grid"><code>EF</code></td>
<td class="grid"><code>OUT DX, EAX</code></td>
<td class="grid">Output doubleword in EAX to I/O port address in DX.</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Description</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<p>Copies the value from the second operand (source operand) to the I/O port specified with the destination operand (first operand). The source operand can be register AL, AX, or EAX, depending on the size of the port being accessed (8, 16, or 32 bits, respectively); the destination operand can be a byte-immediate or the DX register. Using a byte immediate allows I/O port addresses 0 to 255 to be accessed; using the DX register as a source operand allows I/O ports from 0 to 65,535 to be accessed.</p>
<p>The size of the I/O port being accessed is determined by the opcode for an 8-bit I/O port or by the operand-size attribute of the instruction for a 16- or 32-bit I/O port.</p>
<p>At the machine code level, I/O instructions are shorter when accessing 8-bit I/O ports. Here, the upper eight bits of the port address will be 0.</p>
<p>This instruction is only useful for accessing I/O ports located in the processor's I/O address space. See Chapter 13, Input/Output, in the IA-32 Intel Architecture Software Developer's Manual, Volume 1, for more information on accessing I/O ports in the I/O address space.</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>PE <span class="operator">==</span> <span class="number">1</span> <span class="operator">&amp;&amp;</span> <span class="operator">(</span>CPL <span class="operator">&gt;</span> IOPL <span class="operator">||</span> VM <span class="operator">==</span> <span class="number">1</span><span class="operator">)</span><span class="operator">)</span> { <span class="comment">//Protected mode with CPL > IOPL or virtual-8086 mode</span>
	<span class="keyword">if</span><span class="operator">(</span><span class="operator">!</span>IOPermission<span class="operator">(</span><span class="operator">)</span><span class="operator">)</span> Exception<span class="operator">(</span>GP<span class="operator">)</span><span class="operator">;</span> <span class="comment">//Any I/O Permission Bit for I/O port being accessed = 1</span>
	<span class="keyword">else</span> Destination <span class="operator">=</span> Source<span class="operator">;</span> <span class="comment">//Writes to selected I/O port</span>
}
<span class="comment">//Real Mode or Protected Mode with CPL <= IOPL</span>
<span class="keyword">else</span> Destination <span class="operator">=</span> Source<span class="operator">;</span> <span class="comment">//Writes to selected I/O port</span>
</pre>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>Flags affected</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<p>None.
</p>
</td>
</tr>
</table>
</object>
<object>
<table class="box">
<tr>
<th>IA-32 Architecture Compatibility</th>
</tr>
<tr>
<td class="instruction_set_reference_box">
<p>After executing an OUT instruction, the Pentium processor insures that the EWBE# pin has been sampled active before it begins to execute the next instruction. (Note that the instruction can be prefetched if EWBE# is not active, but it will not be executed until the EWBE# pin is sampled active.) Only the Pentium processor family has the EWBE# pin; the other IA-32 processors do not.
</p>
</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>#GP(0)</code></td><td>If the CPL is greater than (has less privilege) the I/O privilege level (IOPL) and any of the corresponding I/O permission bits in TSS for the I/O port being accessed is 1.</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">
None.
</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>#GP(0)</code></td><td>If any of the I/O permission bits in the TSS for the I/O port being accessed is 1.</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/069n</td><td class="grid">0F3n/0F2n/069n</td><td class="grid">0F2n</td></tr>
<tr><td class="grid"><code>OUT</code></td><td class="grid">&lt;225</td><td class="grid">40</td><td class="grid">-</td></tr>
</table>
</object>
</div>
</body>
</html>