Bug Computer

The Bug Computer is a simple, educational computer architecture invented by User:Function call without parameters in 2012.

Naming
The Bug Computer, although it may seem reasonable, was not named after software bugs well-known by all of us, but rather the bug as a metaphor for the program counter originating from primitive educational computer architectures of similar complexity.

Architecture
The Bug Computer reference implementation utilizes a memory consisting of 256 bytes (although it could be extended arbitrarily in other implementations). It also has a (theoretically unbounded) stack which stores nybbles of data.

The system also has two registers, PC and A, and a flag, CF. PC is the program counter and is 8 bits (or different according to the memory size), A is the accumulator (4 bits) and CF is the carry flag.

Instruction set
The instruction set is the following:

Character set
The system does not use the standard hex alphabet (digits 0–9 and letters A–F) and instead defines a character set which is moderately useful in terms of user communication. In accordance with this, the reference interpreter accepts several different keystrokes for each of the values 10–15.

The characters are coded as per the following:

Example program
Bytecode for a cat program on Bug Computer (in hex):

(terminates if a value of 10 (Ah) is received)

Bytecode for a program which adds two numbers and displays the result:

Quirks and bugs
The (reference implementation of the) Bug Computer (although not named after them) has a number of quirks and what some may term “bugs”. I’ve also made a few strange decisions during design, especially because I was 4 years younger then and lacking any formal education on the subject. By the way, I’m now planning to release a similar but more reasonably-designed system which I may call the Feature Computer (pun intended).

For example, a bug is to be found in the jump routine in which jump addresses are off by one, a value of 0 (instead of 1) representing normal program flow.

Also a strange thing that I’ve reserved one opcode of arity 0, FC hex, most probably for an instruction which would have put a random value into A, allowing some nondeterminism in the code.