From d74f349e27a1ba20bd549362f95915ee6d2dd9d1 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sat, 8 Jan 2022 10:15:43 -0500 Subject: allow terms to be more complicated --- 04/README.md | 6 ++-- 04/guessing_game | 4 +-- 04/in03 | 104 ++++++++++++++++++++++++++----------------------------- 04/in04 | 7 ++-- 4 files changed, 56 insertions(+), 65 deletions(-) (limited to '04') diff --git a/04/README.md b/04/README.md index b9ee066..68cd81d 100644 --- a/04/README.md +++ b/04/README.md @@ -227,6 +227,9 @@ A *term* is one of: - `{variable name}` - the value of a (local or global) variable - `.{label name}` - the address of a label - `{number}` +- `&{variable}` - address of variable +- `*1{variable}` / `*2{variable}` / `*4{variable}` / `*8{variable}` - dereference 1, 2, 4, or 8 bytes +- `~{term}` - bitwise not An *l-value* is the left-hand side of an assignment expression, and it is one of: @@ -239,9 +242,6 @@ and it is one of: An *r-value* is an expression, which can be more complicated than a term. r-values are one of: - `{term}` -- `&{variable}` - address of variable -- `*1{variable}` / `*2{variable}` / `*4{variable}` / `*8{variable}` - dereference 1, 2, 4, or 8 bytes -- `~{term}` - bitwise not - `{function}({term}, {term}, ...)` - `{term} + {term}` - `{term} - {term}` diff --git a/04/guessing_game b/04/guessing_game index 2c8fea9..5c85252 100644 --- a/04/guessing_game +++ b/04/guessing_game @@ -107,12 +107,10 @@ function stoi function strlen argument s - local c local p p = s :strlen_loop - c = *1p - if c == 0 goto strlen_loop_end + if *1p == 0 goto strlen_loop_end p += 1 goto strlen_loop :strlen_loop_end diff --git a/04/in03 b/04/in03 index 63cbbbc..99b3c6e 100644 --- a/04/in03 +++ b/04/in03 @@ -1238,6 +1238,12 @@ align ?C=D:term_number D='. ?C=D:term_label + D='* + ?C=D:term_dereference + D='& + ?C=D:term_addressof + D='~ + ?C=D:term_bitwise_not D=d58 ?C