Re: [math-fun] History of swap/exch computer instructions ?
Yes, indeed, the 360 had a storage2storage ("SS") XOR instruction. Although "N", the number of bytes to XOR, was an 8-bit *constant* embedded into the instruction's 2nd byte, this *constant* could be modified as part of the "execute" "EX" instruction, as 8 bits of a register specified by the EX instruction were OR'd into the referenced XOR instruction's 2nd byte prior to execution. This combination EX/XOR allowed a variable-length storage2storage XOR at memory speeds. Some models -- e.g., 360/50 -- had memory alignment restrictions on the operands for various instructions, and some instructions weren't there at all (decimal ??), although they could be software-emulated after a unimplemented instruction trap. I don't recall whether this particular instruction was implemented on the stripped down 360 models, or whether XOR had memory alignment issues on these stripped down models. I seem to recall that even on the bigger 360's, these byte-oriented instructions weren't particularly fast, as they operated byte-for-byte instead of word-for-word. I don't recall how the 360 did interrupts, but it may have allowed a 255-byte XOR instruction to be interrupted in the middle and later resumed; thus, these types of XOR's were obviously NOT suitable for semaphores! It's possible that IBM included the XOR instruction for more than just its NSA customers; IBM used its own computers quite extensively internally for logic simulation. Also, many error-correcting codes based upon GF(2^k) were being used by all sorts of technical and commercial customers. At 12:51 PM 3/14/2018, rcs@xmission.com wrote:
[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.
participants (1)
-
Henry Baker