Blog Posts

2023

Writing a 6502 Emulator, part 2

6 minute read

Published:

Last week, I set up the beginnings of a 6502 emulator, including the core codebase. Unfortunately, a command line application that just runs 6502 assembly code is super hard to debug. The 6502 isn’t equipped with any way to print output by default (unless you’d hook up a 65C22 VIA, but coding that seems tricky), and reading raw bytecode isn’t the easiest thing to do. Other emulators I’ve used (ex. Symon) include a pretty nice GUI to debug applications. I didn’t want to go as far as writing a whole application frontend, but I did think implementing some kind of updated UI would be a great addition for both users and for my personal debugging.

Writing a 6502 Emulator

12 minute read

Published:

I recently watched an awesome video from Computerphile about writing an emulator for the Atari 2600. The 2600 runs off a 6507 processor, which is basically a modified 6502. This got me thinking: how hard would it actually be to write an emulator for a 6502 computer? At this point I’ve already built a computer with one and am close to having a working Forth interpreter–so I’m pretty familiar with how the microprocessor works internally.

6502 FORTH, Part 6: 16-Bit Division

18 minute read

Published:

In my last post, I wrote an algorithm for multiplication. I figured I should at least finish wrapping up the basic arithmetic functions before I go back to writing the main Forth interpreter, so today I’m implementing division.

6502 FORTH, Part 5: Multiplication for Peasants

10 minute read

Published:

It’s been a while since I worked on this project, and I wanted to ease back into it by implementing something auxilliary to get me back into the flow of writing assembly. It turns out the 6502 only has instructions for addition and subtraction, meaning that if you want any higher level arithmetic operations (multiplication, division), they need to be implemented manually. Furthermore, since we’re implementing a 16-bit system, we’ll have to make sure these operations work on 16-bit numbers. This post is going to cover multiplication–I’m still working out the best way to write a division algorithm.

2022

6502 FORTH, Part 4: Basic I/O

14 minute read

Published:

I’ve been posting about creating a Forth interpreter for a 65c02, and at this point I’m pretty close to something that could be tested. However, I still need one more piece of infrastructure before I can begin writing and testing my Forth interpreter: some way to communicate with a user.

6502 FORTH, Part 3: 16 Bit Stack

9 minute read

Published:

In my previous post, I created my first Forth words: next, exit, and dolist. I was about to continue on to creating some simple arithmetic words, but then I realized my program is missing the main data structure of Forth…the internal data stack. This is a 16-bit implementation, so I’ll need a 16-bit stack. This of course is not included in the default 65c02 system, so I had to write one myself.

2022 Holiday Coding Challenge

8 minute read

Published:

One of the programming groups I’m in recently posted a challenge for the holiday season. The task is to print the following ASCII art using whatever language you like:

6502 FORTH, Part 1: Setup

5 minute read

Published:

Now that the hardware for my 65C02 computer is more or less complete, it’s time to start working on the software. I’ve been very interested in the Forth language since discovering it a couple years ago due to its relative simplicity, low size requirements, efficiency, and departure from many conventions seen in other programming languages.

64th02 Computer, Part 2

1 minute read

Published:

I finally got my shipment of resistors and soldering wicks, so it’s time to complete the hardware build for this computer! Unfortunately header pins are numerous, and soldering wicks aren’t quite as effective as I had hoped at removing solder. Fortunately I had plenty of extra parts, and PCBway’s minimum PCB shipment is five boards, so I decided to start over from scratch.

64th02 Computer, Part 1

1 minute read

Published:

I recently built an 8-bit computer on a breadboard using a 6502 microprocessor. The experience was great, but I’ve been dying to migrate this project to an actual PCB so I can play around with it without worrying about breaking it. I’d also like to remove the dependence on a Raspberry Pico, since it feels like cheating to use a device significantly more powerful than a 6502 for a 6502 computer. My end goal is to build a FORTH interpreter from scratch that I can run on this machine. This is the beginning of my 6-FORTH-02 Computer, AKA the 64th02!

Starting a blog!

less than 1 minute read

Published:

I figured it would be fun to keep a record of all the projects I’m working on in a blog format, so I’ve set up the blog page on my website! You’ll be able to access this page at any time by going to ahl27.com/blog!