The Ember CPU — Initial Design Part 2: Registers

Tom Gambill
Project Ember
Published in
13 min readDec 20, 2021

--

Computer Memory
Photo by Michael Dziedzic on Unsplash

Now that we have the basic design philosophy and some fundamental requirements for our new CPU, we should consider the types and number of registers we need. First, let’s look at how registers are used, their benefits, and some limitations due to hardware and instruction architecture.

One of the primary uses of internal registers is to hold values for operations that are being computed or actively worked on. Registers can represent CPU settings, flags used in logic operations, and loop counters so the program knows which item in a loop it is working on, and when to stop the current algorithm.

It is very common to have loops in code that “iterate over” or go to each entry or value in a list and perform some operation. Nearly as common is a 2-dimensional, or double loop, which iterates over two lists or dimensions at the same time. For example, when we want to do something to a 2-dimensional array like an image, we have a number of rows in the image, and then each row has a number of pixels. In this case, we need two “iterators” or index registers, one for X and one for the Y direction. Higher-dimensional arrays are increasingly less common, but still desirable, though one can often split those into smaller arrays if needed.

--

--

Project Ember
Project Ember

Published in Project Ember

The Plan: Design and implement a fully functional “retro” video game console, with a custom CPU, GPU, Audio Processor, and development architecture from scratch. Engineering background, while helpful, is not required to follow along. Please join us!

Tom Gambill
Tom Gambill

Written by Tom Gambill

Software Engineer, Retro Hacker, World Traveler. And also: sailboats, fish tanks, nature, family, startups…

No responses yet