7691
This commit is contained in:
parent
74f1512ff1
commit
5268b0e1df
|
@ -131,10 +131,11 @@ $ qemu-system-i386 disk.img
|
||||||
The entire stack shares certain properties and conventions. Programs consist
|
The entire stack shares certain properties and conventions. Programs consist
|
||||||
of functions and functions consist of statements, each performing a single
|
of functions and functions consist of statements, each performing a single
|
||||||
operation. Operands to statements are always variables or constants. You can't
|
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
|
perform `a + b*c` in a single statement; you have to break it up into two.
|
||||||
in memory or in registers. Registers must be explicitly specified. There are
|
Variables can live in memory or in registers. Registers must be explicitly
|
||||||
some shared lexical rules; comments always start with '#', and numbers are
|
specified. There are some shared lexical rules. Comments always start with
|
||||||
always written in hex.
|
'#'. Numbers are always written in hex. Many terms can have context-dependent
|
||||||
|
_metadata_ attached after '/'.
|
||||||
|
|
||||||
Here's an example program in Mu:
|
Here's an example program in Mu:
|
||||||
|
|
||||||
|
|
17
mu.md
17
mu.md
|
@ -59,7 +59,8 @@ fn _name_ _inout_ ... -> _output_ ... {
|
||||||
|
|
||||||
Each function has a header line, and some number of statements, each on a
|
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,
|
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`).
|
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)
|
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
|
always strings in Mu, you'll quickly learn to mentally shorten this type to
|
||||||
"an address to an array of strings".
|
"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
|
||||||
|
|
||||||
Blocks are useful for grouping related statements. They're delimited by `{`
|
Blocks are useful for grouping related statements. They're delimited by `{`
|
||||||
|
|
Loading…
Reference in New Issue