mu

Reference documentation on available primitives

Data Structures

For memory safety, the following data structures are opaque and only modified using functions described further down. I still find it useful to understand how they work under the hood.

Functions

The most useful functions from 400.mu and later .mu files. Look for definitions (using ctags) to see type signatures.

assertions for tests

predicates

arrays

streams

reading/writing hex representations of integers

printing to screen

pixel-on-real-screen draws a single pixel in one of 256 colors.

All text-mode screen primitives require a screen object, which can be either the real screen on the computer or a fake screen for tests.

The real screen on the Mu computer can currently display only ASCII characters, though it’s easy to import more of the font. There is only one font, and it’s mostly fixed-width, with graphemes being either 8 or 16 pixels wide.

Similar primitives for writing text top-to-bottom, left-to-right.

Screens remember the current cursor position.

Assertions for tests:

events

read-key reads a single key from the keyboard and returns it if it exists. Returns 0 if no key has been pressed.

read-mouse-event returns a recent change in x and y coordinate.

Mu doesn’t currently support interrupt-based mouse events.

persistent storage

load-sector synchronously reads a single sector from a disk of persistent storage. The disk must follow the ATA specification with a 28-bit sector address. Each sector is 512 bytes. Therefore, Mu currently supports ATA hard disks of up to 128GB capacity.

Similarly, store-sector synchronously writes a single sector to disk.

Mu doesn’t currently support asynchronous transfers to or from a disk.