hn.today

In Rainbows

hitogata.neocities.org38 points10 comments
Screenshot of In Rainbows

Rainbows is a developing specification for adding standard input/output and hardware-like devices to the ok virtual machine. Since ok only evaluates instructions and provides data and return stacks, rainbows assigns special memory addresses to devices so programs can interact with them through ordinary reads and writes. Its implemented RbConsole device exposes stdin, stdout, and argc, plus registers for selecting command-line arguments and reading their characters; out-of-range reads return zero. RbArith adds multiplication, division, and modulo for unsigned integers from one to four bytes, with an error register for division or modulo by zero. RbDisk provides persistent storage through a BlockFile of 1024-byte blocks: programs select a block, read it into a data region, or write that region back.

The remaining device designs are unsettled, and addresses may change. RbDatetime could expose separate date and clock fields or Unix time, but the latter raises issues around 32-bit limits and representing smaller time units. RbScreen poses tradeoffs among color depth, framebuffer size, resolution, resizable windows, and multiple buffering; a 1024-by-600 display with 24-bit color would consume about 1.8 MiB. Other ideas include keyboard and controller input, and a floating-point device. The guiding challenge is to make useful capabilities available without imposing awkward memory layouts or excessive requirements on programs, while potentially supporting a bare-metal system as well as an emulator running under an operating system.

Read on hitogata.neocities.org10 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.