HeadlinesBriefing favicon HeadlinesBriefing.com

MOS 6502 CPU Emulated Entirely in PostgreSQL

Hacker News •
×

Developers have pushed the boundaries of database utility with pg_6502, an implementation of the classic MOS Technology 6502 8-bit microprocessor written purely in SQL, leveraging PostgreSQL.

This unusual architecture maps core CPU components—registers, flags, and the entire 64KB address space—directly into PostgreSQL database tables. Every single opcode execution is then handled by a corresponding stored procedure, forcing the relational engine to act as an instruction processor.

Running this custom CPU requires PostgreSQL 16 or newer, suggesting reliance on recent features for performance or syntax. The project includes tooling via Docker Compose for setup and uses the Klaus 6502 functional test suite for verification, ensuring correctness.

Storing system state within a transactional database engine offers interesting implications for debugging and state persistence, effectively turning data storage into execution logic. The MIT License makes this an open exploration into unusual computational modeling.