		    Xmodem Archive by Aaron Levinson

	Awhile ago someone wrote that they would like to see an archive that 
used Xmodem (that is, the built-in Xmodem on the G/GX), not Kermit, and 
someone else posted a program that supposedly should have done just that.  
However, I read the documentation, and it said that it had only been tried on 
an S(X) which seemed rather odd since Xmodem was G(X) only.  It also was over 
1000KB.  I didn't try it out since I didn't think that it was worth it.  The 
program that follows, however, is worth it in my opinion.  It uses Xmodem, 
and is only 27.5 bytes long.  Also, unlike some other backup programs that 
I've seen, it needs no extra memory other than the memory that Xmodem needs 
to work in.  That means that the calculator can be practically full, and the 
program will still work.  While I haven't compared times with a Kermit 
archive, this new archive definitely beats the old by far.  True, the ARCHIVE 
command is only 2.5 bytes long, but if you have ever decompiled it, you soon 
realize that it stretches on forever.  I think that if all of the Externals 
in the command were lined up, they would stretch for a mile or longer.  I 
spent three hours trying to decipher it, and I probably wasn't even a third 
finished before I gave up.

	Well, my version of Archive is pretty easy to use.  Just execute it.  
It doesn't take any arguments.  After it starts (wait about a second), start 
receiving via Xmodem on your computer.  Then your job is hopefully finished.  
However, if for some reason the connection errors and the program stops (from 
the wrong IO setups on the calculator and computer, low battery, etc.), 
you'll might need to do some special maneuvers because if you investigate the 
Home directory, it will appear that there is nothing there.  If you see 
"Backup X" on the stack, restore it, and your memory will return.  If not, 
type #15777h (that is, in Hex mode) and SYSEVAL it.  This creates a null ID.  
Then, EVAL the null ID, and Backup X will appear (I'll discuss this later).  
Restore the backup and fix the problem(s) that caused the error in connection.  
In future additions I may include a program that does all of this for you.

	Since it's such a short program, I'll include the source code here 
and discuss it:

::
HOMEDIR
ID X
PTR 94A4 (HOME>BAK)
NULLID
ROMPTR E8 40 (Xsend without error protection)
PTR 9699 (BAK>HOME)
DROP
;

	I found the two unsupported (they work in both the S and G series) in 
a sorted entries document by Mika Heiskanen.  According to the document, 
SYSEVALing #94A4 without anything on the stack (or rather, it needs no 
arguments) should uproot the Home directory into a backup, which should 
appear on the stack.  However, when I tried this, my stack was empty, and my 
Home directory was gone.  The MEM command, however, still accounted for my 
missing Home directory.  So, I looked in my hidden directory by doing NULLID 
(#15777 SYSEVAL) and evaluating.  Rather than moving to the directory, 
"Backup " appeared on the stack.  It was as if the whole hidden directory 
('') had been transformed from a directory into a single object, the backup.  
For entry 94A4, if you supply an ID, it returns a backup to the stack (i.e. 
Backup ID).  Be careful with the ID, though.  I tried the number "4" as the 
ID name, and it returned a null-named Backup which wasn't useable by RESTORE, 
and I lost my home directory.  Basically, use ID's that you would use to name 
variables and that the calculator would accept.

	PTR 9699 takes the backup of the home directory and converts it back 
to the home directory.  However, it returns one External to the stack.  On 
the S(X), it's address is 738BEh and on the G(X) it's AA...h something or 
other.  I'm not exactly sure of its function, but on the S(X) it lies in the 
section of memory reserved for message, unit, and hash tables, and since the 
home directory has some library characteristics, it may very well be a hash 
table.  On the S(X), executing it only warmstarted the machine (as far as I 
could tell).  I wouldn't recommend executing it.

	You should be able to figure out the rest of the program from these 
notes.  By the way, this program does not touch the ports and does not affect 
them in any way.  I'm working on a total backup program that uses Xmodem, but 
I don't expect that it will be completed as quickly as archive was.

	In creating this program, I would like to thank Mika Heiskanen for 
his excelling document and the creators of <RPL>.

Any comments, questions, or suggestions can be sent to: 
				    aaronl@merle.acns.nwu.edu
				    or
				    caitiff@rci.ripco.com
