Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use ADOX instead of ADCX?

Tags:

x86

assembly

adx

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?

like image 387
J-M. Gorius Avatar asked Jul 11 '17 11:07

J-M. Gorius


Video Answer


1 Answers

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?

like image 62
phuclv Avatar answered Sep 20 '22 11:09

phuclv