From WikiChip
Difference between revisions of "x86/adx"
< x86

(Created page with "The ADX instruction extension contains the instructions * ADCX * ADOX They are similar to the ADC instruction by doing a add with overflow, but * ADCX uses the Carry flag as s...")
 
(Overview: Changed "an register" to "a register"; changed "effecting flags" to "affecting flags.")
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
The ADX instruction extension contains the instructions
+
{{x86 title|ADX}}{{x86 isa main}}
 +
'''ADX''' is an {{x86|extensions|x86 instruction set extension}} that introduced [[arbitrary-precision arithmetic]] operations.
 +
 +
== Overview ==
 +
ADX introduced two new instructions:
 +
 
 
* ADCX
 
* ADCX
 
* ADOX
 
* ADOX
 +
 
They are similar to the ADC instruction by doing a add with overflow, but
 
They are similar to the ADC instruction by doing a add with overflow, but
 +
 
* ADCX uses the Carry flag as source and destination of overflow and leaves the other flags untouched
 
* ADCX uses the Carry flag as source and destination of overflow and leaves the other flags untouched
 
* ADOX uses the Overflow flag as source and destination of overflow and leaves the other flags untouched
 
* ADOX uses the Overflow flag as source and destination of overflow and leaves the other flags untouched
This allowes two parallel addition of multi precision numbers, because both have their separate carry flag.
+
 
 +
This allows two parallel addition of multi-precision numbers because both have their separate carry flag.
  
 
Note:
 
Note:
* To add a constant to an register without effecting flags, you can use the <code>LEA reg, [reg + n]</code> instruction
+
 
<code>
+
* To add a constant to a register without affecting flags, you can use the <code>LEA reg, [reg + n]</code> instruction
 +
 
 +
<source lang=asm>
 
     xor  rax, rax
 
     xor  rax, rax
 
  lbl:
 
  lbl:
Line 21: Line 31:
 
     dec  r14
 
     dec  r14
 
     jnz  lbl
 
     jnz  lbl
</code>
+
</source>

Latest revision as of 11:28, 10 August 2021

ADX is an x86 instruction set extension that introduced arbitrary-precision arithmetic operations.

Overview[edit]

ADX introduced two new instructions:

  • ADCX
  • ADOX

They are similar to the ADC instruction by doing a add with overflow, but

  • ADCX uses the Carry flag as source and destination of overflow and leaves the other flags untouched
  • ADOX uses the Overflow flag as source and destination of overflow and leaves the other flags untouched

This allows two parallel addition of multi-precision numbers because both have their separate carry flag.

Note:

  • To add a constant to a register without affecting flags, you can use the LEA reg, [reg + n] instruction
    xor  rax, rax
 lbl:
    mov  rbx, [r8 + r15]
    adcx rbx, [r9 + r15]
    mov  [r9 + r15], rbx
    mov  rbx, [r10 + r15]
    adox rbx, [r11 + r15]
    mov  [r11 + r15], rbx
    lea  r15, [r15 + 8]
    dec  r14
    jnz  lbl