问题
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?
回答1:
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
andadox
instructions are extensions of theadc
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
andsrc2
plus a carry-in and generate an output sum dest and a carry-out. The difference between these two instructions is thatadcx
uses the CF flag for the carry in and carry out (leaving the OF flag unchanged), whereas theadox
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?
来源:https://stackoverflow.com/questions/45033397/when-to-use-adox-instead-of-adcx