logoalt Hacker News

adrian_btoday at 9:49 AM1 replyview on HN

It should be noted that XOR is just (bitwise) subtraction modulo 2.

There are many kinds of SUB instructions in the x86-64 ISA, which do subtraction modulo 2^64, modulo 2^32, modulo 2^16 or modulo 2^8.

To produce a null result, any kind of subtraction can be used, and XOR is just a particular case of subtraction, it is not a different kind of operation.

Unlike for bigger moduli, when operations are done modulo 2 addition and subtraction are the same, so XOR can be used for either addition modulo 2 or subtraction modulo 2.


Replies

gblarggtoday at 12:47 PM

> XOR is just a particular case of subtraction, it is not a different kind of operation.

It's different in that there's no carry propagation.