Low-level • Educational • Stack-based • ISA Emulator
CESSER (Custom Emulated Stack-based System ExecuteR)
is a 16-bit CPU emulator written in FreePascal, complete with a mini assembler, RAM, stack, and subroutine support.
This project simulates how a real processor works internally — from instruction decoding, register manipulation, stack operations, to program execution.
CESSER is built for learning low-level systems, computer architecture, and emulator design.
✅ 16-bit Virtual CPU
✅ Custom Instruction Set Architecture (ISA)
✅ Built-in Mini Assembler
✅ 4KB RAM Memory
✅ Stack Pointer & Subroutines (CALL / RET)
✅ Conditional Jumps (JZ, JNZ)
✅ Arithmetic Instructions
✅ Interactive CLI Emulator
┌─────────────────────────────┐
│ CESSER CPU │
├──────────────┬──────────────┤
│ Registers │ R0 R1 R2 R3 │
│ │ SP PC STATUS │
├──────────────┴──────────────┤
│ RAM │ 4 KB (Word) │
├─────────────────────────────┤
│ Stack │ Grows Down │
├─────────────────────────────┤
│ ISA │ Custom │
└─────────────────────────────┘
| Instruction | Description |
|---|---|
MOV |
Move data |
ADD |
Addition |
SUB |
Subtraction |
MUL |
Multiplication |
CMP |
Compare values |
LOAD |
Load from memory |
STORE |
Store to memory |
JMP |
Unconditional jump |
JZ |
Jump if zero |
JNZ |
Jump if not zero |
CALL |
Call subroutine |
RET |
Return from subroutine |
PUSH |
Push to stack |
POP |
Pop from stack |
PRINT |
Debug output |
HALT |
Stop execution |
CESSER/
└── PROCESSER/
└── cesser.pas # CPU Emulator + Assembler + VM
Assembly Code
↓
Mini Assembler
↓
Bytecode in RAM
↓
Fetch → Decode → Execute
↓
CPU Registers & Memory Updated
- FreePascal Compiler (FPC)
- Terminal / Command Prompt
fpc cesser.pas./cesser| Command | Description |
|---|---|
load <file> |
Assemble & load program |
run |
Start CPU execution |
reset |
Reset CPU state |
help |
Show help |
quit |
Exit emulator |
; Factorial of 5
MOV R0, 5
MOV R1, 1
CALL 20
JMP 30
20:
CMP R0, 1
JZ 25
MUL R1, R0
SUB R0, 1
JMP 20
25:
RET
30:
PRINT R1
HALTExpected output:
[CPU OUT] R1 = 120
CESSER implements a real stack model:
CALLpushes return address to stackRETpops address back intoPCPUSH/POPmanipulate stack directly
This allows modular programs, loops, and function-like behavior.
By building and using CESSER, you learn:
- How CPUs fetch & execute instructions
- Register-based computation
- Stack memory mechanics
- Assembly-level program flow
- Emulator & VM architecture
- Low-level systems programming
- This project is educational
- Instruction encoding is simplified
- Label handling is minimal
- Designed for clarity, not performance
MIT License — free to use, modify, and learn from.
Developed by norct 👾