Monday, March 12, 2012

Applesoft Lite in EEPROM


Recently I've been playing with the EEPROM on the Replica 1 Multi I/O board. The other day I built my JMON monitor program to run out of it. It just needed to have the link address changed to $A000. It was nice to see that it worked out of ROM without any code changes.

Today I rebuilt the Applesoft Lite BASIC interpreter to run out of the Multi I/O EEPROM socket. I downloaded the source code and just made some changes to a couple of files.

By default it builds at address $E000 so it can replace the the on-board EPROM and includes the Woz monitor at $FE00. I didn't need to include the Woz monitor so I removed it from the list of objects to link. Here is the diff to the Makefile:

% diff Makefile.orig Makefile
4c4
< OBJS    = applesoft-lite.o io.o cffa1.o wozmon.o
---
> OBJS    = applesoft-lite.o io.o cffa1.o

It needs to be linked starting at address $A000 rather than $E000, so I made these changes to
the file replica1.cfg, as well as removing the Woz monitor code:

% diff replica1.cfg.orig replica1.cfg
2,3c2,3
<       BASROM:         start = $E000, size = $1F00, fill = yes, file = %O;
<       MONROM:         start = $FF00, size = $100, fill = yes, file = %O;
---
>       BASROM:         start = $A000, size = $1FFF, fill = yes, file = %O;
> #     MONROM:         start = $FF00, size = $100, fill = yes, file = %O;
8c8
<       MONITOR:        load = MONROM,  type = ro;
---
> #     MONITOR:        load = MONROM,  type = ro;

With that it built and worked like a charm. I can now load Applesoft Lite at any time with an "A000R" command from the Woz monitor.
Applesoft Lite running from EEPROM
The code builds with the CC65 assembler, which I had installed. There is a handy utility in the version of CC65 which has been patched to support the Replica 1. The bintomon program converts a binary file from the CA65 tools to the format that can be loaded by the Woz monitor over a serial port.

I made an enhanced version of this program that adds a few features. Specifically:

  1. You can optionally get the start address from the binary file (which seems to be the case when building a C program but not when building an assembler program).
  2. You can specify the load address on the command line.
  3. You can optionally specify the run address on the command line (when it differs from the load address)
  4. Support for  standard command line option parsing.
  5. A verbose option that displays information about the file.

The command usage is:

bintomon [-v] [-f] [-l LoadAddress] [-r RunAddress] filename

To generate the download file for Applesoft Lite I used:

bintomon -l 0xa000 applesoft-lite.bin >applesoft-lite.txt

In a future blog posting I will talk more about the CC65 assembler package and how to use the accompanying C compiler with the Replica 1.

2 comments:

Corneleous Worthington said...

This is a great right-up, Jeff!

I've been following along, and trying to build Applesoft-lite, to run in address $8000 instead of $E000. I used the same exact steps you used to build your $A000 version. It assembles and links ok, but, it will not run in POM1 A1 emulator.

Is there something I am missing to get it to work with that emulator that you're aware of? Does your $A000 version work in the emulator?
Thanks,
Jason

Corneleous Worthington said...

and by right-up, I mean, write-up! ;-)