0100 -Milestone 1: a running program

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:

  1. an assembly language program
  2. an assembler
  3. 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:

  1. Write the code, assemble it with the SB Assembler and output a binary 4096 byte file that I could import into the Symon Simulator.
  2. 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.
  3. 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.

Troubleshooting Address Decoding
When wiring your board, it’s a good idea to make sure you’ve got the wires going to the right pins. Preferably as you wrap each one. Here I’m tapping directly into the address bus to test the address decoding via the 74LS138 (bottom left). The smaller chip above it is a 74LS00 I’m using to properly set the timing for write-enable on the SRAM.

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 ///.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s