When I wrote the original serial port adding machine, I just squeezed it into 256 bytes with 1 byte to spare (and that was at address 0177). I was unhappy with the output format, unhappy that a zero addend or total printed as blank rather than 0, and unhappy that it couldn't subtotal like the Victor. I needed more program memory and cajoled Mark to add some ability to read an EEPROM slot using a sysx command. He did way more than that, adding (in the June 2019 version on
Github) a very flexible ability to transfer EEPROM to and from memory, which more than met my original need.
I decided, for my first foray into overlays, to keep it simple and only overlay the lower 128 bytes (actually 124) of memory:
In the main overlay is the end of the main program and all the functions except PUTVALUE (which is the primary function I needed to expand to improve the program).
In the second overlay is the same end of the main program and the PUTVALUE function.
The first overlay (plus the upper 128 bytes containing data, main program, and minor functions) is hard coded to reside in EEPROM slot 0 (which is always 256 bytes).
The second overlay is hard coded to reside in EEPROM slot 2. That slot must be configured to be at least 128 bytes (it's possible but unlikely you've configured it to less than that).
The main program copies the second overlay into the 124 bytes starting at address 4 before calling PUTVALUE, and copies the first overlay back into those bytes after. That gave me a substantial amount of additional memory to expand/improve PUTCHAR, and just enough memory to modify the main program to support a subtotal and loading the overlays. The overlays contain only code and no persistent data, and are thus never copied back to EEPROM.
In the version posted here, the first overlay has 2 spare bytes at 0176 and 0177; and the second overlay has 15 spare bytes from 0161 to 0177.
So how do you run this, you might ask. Here's the rundown:
Make sure you're running the June 2019 version of the µKenbak-1 firmware.
Make sure your EEPROM map is configured such that slot 2 is at least 128 bytes.
Make sure your µKenbak-1 is connected to a terminal emulator at 38400 baud, and is stopped.
Over the serial port, load the first overlay and save it to EEPROM slot 0:
Press and hold button 7, click the SET button, release button 7. Terminal will prompt [0.
From terminal emulator, paste or send the file "AddingMachineV12o1.out".
Terminal should show "len=0x100 chk=0x3E"
If length or checksum is wrong, you may need to configure the terminal emulator for some per-character delay.
Press button 0, then release button 0 (this step is VERY important).
Press and hold button 0, click the STORE button, release button 0. LED 0 will be lit.
Over the serial port, load the second overlay and save it to EEPROM slot 2:
Press and hold button 7, click the SET button, release button 7. Terminal will prompt [0.
From terminal emulator, paste or send the file "AddingMachineV12o2.out".
Terminal should show "len=0x100 chk=0x68". If it doesn't, see above.
Press button 2, then release button 2.
Press and hold button 2, click the STORE button, release button 2. LED 2 will be lit.
From now on (until you store something else in EEPROM slots 0 or 2), to run the serial port adding machine program, simply load and run the program in slot 0:
Press and hold button 0, click the READ button, release button 0.
Click the START button. All 8 LEDs should extinguish.
VERY important: do not press any button 0-7 before or after clicking START.
Now type digits to enter an addend (up to 20 digits), "+" to add it into the sum, "S" to print a subtotal, and "=" to print the total and clear the sum. (While you're typing, the ASCII code for each character you type will appear in the LEDs because the OUTPUT register is being used to store data) That's all there is to it!
I'll be the first to admit that the function PUTVALUE, while not exactly spaghetti code, is not written in the most comprehensible way, and no doubt it can be improved (exercise for the student). I just wanted to have fun playing with the overlay idea, so I didn't take code quality too seriously.