News for hackers. Stuff that matters.
Re:Sort an array using only one local variable by userbinator on Sunday April 24, 2016 @12:35AM (#11558564)
There's no memory-to-memory XOR in x86. A XOR swap will need one register, the array address itself will take another, and the "single integer variable" one more. Then you also need the absolute value of the variable; there's another register.

The single-expression abs that you specify needs at least two registers, one to hold the shifted value and one to hold the original one. Two alternatives which do not involve multiplication and are 3 instructions is here:

https://www.strchr.com/optimized_abs_function

There are no comments on this comment yet.