[comp.sys.handhelds] CHIP8.MACros, 1/3

SLSW2@cc.usu.edu (Roger Ivie) (09/20/90)

I've had a few requests to post my CHIP8 macros for M80 for the FTP-deprived, 
so I'm doing it. These macros use my very own made up mnemonics to assemble 
CHIP8 code. I'm quite attached to them, so there!

This is a slightly newer version than that available for anonymous FTP
at cc.usu.edu in that (after receiving feedback from Andreas Gustafsson)
I've deleted the second operand to SHL and SHR. As soon as the net.god
returns from vacation, I'll make the updated version available for
anonymous FTP here.

I'm also posting as an example program the source to the infamous "15"
puzzle. As soon as my Unix box gets out of the hands of the local hardware
hacker, I'll post a UUENCODED binary.

Using the macro package is very straightforward. Simply include it in
at the start of your program. It performs a .PHASE 200 so that your 
code is assembled at the proper virtual machine starting location.
Link it into a COM file and download the resulting binary to your
calculator. Voila, executable CHIP8 string.

There is a bit of magic involved in telling L80 not to put an 8080 jump
to the start of the program. Here's how to assemble TEST8:

       A> M80 =TEST8/R
       A> L80 /P:100/D:100,TEST8,TEST8./N/E
		 
This will generate a binary file called TEST8. on drive A. It can be
downloaded via KERMIT as follows:

       A> KERMIT
       <KERMIT signon message here>
       KERMIT-80> SEND TEST8.
		 
Of course, the calculator should be in server mode.

Note that CHIP8 does not generate an HP-48 header specifying that it is
a string. Since the file lacks that header, the calculator doesn't 
understand the file and stores it in a string; this is exactly what we
want.

Once TEST8. is in your calculator, go to the VAR menu and press TEST8
followed by CHIP and, voila, countdown display in the upper left corner.
Nifty, eh?

By the way, European users should note that a '.' is appended to the file
name by CP/M KERMIT. This is not a legal variable name character for
people that have the radix separator set to ','. To rename the variable
to something legal, you'll have to set the radix separator to '.', recall
the variable, and store it under another name.

The CHIP8 macros do not do a whole lot of error checking. They check for
some things that would not cause syntax errors in the macro expansions,
but not everything is checked. I've also not tried the error checking to
make certain it works.

One thing I discovered while writing PUZZLE is that M80 will map strings
separated by a space to separate dummy arguments in the macro call (I've
never done anything this complex with M80 before). Expressions used as 
arguments should be surrounded with angle brackets so that they will be 
shipped as one argument.

Also, negative arguments will be viewed as register numbers by the macros 
unless you remember to specify LOW in front of them to get only the low
byte. You can see a few places in PUZZLE were I've done that.

Sure, they could use a bit of polishing, but they work.

Oh yeah, almost forgot, I'm using a SUBMIT file that looks like this:

M80 =$1
L80 /P:100/D:100,$1,$1./N/E

to do the assembly. It makes it a bit nicer since you don't have to
remember to tell L80 /P:100/D:100 every time you run it.

Well, that's it. Have fun, write lots of games, and post them to 
comp.sys.handhelds so that everyone else can enjoy them too.

Roger Ivie
slsw2@cc.usu.edu
35 South 300 West
Logan, Utah 84321
(801)752-8633
-- 
===============================================================================
Roger Ivie

35 S 300 W
Logan, Ut.  84321
(801) 752-8633
===============================================================================