This commit is contained in:
Kartik Agaram 2021-02-07 09:53:14 -08:00
parent 74f1512ff1
commit 5268b0e1df
2 changed files with 21 additions and 5 deletions

View File

@ -131,10 +131,11 @@ $ qemu-system-i386 disk.img
The entire stack shares certain properties and conventions. Programs consist
of functions and functions consist of statements, each performing a single
operation. Operands to statements are always variables or constants. You can't
say `a + b*c`, you have to break it up into two operations. Variables can live
in memory or in registers. Registers must be explicitly specified. There are
some shared lexical rules; comments always start with '#', and numbers are
always written in hex.
perform `a + b*c` in a single statement; you have to break it up into two.
Variables can live in memory or in registers. Registers must be explicitly
specified. There are some shared lexical rules. Comments always start with
'#'. Numbers are always written in hex. Many terms can have context-dependent
_metadata_ attached after '/'.
Here's an example program in Mu:

17
mu.md
View File

@ -59,7 +59,8 @@ fn _name_ _inout_ ... -> _output_ ... {
Each function has a header line, and some number of statements, each on a
separate line. Headers describe inouts and outputs. Inouts can't be registers,
and outputs _must_ be registers. Outputs can't take names.
and outputs _must_ be registers (specified using metadata after a `/`).
Outputs can't take names.
The above program also demonstrates a function call (to the function `do-add`).
Function calls look the same as primitive statements: they can return (multiple)
@ -98,6 +99,20 @@ addresses to arrays of bytes." Since addresses to arrays of bytes are almost
always strings in Mu, you'll quickly learn to mentally shorten this type to
"an address to an array of strings".
Mu currently has no way to name magic constants. Instead, document integer
literals using metadata after a `/`. For example:
```
var x/eax: int <- copy 3/margin-left
```
Here we use metadata in two ways: to specify a register for the variable `x`
(checked), and to give a name to the constant `3` (unchecked; purely for
documentation).
Variables can't currently accept unchecked metadata for documentation.
(Perhaps this should change.)
## Blocks
Blocks are useful for grouping related statements. They're delimited by `{`