Neamerjell

Building a computer from the chips up using a 6502 microprocessor

One of my goals since I started high school was to fully understand how a computer works. This is a huge and seemingly unattainable goal. However, I have already made great leaps in understanding certain parts when I learned the intimate details about the boot process of a PC while manually installing Arch Linux. Originally, I set out to "roll my own" Linux distro, but with the infinite customizablity of Arch, I was practically able to do so. While researching Arch, I also slid down the rabbit hole of creating an OS from scratch. At the time I didn't understand a whole lot of what I was reading because it was mostly assembly language tutorials.

But I was able to answer one of my long time buring questions: How does a computer know what to do when I first turn it on?

The PC first loads and runs the BIOS / UEFI program, which, when finished, tells the computer to look in a specific place (the first 512 bytes) on a designated drive (first in boot order BIOS setting) to continue executing instructions. This! This is what I was looking for! Okay, so how does it know to execute from the BIOS first?

This was actually answered during my research of the 6502 microprocessor. It is hard wired to look in a specific address location to begin executing instructions. I learned this is called the reset vector. It stands to reason that other processors have a similar design.

My 6502 Computer Design

The design goals I currently have in mind include a PS/2 keyboard interface, a 128x64 graphical LCD display, an SD card reader, and NO Arduino. It makes no sense to use something that is orders of magnitude more powerful to interface with hardware when the 6502 can probably do it on its own. I am, however, using an Arduino Mega to test and debug what I have so far. I found an online Arduino simulator! This streamlined the debugging of my code immensely!

11-19-2023

I cleared a major milestone today! I finished my custom address decoder! After watching Ben Eater's tutorials, I thought that his address decoder wasted a ton of potentially addressable space on I/O. I understand that he was going for simplicity of design, but I came up with a decoder that utilizes even more than he had and I can still access all 32KB of SRAM and all but 48 bytes of the 32KB EEPROM. Those 48 bytes are my I/O: 16 bytes each for the PIA, VIA and ACIA. Address Decoder Schematic I transferred this design to a breadboard and tested it using a program I wrote for the Arduino Mega. Address Decoder Breadboard After testing on the breadboard, I soldered it together using a solderable breadboard. I chose this for simplicity so I don't have to design it twice - once on the breadboard, and again on a custom PCB. This way, I can transfer everything directly over and all the connections stay the same.

So I started testing the soldered version... After I realized I missed one wire connection and made the necessary correction, it took me half an hour to figure out that I had the address bus between the Arduino and my stackable header wired BACKWARDS! I altered my code for the Arduino to include a comment that listed the address bus numbers directly below the pin number assignment. That should save me some headaches later. Once all that was done, it worked just like it did on the breadboard.

This is also a testament to how much my soldering skills have improved. There were no solder bridges or shorts! Everything was in the right place on the first try and, as I mentioned earlier, I only forgot one wire. I was actually surprised at this. It also proves that my method of assembly works; I printed a copy of the breadboard design and soldered one component or connection at a time, crossing off each one as I went. I plan on using this method for each subsequent module.