Projects

ProxOS

A bytecode VM, an assembler for its own assembly language, and the start of a kernel, written in C and C++ without AI.


What it does

  • PrASM, a small assembly language, and an assembler that turns it into PRX bytecode.
  • A VM that runs PRX programs, with stack frames, label branching, and a heap.
  • A prox CLI that runs either one from macOS, Linux, or Windows.
  • A freestanding aarch64 kernel image that boots on QEMU. Its subsystems are still stubs.
examples/hello.prasm
; prints hi and a newline
SET R0 104
PRC R0
SET R0 105
PRC R0
SET R0 10
PRC R0

Technical details

Every instruction is at least two integers wide. Two-argument operators carry a 0x80 flag on top of their base opcode, so the decoder reads an instruction’s width from the opcode instead of a table.

Each stack frame has ten registers and a return register. CAL pushes a frame and copies the current registers into it, which is how arguments get passed.

The heap is 1,024 integers with a first-fit allocator. When a request doesn’t fit, it compacts and retries once. Compaction moves live chunks, so each register carries an is_ref flag and the compactor rewrites the ones that point into the heap.

Built with CMake, with two CTest suites. Host-only targets switch off automatically when cross-compiling the kernel.

Architecture
           PrASM SOURCE  (.prasm)
                  │
                  ▼
             ASSEMBLER            near 1:1 translation
                  │
                  ▼
           PRX BYTECODE  (.prx)   4-int magic + label count
                  │
                  ▼
              PROX VM
                  │
     ┌────────────┼────────────┐
     ▼            ▼            ▼
  STACK       REGISTERS      HEAP
  frames      10 + return    1024 ints
$ prox asm demo.prasm
$ xxd out.prx | head -2
00000000: 5000 0000 5200 0000 4f00 0000 5800 0000  P...R...O...X...
00000010: 0400 0000 8100 0000 0000 0000 5000 0000  ............P...
$ prox vm out.prx
PROX
5 4 3 2 1
42
Hi!
The header is the four-int PROX magic and a label count of 4. The next instruction starts with 0x81: SET (0x01) with the two-argument flag.