On 14 Mar 2018 at 13:51, rcs@xmission.com wrote:
This reminds me of another famous swapping hack, often used by bit-bumming assembly language hackers (such as myself)..
A -->XOR--> B // That is, set B = A^B
B -->XOR--> A
A -->XOR--> B
There's a related hack those of us used on machines with more limited instruction sets: load a, xor b, and mask, xor b. which loads the bits in 'b' where there are zeroes in the mask. We iused that a lot on the PDP-1d timesharing system. But most notably, with some addition extended hacking you can use that trick to swap fields between two words. I used that in the IMP code to swap the source IMP address and destination IMP address in setting up the RFNM reply. It was a cute bit of code, because the IMP address was actually 9 bits -- six bits of IMP #, two bits of host and one bit of "fake host" The tricky part is that the fake host bits wasn't contiguous and so it was a cute bit of code to move the fields around all "on the fly", not using an intermediate storage location. I thought it was a beautiful bit of how one could abuse the XOR instruction... nobody else was willing to touch that bit of code... :o) /Bernie\ Bernie Cosell bernie@fantasyfarm.com -- Too many people; too few sheep --