A pure JavaScript CPU emulator

Articles

Introduction

A CPU is a device which takes instructions from RAM and performs actions based on those instructions.

There are a variety of instructions that a CPU can perform:

* Arithmetic instructions

Implementation

In theory a CPU can be very simple to implement - it is a for loop over a list of instructions and a switch statement to perform the required instruction each time.

There are many complexities which can be added but let's start simple:

function