Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The μDewy Subset Programming Language

udewy (μdewy, "micro-dewy") is a strict subset of the Dewy programming language, designed for bootstrapping. It serves as an intermediate step in a trusted computing base, providing a language simple enough to implement in assembly while being expressive enough to write a real compiler.

Key principle: Any well-formed udewy program should compile and behave identically under both the udewy compiler and the full Dewy compiler.

This document serves as the definitive specification for the udewy language. There is no implementation-defined behavior; all semantics are fully specified here.

Quick Start

# Run a udewy program (default x86_64 target)
python -m udewy.p0 udewy/tests/test_hello.udewy

# Compile only (don't run)
python -m udewy.p0 -c udewy/tests/test_hello.udewy

# Target a different backend
# For wasm32, this opens the generated HTML in your browser
python -m udewy.p0 --target wasm32 udewy/tests/test_hello.udewy
python -m udewy.p0 --target riscv udewy/tests/test_hello.udewy
python -m udewy.p0 --target arm udewy/tests/test_hello.udewy

The compiler writes artifacts under __dewycache__/, mirroring the source path relative to the current directory. udewy path/to/main.udewy produces __dewycache__/path/to/main. A path already under __dewycache__/ is not nested again. Sources outside the current directory go under __dewycache__/__external__/<12-hex>/….

NOTE: long-term goals is for the default compile target to match the host machine/OS

Supported Targets

TargetOutputRequirements
x86_64 (default)Linux ELF executableGNU as, ld
wasm32Single HTML with embedded WASMwat2wasm (wabt)
riscvRISC-V 64-bit executableriscv64-linux-gnu toolchain, qemu-riscv64
armAArch64 executableaarch64-linux-gnu toolchain, qemu-aarch64

Hello World

# SYS_WRITE and STDOUT are builtin constants provided by the x86_64 backend
let main = ():>int => {
    let msg:int = "Hello from udewy!\n"
    let len:int = __load__(msg - 8)
    __syscall3__(SYS_WRITE STDOUT msg len)
    return 0
}

Status & Scope

This repo contains a reference implementation of udewy, including a lot of supplimentary features for more pleasant everyday use (e.g. multiple backends, graphics support, float bit helpers, etc). The core trusted computing rung for udewy will likely be a more simplified implementation targeting a single backend (likely risc-v), and skipping most of the other nice-to-have features present in this implementation.