blob: 972053e21f35495e30f47dc2fba078885793fb8c [file] [log] [blame] [raw]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="style.css" type="text/css" rel="stylesheet">
<title>ADOX — Unsigned Integer Addition of Two Operands with Overflow Flag </title></head>
<body>
<h1>ADOX — Unsigned Integer Addition of Two Operands with Overflow Flag</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/En</th>
<th>64/32bit Mode Support</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>
<p>F3 0F 38 F6 /r</p>
<p>ADOX r32, r/m32</p></td>
<td>RM</td>
<td>V/V</td>
<td>ADX</td>
<td>Unsigned addition of r32 with OF, r/m32 to r32, writes OF.</td></tr>
<tr>
<td>
<p>REX.w + F3 0F 38 F6 /r</p>
<p>ADOX r64, r/m64</p></td>
<td>RM</td>
<td>V/NE</td>
<td>ADX</td>
<td>Unsigned addition of r64 with OF, r/m64 to r64, writes OF.</td></tr></table>
<h3>Instruction Operand Encoding</h3>
<table>
<tr>
<td>Op/En</td>
<td>Operand 1</td>
<td>Operand 2</td>
<td>Operand 3</td>
<td>Operand 4</td></tr>
<tr>
<td>RM</td>
<td>ModRM:reg (r, w)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td>
<td>NA</td></tr></table>
<h2>Description</h2>
<p>Performs an unsigned addition of the destination operand (first operand), the source operand (second operand) and the overflow-flag (OF) and stores the result in the destination operand. The destination operand is a general-purpose register, whereas the source operand can be a general-purpose register or memory location. The state of OF represents a carry from a previous addition. The instruction sets the OF flag with the carry generated by the unsigned addition of the operands.</p>
<p>The ADOX instruction is executed in the context of multi-precision addition, where we add a series of operands with a carry-chain. At the beginning of a chain of additions, we execute an instruction to zero the OF (e.g. XOR).</p>
<p>This instruction is supported in real mode and virtual-8086 mode. The operand size is always 32 bits if not in 64-bit mode.</p>
<p>In 64-bit mode, the default operation size is 32 bits. Using a REX Prefix in the form of REX.R permits access to addi-tional registers (R8-15). Using REX Prefix in the form of REX.W promotes operation to 64-bits.</p>
<p>ADOX executes normally either inside or outside a transaction region.</p>
<p>Note: ADOX defines the CF and OF flags differently than the ADD/ADC instructions as defined in <em>Intel<sup>®</sup> 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A</em>.</p>
<h2>Operation</h2>
<pre>IF OperandSize is 64-bit
THEN OF:DEST[63:0] ← DEST[63:0] + SRC[63:0] + OF;
ELSE OF:DEST[31:0] ← DEST[31:0] + SRC[31:0] + OF;
FI;</pre>
<h2>Flags Affected</h2>
<p>OF is updated based on result. CF, SF, ZF, AF and PF flags are unmodified.</p>
<h2>Intel C/C++ Compiler Intrinsic Equivalent</h2>
<p>unsigned char _addcarryx_u32 (unsigned char c_in, unsigned int src1, unsigned int src2, unsigned int *sum_out);</p>
<p>unsigned char _addcarryx_u64 (unsigned char c_in, unsigned __int64 src1, unsigned __int64 src2, unsigned __int64 *sum_out);</p>
<h2>SIMD Floating-Point Exceptions</h2>
<p>None</p>
<h2>Protected Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#UD</td>
<td>
<p>If the LOCK prefix is used.</p>
<p>If CPUID.(EAX=07H, ECX=0H):EBX.ADX[bit 19] = 0.</p></td></tr>
<tr>
<td>#SS(0)</td>
<td>For an illegal address in the SS segment.</td></tr>
<tr>
<td>#GP(0)</td>
<td>
<p>For an illegal memory operand effective address in the CS, DS, ES, FS or GS segments.</p>
<p>If the DS, ES, FS, or GS register is used to access memory and it contains a null segment selector.</p></td></tr>
<tr>
<td>#PF(fault-code)</td>
<td>For a page fault.</td></tr>
<tr>
<td>#AC(0)</td>
<td>If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.</td></tr></table>
<h2>Real-Address Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#UD</td>
<td>
<p>If the LOCK prefix is used.</p>
<p>If CPUID.(EAX=07H, ECX=0H):EBX.ADX[bit 19] = 0.</p></td></tr>
<tr>
<td>#SS(0)</td>
<td>For an illegal address in the SS segment.</td></tr>
<tr>
<td>#GP(0)</td>
<td>If any part of the operand lies outside the effective address space from 0 to FFFFH.</td></tr></table>
<h2>Virtual-8086 Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#UD</td>
<td>
<p>If the LOCK prefix is used.</p>
<p>If CPUID.(EAX=07H, ECX=0H):EBX.ADX[bit 19] = 0.</p></td></tr>
<tr>
<td>#SS(0)</td>
<td>For an illegal address in the SS segment.</td></tr>
<tr>
<td>#GP(0)</td>
<td>If any part of the operand lies outside the effective address space from 0 to FFFFH.</td></tr>
<tr>
<td>#PF(fault-code)</td>
<td>For a page fault.</td></tr>
<tr>
<td>#AC(0)</td>
<td>If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.</td></tr></table>
<h2>Compatibility Mode Exceptions</h2>
<p>Same exceptions as in protected mode.</p>
<h2>64-Bit Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#UD</td>
<td>
<p>If the LOCK prefix is used.</p>
<p>If CPUID.(EAX=07H, ECX=0H):EBX.ADX[bit 19] = 0.</p></td></tr>
<tr>
<td>#SS(0)</td>
<td>If a memory address referencing the SS segment is in a non-canonical form.</td></tr>
<tr>
<td>#GP(0)</td>
<td>If the memory address is in a non-canonical form.</td></tr>
<tr>
<td>#PF(fault-code)</td>
<td>For a page fault.</td></tr>
<tr>
<td>#AC(0)</td>
<td>If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.</td></tr></table></body></html>