6

The only difference mentioned in the Intel instruction set reference is the usage of the overflow-flag instead of the carry-flag. When does one use ADOX instead of ADCX to perform an unsigned addition with a carry?

Cody Gray
  • 222,280
  • 47
  • 466
  • 543
J-M. Gorius
  • 586
  • 3
  • 15
  • 1
    Normally you should use `adc` because it's smaller (fewer instruction bytes), and writes all flags (avoiding any partial-flag merging penalties for later instructions on all CPUs). Only use either `adcx` or `adox` if you specifically want their behaviour. – Peter Cordes Mar 10 '18 at 06:26

1 Answers1

9

ADOX can be used when you don't want to overwrite the carry flag, like you've stored something like a rotation out.

However their main usage is to accelerate big-int arithmetics because now you can do two additions with carry in parallel in conjunction with mulx

From Intel's paper New Instructions Support Large Integer Arithmetic

ADCX/ADOX Instructions

The adcx and adox instructions are extensions of the adc instruction, designed to support two separate carry chains. They are defined as:

adcx dest/src1, src2
adox dest/src1, src2

Both instructions compute the sum of src1 and src2 plus a carry-in and generate an output sum dest and a carry-out. The difference between these two instructions is that adcx uses the CF flag for the carry in and carry out (leaving the OF flag unchanged), whereas the adox instruction uses the OF flag for the carry in and carry out (leaving the CF flag unchanged).

Related:

What is the difference between the ADC and ADCX instructions on ia32/ia64?

Community
  • 1
  • 1
phuclv
  • 27,258
  • 11
  • 104
  • 360