Malbolge is an esoteric language designed to be almost impossible to program — every instruction is encrypted after it runs, opcodes depend on the program counter's position, and the two data operations are deliberately obtuse. This repo takes it all the way from a faithful interpreter to a cooperative RTOS whose tasks are Malbolge programs, running bare-metal on a microcontroller and scrolling text on an LED matrix.
interpreter/ — interpreter + compilers (Python)
malbolge.py— a faithful interpreter, a line-for-line reimplementation of Ben Olmstead's 1998 reference C, validated differentially against that reference (~21k checks: hundreds ofcatinputs + 20k fuzzed programs).text2malbolge.py— a linear text→Malbolge compiler (fast; ASCII scope).text2malbolge_bor.py— a branch-on-read compiler with full arbitrary-byte output: every byte value 0–255 is emittable (verified on the reference C), using a data pointer parked 120 cells ahead of the code so the rotate/crazy operands are freely chosen.cat.mb,hello.mb— a Malbolgecatand "Hello World".tests/— the differential + fuzz + compiler suites.
rtos/ — a Malbolge RTOS for the STM32U585
A from-scratch cooperative real-time kernel where each task is a Malbolge
VM. Because the interpreter is a pure state machine, a task's whole context is
(a, c, d, mem) and the scheduler advances it by a quantum of cycles with no
assembly context-switch. Built for the Arduino UNO Q's STM32U585; the same
kernel/VM/display code runs on the host (rendering the LED matrix as ASCII) and
on the chip, where it drives the on-board 13×8 charlieplexed LED matrix to
scroll "Hello World from Malbolge VM" forever.
cd rtos
make run # host simulation: scheduler + scrolling matrix as terminal ASCII
make arm # -> build/arm/firmware.bin for the STM32U585 (3.8 KB flash, ~125 KB SRAM)- A reference-exact interpreter (so behavior matches real Malbolge).
- Compilers, including one that reaches any byte — needed to generate the text the firmware prints.
- A kernel that schedules interpreter instances as tasks.
- A bare-metal STM32U585 port: default-clock boot, a SysTick-driven
charlieplex scan over
PF0..PF10, and a 5×7-font scroller fed by a Malbolge task's output. Flashed to a real Arduino UNO Q — and it runs.
Original code is Apache-2.0 (see LICENSE). rtos/port/cmsis/ vendors CMSIS
device/core headers from ST and Arm, redistributed under their own permissive
licenses (headers retained in each file) so the firmware builds self-contained.