What is Gloria JIT?
Gloria JIT is a low-level programming language and compiler that is part of the ForgeZero ecosystem. It is written in Go and compiles source code directly to x86-64 machine code — no LLVM, no GCC, no Clang in the middle.
The goal is straightforward: give the programmer direct, unmediated control over the machine. No intermediate representation handed off to a third-party backend. No optimizer making decisions you didn't ask for. The compiler emits raw bytes, and those bytes run.
This makes Gloria JIT an interesting project for anyone curious about how compilers actually work, or for developers who want to explore bare-metal programming without the abstraction layers that most toolchains introduce.
v4.4.0 expands the language significantly, adding structured control flow, direct memory and I/O access, and a bare-metal output path for VGA framebuffer writing.
while Loops — Structured Control Flow
Before this release, repeated execution required manual branching. v4.4.0 adds proper while loops.
A loop runs as long as its condition is non-zero. Inside the loop body you can use standard assignment and mutation operators (=, +=, -=), and built-in calls are permitted as well. This is a meaningful step toward the kind of control flow you'd expect from a general-purpose language.
Memory Primitives — peek and poke
Two new built-in functions expose direct memory access:
-
peek(address)— reads a 16-bit value from the given address -
poke(address, value)— writes a 16-bit value to the given address
Both accept either immediate values or runtime variables as arguments.
This is the kind of primitive that exists in very few high-level languages, but is essential for bare-metal work — writing to hardware registers, inspecting memory-mapped I/O, or building your own allocator from scratch. Handle with care.
x86-64 Port I/O
For environments that use port-mapped I/O (common in older PC hardware and embedded x86 systems), two new built-ins are available:
-
in8(port)— reads a single byte from the given I/O port (zero-extended) -
out8(port, value)— writes a byte to the given I/O port
This enables direct hardware interaction at a level that most programming languages simply do not expose.
VGA Framebuffer Output
print(string) now supports a bare-metal execution path that writes directly to the VGA text buffer at memory address 0xB8000.
For context: on x86 PCs, this address is where text-mode video memory lives. Writing bytes there places characters directly on screen — no operating system, no drivers, no system calls involved. This is how early PC software (and modern bootloaders) produce output.
Details of the implementation:
- Default text color is green (
0x0A) - Register
R15is reserved as a cursor offset and is preserved across calls - Escape sequences
\nand\tare resolved at compile time into the appropriate control characters
To support testing without real hardware, two utilities are included: patchVGA() swaps the real framebuffer address for a heap-allocated buffer, and dumpVGA() renders that buffer to stdout via a direct syscall, with zero heap allocations.
Register Constants
To reduce ambiguity in the backend IR and make generated code easier to reason about, named constants have been introduced for all general-purpose x86-64 registers:
regRAX(0), regRCX(1), regRDX(2), regRBX(3),
regRSP(4), regRBP(5), regRSI(6), regRDI(7),
regR8(8) ... regR15(15)
Internal Changes
A few backend improvements shipped alongside the language features:
-
emitLowLevelPrintnow accepts akernelModeflag to switch between syscall-based output and direct VGA writes -
emitPushRegandemitPopRegnow cover the full register set including R8–R15 - New operations:
emitMovMemToReg64,emitMovRegToMem64 -
parseStringLiteralhandles escape sequences at compile time rather than at runtime -
emitBareMetalPrintintroduced for the VGA output path
Where This Is Heading
With v4.4.0, Gloria JIT operates in two modes simultaneously: as a userspace compiler with kernel-aware syscall output, and as a bare-metal code generator capable of running without an operating system underneath it.
The next focus areas are optimization passes and IR stability. If you're interested in how compilers work from the ground up — or in low-level x86 programming without giving up a proper language — this is worth following.
Gloria JIT is part of the ForgeZero project. Follow along on dev.to/alexvoste.
Top comments (0)