Skip to content
A CPU emulator which runs machine code. Insprited by the Little Man Computer, hence the name.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.





A very simple CPU emulator written in c++, inspired by LMC for me to learn how a cpu works in more detail.

Current features:

  • Fetch-decode-execute cycle
  • 32-bit architecture (256 CPU instructions, not all implemented)
  • A 16x16 pixels "monitor" with a 12-bit colour depth


Make sure you have:

  • g++
  • cmake
  • sfml (for pixel plotting)
$ git clone
$ mkdir big-boy-computer/build && cd big-boy-computer/build
$ cmake ../src -G "<Insert your favourite Makefiles type here>"
$ make

Overview of the registers

int64_t ac; // Accumulator - stores the result of the last calculation
word_t pc; // Program counter - store address of the next instruction
word_t ir; // Instruction register - stores top 8 bits of instruction
sword_t ar; // Address register - stores bottom 24 bits of instruction

Writing a program in machine code


Currently, to write a program for the big boy computer (bbc), you need to edit an array in main.cpp called program, which holds the instructions. Because of this, every change in the machine code program will mean you need to recompile bbc.


Have a look at INSTRUCTIONS (file) for a comprehensive list of all the CPU instructions along with a synopsis of an instruction.

A program must start with (i.e. the first word of a program in ram must be) a number representing how many pieces of data you want to initialise. The CPU then skips ahead this amount of instructions, assuming that they're pieces of data.


Say you wanted to be able to access a memory address with the value of 10 (an ASCII newline), your program may look like this (base 2, note the padding zeroes are of course optional):

... (rest of program) ...

Or equally (base 16)

... (rest of program) ...

And, annotated:

00000001    # Tell the processor that the next 1 word is data, not an instruction
0000000a    # This address in RAM is now 10
... (rest of program) ...
00000000    # And all programs must end with 0, which is the halt instruction

Writing your program to file

This is very simple:

  • Get a hex editor
  • Literally just type out your program's instructions as hex
You can’t perform that action at this time.