Today marks the completion of my first milestone: running a program in ROM and keyboard input/ display output through the ACIA to USB-serial bridge. A happy day to say the very least. Another “Hello World” of a fully-functioning computer.
Once wire wrap was completed (and failed, then troubleshot, rewrapped, repeat…), I began the task of writing and loading a simple program into the EEPROM. This required three things:
- an assembly language program
- an assembler
- an eprom programmer
As I have not yet learned 6502 assembly, I researched various project sites for code related to simple output to a 6551. I found many different code samples, most notably from Paul Dourish’s 6502Mite Monitor. Fortunately, his GitHub repository contains multiple revisions of his monitor program, showing the evolution of the features he implements in his own 6502-based project.
Knowing enough about procedural programming, I was able to work out the necessary pieces to print a simple repeating, “Hello World” through the serial interface to my laptop running putty (a terminal program). Soon after, I completed a program that basically displayed the input typed into the serial terminal going through the ACIA.
The ACIA is a serial device intended to work with the RS-232 protocol. Since I intended to go from my board (5v TTL) into the USB jack of my laptop (also 5v), I knew I could forego the required 5v/12v conversion used by traditional RS-232 connections. Again, this is where my Arduino could step in. By permanently jumpering it’s reset pin to ground and connect the TX, RX and GRD from the ACIA into the respective pins on the Arduino, I could have a direct serial link into my laptop. The next step was to find an assembler.
There are many assemblers out there to choose from. Most in the 6502 world are familiar with cc65, a suite of assembler tools for assembling C code into native 6502 binary. However, I was not able to get it to work properly, mainly due to my lack of knowledge and the (in my opinion) lack of adequate examples in the documentation.
At one point, I even tried using Merlin on an Apple II. Merlin is a great assembler, but at that time, I wasn’t able to work out how to assemble HEX code that could be burned read by my EPROM burner, and shifting the addresses to account for the difference in memory space. More on this later.
I finally arrived at SB Projects and the SB Assembler. This assembler was just the right fit for me. It had thorough documentation with enough examples for me to properly figure out how to format my assembly code and export both a binary file and a HEX dump for burning into my EPROM. The directives it uses strays somewhat from traditional assembler directives, but it was fairly simple to learn them and know how to translate. The SB Projects site is a wealth of information for interesting electronics projects, including an EPROM emulator which I may implement down the road.
My code editor of choice became Notepad++ with a 6502 template for code highlighting.
One tool that has become indispensable in troubleshooting my assembly code is the Java-based Symon 6502 Simulator. There are several 6502 emulators and simulators out there, but the Symon Simulator has the distinction of built-in ACIA capability as well as simulated screen-to-memory mapping. So I could test my code against it to ensure my code would work on real hardware. The source code is also provided, so I was able to modify the memory mapping to match my hardware.
The third item was an EPROM burner. I knew from the start I wanted to use my Arduino Mega. I wrote a simple EEPROM writer and reader sketch, whereby I could feed a properly formatted 4k HEX dump of my program into an array from which the sketch would read and burn to the EPROM.
So my workflow involves:
- Write the code, assemble it with the SB Assembler and output a binary 4096 byte file that I could import into the Symon Simulator.
- Once my code was working, I would use the SB Assembler to output a HEX dump which I would convert to a comma-delimited text string and copy/paste into my Arduino sketch.
- Use the Arduino to burn the EPROM for testing on the hardware.
I’m leaving out a lot of trial-and-error as well as sweat and tears. After countless failures of seemingly working code on my hardware, I re-wired the entire board, only to find out the ACIA 6551 chip I was using was bad. After replacing it with another one, it worked like a charm.
Now that I have working hardware, I will dive more into 6502 assembly to make sure I can test each component of my version 1 board. The next hardware step will be simple B&W video out and keyboard in. Essentially, a glorified TV Typewriter.
BTW, I figured I would need to name this computer something from “my homebrew Apple /// non-clone”. Since Dr. Sander codenamed the Apple /// “SARA” after one of his daughters, I thought it appropriate to do the same. So now, mine is officially the Abbie ///.