Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site cmcl2.UUCP Path: utzoo!linus!decvax!harpo!floyd!cmcl2!kenner From: kenner@cmcl2.UUCP Newsgroups: net.math Subject: Re: REPOSTING: the Register Exchange pro - (nf) Message-ID: <33778@cmcl2.UUCP> Date: Sun, 9-Oct-83 12:57:30 EDT Article-I.D.: cmcl2.33778 Posted: Sun Oct 9 12:57:30 1983 Date-Received: Mon, 10-Oct-83 08:42:33 EDT Sender: kenner@cmcl2.UUCP Organization: New York University Lines: 24 #R:sunybcs:-49100:cmcl2:27800001:000:1123 cmcl2!kenner Oct 9 12:57:00 1983 This is actually another piece of CDC folklore. It was discovered by Jack Schwartz at NYU very early on in the life of the machine (it was likely also independantly discovered by others). In hindsight, it's rather simple, though the code is indeed long. Clearly, once you have saved the value of A6 (or A7), you are done. The trick is how to save that register. If you think carefully, you will see that there is only one other instruction than the SA6 instructions which modifies memory -- the return jump instruction! So the code goes as follows: Pick a B register, say B1. If the high bit of B1 is set, do an RJ to a subroutine which simply returns. Otherwise, skip the RJ. Then rotate B1 left one bit (by adding it to itself), test, and, if the sign bit is on, RJ to another similar subroutine. In this manner, all 18 bits of B1 can be tested. Next, simply copy A6 to B1. Then save all the other registers. Finally, reconstruct the contents of B1 by seeing which "subroutines" had their entry word changed (and re-zero that entry word if it was called so the register save routine can be called again).