diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-10-26 22:18:54 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-10-26 22:18:54 -0700 |
commit | c3eab11fd159bed340fcd4db0be22cf7d2cba994 (patch) | |
tree | 836aa8b17383d81dbedca62bf95533d9c27c88f6 | |
parent | 33ed713124d75f9945cec007fe3ad269062f0434 (diff) | |
download | mu-c3eab11fd159bed340fcd4db0be22cf7d2cba994.tar.gz |
.
-rw-r--r-- | mu.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/mu.md b/mu.md index e79861ed..4c2f5226 100644 --- a/mu.md +++ b/mu.md @@ -22,23 +22,27 @@ They can take any number of inouts and outputs, including 0. Statements with 0 outputs also drop the `<-`. Inouts can be either variables in memory, variables in registers, or -constants. Outputs are always variables in registers. +literal constants (either integers or string literals that get replaced with +constant addresses). Outputs are always variables in registers. Inouts in memory can be either inputs or outputs (if they're addresses being written to). Hence the name. Primitives usually require their inouts to be in specific combinations of -memory and register. User-defined functions are flexible. +memory and register. They can't handle more than one inout in memory. +User-defined functions are flexible. Primitives can often write to arbitrary output registers. User-defined -functions, however, require rigidly specified output registers. +functions, however, require rigidly specified output registers. Notice how the +definition of `foo` above writes to `eax`. ## Variables, registers and memory -Declare local variables in a function using the `var` keyword. +Declare local variables in a function using the `var` keyword. As shown above, +all variable declarations should specify a type after a `:`. -You can declare local variables in either registers or memory (the stack). So -a `var` statement has two forms: +You can declare local variables in either registers or memory (the _stack_ +segment). So a `var` statement has two forms: - Living in a register, e.g. `var x/eax: int <- copy 0` defines `x` which lives in `eax`. - Living in memory, e.g. `var x: int` defines `x` on the stack. |