Skip to main content

Introduction

The Hybrix system features a custom central processing unit (CPU) called Chombit. It is not a physical electronic chip. Instead, your web browser emulates the CPU as part of the virtual computer simulation.

Unlike an interpreted bytecode or intermediate language approach, Chombit's design captures many important aspects of a realistic CPU:

  • Chombit instructions are primitive CPU register operations, not high-level actions.
  • Each instruction has an explicitly defined timing, measured in virtual clock cycles.
  • The virtual machine features a flat, byte-addressable 32-bit linear address space with distinct RAM, ROM, and I/O memory segments. (The garbage collector is part of the program, not a service of the emulator.)
  • All device interactions use memory-mapped input/output (MMIO), without any "magic" communication with the emulator.
  • Realistic CPU flags track arithmetic results and control execution flow.
  • Traps and faults are modeled as low-level CPU events.
  • The design emphasizes integer and fixed-point algorithms, with signed and unsigned 8-bit, 16-bit, and 32-bit registers supporting add-with-carry and subtract-with-carry for multi-precision arithmetic.
  • Floating point is available as an optional add-on, using single-precision IEEE 754 to encourage reasoning about how to manage precision loss.

Chombit's architecture incorporates many features designed specifically to facilitate education:

  • Framed registers simplify register allocation, making assembly language coding significantly more approachable.
  • Hardware MMIO relies heavily on asynchronous queues, allowing precise multimedia experiences without need for multithreading, hardware interrupts, or cycle-accurate timing.
  • There are only 25 instructions to learn, with only 20 of them being commonly used in beginner programs.
  • Each instruction has many variable-length encodings (over 200 opcodes total), allowing natural coding patterns and compact binaries.
  • The machine language is human-friendly: each instruction form is encoded as a single opcode byte. Each operand (register or literal value) is encoded in its own operand byte.
  • Instructions range from 1 to 5 bytes in length, with the instruction size conveniently represented in the top two bits of the opcode byte for easy decoding and iteration.
  • Chombit provides two hardware stacks: a conventional SP stack managed by the SP register, as well as a special GP stack managed by the GP register. The GP stack simplifies the garbage collector implementation.
  • Memory addresses are freely accessible at any byte offset, without worrying about alignment.
  • There is no pipelining or branch prediction, making performance fully deterministic. Algorithms can be optimized by manually counting clock cycles.