git @ Cat's Eye Technologies Maentwrog / 00bb6f7
At least make the tables look readable. I hope. Cat's Eye Technologies 10 years ago
1 changed file(s) with 31 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
3434 Additionally, words (except number words) can take one of a list of
3535 prefixes, changing how the word is executed.
3636
37 ------------ -------------------- ------------- --------------------------------------------------------------------------------------------------------------------
38 **Prefix** **Action** **Example** **Result**
39 `=` Assign to variable `=foo` A value popped from the stack is assigned to the variable *foo*.
40 `@` If `@bye` Pop value, stop the program (see predefined words) if it isn't 0.
41 `[` While `[xyz` Pop value, if it's not 0 execute word *xyz*, then pop another value and do it again; continue until a 0 is popped.
42 `$` Repeat `$.` Pop value, then output that many values from the stack.
43 ------------ -------------------- ------------- --------------------------------------------------------------------------------------------------------------------
37 **Prefix** **Action** **Example** **Result**
38 `=` Assign to variable `=foo` A value popped from the stack is assigned to the variable *foo*.
39 `@` If `@bye` Pop value, stop the program (see predefined words) if it isn't 0.
40 `[` While `[xyz` Pop value, if it's not 0 execute word *xyz*, then pop another value and do it again; continue until a 0 is popped.
41 `$` Repeat `$.` Pop value, then output that many values from the stack.
4442
4543 ### Predefined words
4644
47 -------------------- ------------------ ----------------------------------------------------------------
48 **Word** **Stack effect** **Description**
49 `bye` Stop program immediately.
50 `rem` ... `;` Comment. (Ignore all words between `rem` and `;`.)
51 `:` *word* ... `;` Define a new word.
52 `debug` Turn on debugging (outputs all words executed).
53 `vars` Output a list of currently defined variables and their values.
54 `words` Output a list of currently defined words.
55 `alloc` `n` | `ptr` Allocate memory for *n* C *long*s, returns a pointer.
56 `free` `ptr` | `-` Free memory at pointer.
57 `size` `-` | `n` Push stack size.
58 `dup` `a` | `a a` Duplicate top of stack.
59 `swap` `a b` | `b a` Swap the two topmost stack values.
60 `pop` `a` | `-` Remove top value from stack.
61 `get` `ptr` | `value` Push value at pointer to stack (C `*ptr`).
62 `put` `ptr val` | `-` Store value at pointer (C `*ptr = val`).
63 `rnd` `-` | `n` Push random value.
64 `>` `a b` | `(a>b)` Push 1 if a is greater than b, else 0.
65 `<` `a b` | `(a<b)` Push 1 if a is less than b, else 0.
66 `==` undefined Undefined.
67 `.` `n` | `-` Pop a value, output as integer, adding a newline.
68 `..` `n` | `-` Pop a value, output as an ASCII character.
69 `mod` `a b` | `(a%b)` Modulo.
70 `+` `a b` | `(a+b)` Addition.
71 `-` `a b` | `(a-b)` Subtraction.
72 `*` `a b` | `(a*b)` Multiplication.
73 `/` `a b` | `(a/b)` Division, result is rounded towards 0.
74 -------------------- ------------------ ----------------------------------------------------------------
45 **Word** **Stack effect** **Description**
46 `bye` Stop program immediately.
47 `rem` ... `;` Comment. (Ignore all words between `rem` and `;`.)
48 `:` *word* ... `;` Define a new word.
49 `debug` Turn on debugging (outputs all words executed).
50 `vars` Output a list of currently defined variables and their values.
51 `words` Output a list of currently defined words.
52 `alloc` `n` | `ptr` Allocate memory for *n* C *long*s, returns a pointer.
53 `free` `ptr` | `-` Free memory at pointer.
54 `size` `-` | `n` Push stack size.
55 `dup` `a` | `a a` Duplicate top of stack.
56 `swap` `a b` | `b a` Swap the two topmost stack values.
57 `pop` `a` | `-` Remove top value from stack.
58 `get` `ptr` | `value` Push value at pointer to stack (C `*ptr`).
59 `put` `ptr val` | `-` Store value at pointer (C `*ptr = val`).
60 `rnd` `-` | `n` Push random value.
61 `>` `a b` | `(a>b)` Push 1 if a is greater than b, else 0.
62 `<` `a b` | `(a<b)` Push 1 if a is less than b, else 0.
63 `==` undefined Undefined.
64 `.` `n` | `-` Pop a value, output as integer, adding a newline.
65 `..` `n` | `-` Pop a value, output as an ASCII character.
66 `mod` `a b` | `(a%b)` Modulo.
67 `+` `a b` | `(a+b)` Addition.
68 `-` `a b` | `(a-b)` Subtraction.
69 `*` `a b` | `(a*b)` Multiplication.
70 `/` `a b` | `(a/b)` Division, result is rounded towards 0.
7571
7672