From c3eab11fd159bed340fcd4db0be22cf7d2cba994 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 26 Oct 2021 22:18:54 -0700 Subject: . --- mu.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'mu.md') 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. -- cgit 1.4.1-2-gfad0