logo

Understanding CPUs by building one in Kotlin

Posted by bloder |3 hours ago |1 comments

bloder 3 hours ago

In order to understand how CPUs work internally I decided to build a small 16-bit CPU emulator entirely in Kotlin.

It includes:

A custom ISA (RISC/MIPS-inspired) Registers, Stack, Flags Instruction encoding/decoding ALU operations, branching, CALL/RET A simple assembler

I also wrote two detailed blog posts explaining the whole process step-by-step:

Part 1 - Understanding how a CPU works: https://bloder.io/cpu-from-scratch-part-1

Part 2 - Using Kotlin to create a CPU emulator: https://bloder.io/cpu-from-scratch-part-2

And here’s the full source code: https://github.com/bloderxd/kotlin-cpu

Cheers