Example Programs for Calcutron-33

This is a follow up story on my story about inventing a RISC CPU called Calcutron-33 which has a decimal based number system rather than a binary number system.

Obviously this has no practical application for actual implementation. Rather the intention here is to come up with a simple model of a CPU, which is easy to teach.

Image for post
Image for post
A diagram of our simple Decimal RISC CPU, showing how data flows to different parts. It is the Decoder which decides what parts are enabled and thus where data can flow in. Decode only knows what to enable by looking at Instruction Register, which contains latest instruction fetched from memory.

The idea here is to play with some example programs which can be useful for a beginner to implement. What I am interested in figuring out, is what a minimal set of features are to be able to do something interesting. Such as how many instructions do we need to support? How many registers do we need at minimum?

Get two inputs, add them together and write them to output

Repeatedly double inputs and write to output.

Take two inputs and reverse their order

Multiply each input by 8. This is the first step to understand how addition can be used for multiplication.

Sometimes you need multiple registers to achieve multipliation

Remove all the zeros. Early way to learn the use of branching

Pick the largest of two numbers

The most primitive form of general multiplier. It picks two numbers at a time, multiplies them and outputs result.

The is program from original story, for how to multiple numbers.

Unlike the simple multiplier above we use a lot fewer iterations by using shifts. This speeds up the multiplication.

Implementation of Calcutron-33

This made up CPU instruction set architecture now has a Julia package, Calcutron33.jl offering an assembler, disassembler and simulator.

It is still in early stages, but several of these example programs should work.

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store