[another mailing list flub --Rich] Date: Wed, 14 Mar 2018 15:11:56 -0400 Subject: Re: [math-fun] History of swap/exch computer instructions ? From: wba <wbackerman@gmail.com> To: math-fun@mailman.xmission.com, William Ackerman <wba@alum.mit.edu> This reminds me of another famous swapping hack, often used by bit-bumming assembly language hackers (such as myself). You want to swap two things--memory, register, whatever, and you have XOR instructions. You need to have XOR instructions that go both ways: if swapping a register with memory, you need instructions that can XOR a register out to memory. The 360, and Intel, being monstrously CISC machines, have them. I used this hack many times in my youth. A -->XOR--> B // That is, set B = A^B B -->XOR--> A A -->XOR--> B The 360 had "block XOR" instructions ("XORM"? Can't be bothered to look it up.) You could XOR one long block of memory onto another. So you could use this hack to swap two blocks of memory, without any temporaries. -------- On 03/14/2018 12:05 PM, Adam P. Goucher wrote: Maybe the reason for lacking ROTATEF in modern instruction sets is that the n-ary rotation can be implemented using (n-1) SWAP instructions: rotatef i_1 i_2 i_3 ... i_n <==> swap i_1 i_2 swap i_2 i_3 ... swap i_{n-1} i_n Best wishes, Adam P. Goucher