[net.math] REPOSTING: the Register Exchange pro

grunwald@uiuccsb.UUCP (10/08/83)

#R:sunybcs:-49100:uiuccsb:9700009:000:357
uiuccsb!grunwald    Oct  7 23:20:00 1983

Along a similar line of CDC puzzles: Can you think of a way to save all the
contents of all the registers (A,X and B)? Someone at the U of I did it once
on a bet. It's not easy, and from my understanding, the code to do it is quite
long.

Spoken	: Dirk Grunwald
	  University of Illinois
USENET	: ihnp4 ! uiucdcs ! grunwald
CSNET	: grunwald.uiuc@Rand-Relay

leichter@yale-com.UUCP (Jerry Leichter) (10/09/83)

A REAL CDC 6600 hacker can not only save ALL the A, B and X registers, but
can also RESTORE them all - which, although at first it looks trivial, turns
out to be harder than saving them!  (Just for the challenge of it, I actually
did both at one time...great hacks.)
							-- Jerry

kenner@cmcl2.UUCP (10/09/83)

#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).

ddd@druxj.UUCP (10/10/83)

This is probably not the right place for this but I can't resist.

On a CDC 6000 can you zero out all of memory, RA+2 through the end
of mem., and end with a normal job termination?

(I found a way to do this while perusing the source for SCOPE one time.)

kenner@cmcl2.UUCP (10/23/83)

#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 m&it was called so the register
save routine can be called again).