IKP 2002 – A Minimal C++ CPU
Release Date: April 22, 2026
IKP 2002 is a small experimental CPU written in C++. It was not designed to be perfect or fully accurate, but rather to explore and better understand low-level concepts such as registers, instructions, flags, and basic processor logic.
This project is a handcrafted attempt to simulate how a CPU behaves at a very fundamental level. Instructions are interpreted in real time through a command-line interface, and the syntax was intentionally designed to resemble modern assembly as closely as possible while remaining simple and understandable.
Originally planned as a 2-bit processor, the project evolved into a more flexible experimental system. Instead of forcing strict limitations, the focus shifted toward learning, experimentation, and understanding how everything connects internally.
IKP 2002 was built to:
understand how registers work
see how instructions are parsed and executed
explore ALU-style operations
understand why CPUs need flags
experiment with assembly-like syntax in a controlled environment
This is not a cycle-accurate CPU or a hardware-level emulator. It is a real-time interpreted CPU model, where each instruction is manually entered and executed immediately.
The processor includes 4 general-purpose registers:
AX
BX
CX
DX
All registers are implemented as standard integers (int), meaning the system is not strictly limited to 2-bit values in practice.
The CPU uses 3 main flags:
ZERO → values are equal
GREATER → left value is greater
LESS → left value is smaller
These flags are set after the CMP instruction and are meant to simulate basic decision-making logic.
The CPU starts in a waiting state and requires:
START
to begin execution.
To exit:
>EXIT
Moves a value into a register.
MOV AX 2
MOV BX 7
MOV AX 2 → AX = 2
MOV BX 7 → BX = 7
Note: This version does not support register-to-register moves.
Outputs register values.
PRINT AX
PRINT ALL
PRINT AX → prints AX
PRINT ALL → prints all registers
This is mainly a debugging / inspection tool.
Adds a value or register to another register.
ADD AX, BX
ADD AX, 1
ADD AX, BX → AX = AX + BX
ADD AX, 1 → AX = AX + 1
Subtracts a value or register.
SUB AX, BX
SUB AX, 1
SUB AX, BX → AX = AX - BX
SUB AX, 1 → AX = AX - 1
Increments a register by 1.
INC AX
AX = AX + 1
Decrements a register by 1.
DEC BX
BX = BX - 1
Compares two values and sets flags.
CMP AX, BX
CMP AX, 2
This instruction:
does NOT modify registers
only sets flags
Result logic:
Stops the CPU.
>EXIT
ends execution
prints final state
IKP 2002 was intentionally left imperfect.
It is not a true 2-bit CPU (values are not limited to 0–3)
There is no instruction memory or program counter
Instructions are manually entered (no program execution flow)
Some instruction cases are incomplete or inconsistent
Flags are not initialized before first use
Certain parsing and logic paths may produce unexpected behavior
These limitations are part of the learning process, not flaws to hide.
This CPU was not built to be finished.
It was built to:
explore
break
understand
rebuild better
Instead of endlessly fixing this version, development moved forward into more advanced processor designs inspired by early microprocessors.
Later projects build on the lessons learned here and move toward more capable early-microprocessor-inspired architectures.
IKP 2002 is the first step.
It represents:
the transition from high-level thinking → low-level understanding
the foundation for building more realistic CPUs
the starting point for future, more advanced processor projects
Copyright (c) 2026 Ignas Kutka
You are free to:
use the source code for commercial and non-commercial purposes
modify it partially or fully
rewrite it completely
use parts of the architecture, logic, or ideas in your own projects
You must clearly state that your project uses or is inspired by IKP 2002
Attribution can be placed in comments, documentation, or credits
This license applies to source code only
No compiled .exe files are provided
Some comments in the code are written in Lithuanian
Translation may be required for non-Lithuanian users
Experienced developers will likely understand context without translation
This project is provided as-is, without warranty of any kind.
The author is not responsible for any issues, damages, or misuse.