wtf I can't add

This commit is contained in:
Peter Fidelman 2022-05-28 20:50:57 -07:00
parent af8618675b
commit 8d8c886cf4

View file

@ -437,7 +437,7 @@ Address Data stack Return stack
202 [3] [102] 202 [3] [102]
204 [3 4] [102] <--- About to return from subroutine... 204 [3 4] [102] <--- About to return from subroutine...
102 [3 4] [] 102 [3 4] []
104 [5] [] 104 [7] []
``` ```
The return stack is there to make sure that returning from a subroutine The return stack is there to make sure that returning from a subroutine
@ -1044,9 +1044,9 @@ pointing to the previous dictionary entry.
self.dp = here; self.dp = here;
} }
} }
``` ```
Now we can start building the dictionary. Now we can start building the dictionary.
To create our Forth interactive programmming environment, we will start To create our Forth interactive programmming environment, we will start
@ -2291,9 +2291,7 @@ word from name lookups. We will talk more about this later.
// smudge ( -- ) // smudge ( -- )
d.entry(); d.name(6 | 0x80, *b"smu"); let smudge = d.here; d.entry(); d.name(6 | 0x80, *b"smu"); let smudge = d.here;
forth!(word_addr, DUP, LD, Literal(0x0040), OR, SWP, ST, RET); forth!(word_addr, DUP, LD, Literal(0x0040), OR, SWP, ST, RET);
```
```rust
// unsmudge ( -- ) // unsmudge ( -- )
d.entry(); d.name(8 | 0x80, *b"uns"); let unsmudge = d.here; d.entry(); d.name(8 | 0x80, *b"uns"); let unsmudge = d.here;
forth!(word_addr, DUP, LD, Literal(0x0040), INV, AND, SWP, ST, RET); forth!(word_addr, DUP, LD, Literal(0x0040), INV, AND, SWP, ST, RET);
@ -2384,9 +2382,7 @@ up to the programmer.
/* Compile a number */ /* Compile a number */
d.entry(); d.name(3, *b"lit"); let lit = d.here; d.entry(); d.name(3, *b"lit"); let lit = d.here;
forth!(DUP, ADD, Literal(1), ADD, comma, RET); forth!(DUP, ADD, Literal(1), ADD, comma, RET);
```
```rust
// Helper function to compile a number ( n -- n? ) // Helper function to compile a number ( n -- n? )
let try_compile_lit = d.here; let try_compile_lit = d.here;
forth!( forth!(
@ -2641,6 +2637,8 @@ Put a call to the outer interpreter at the CPU's
} }
``` ```
Finally, start the machine.
```rust ```rust
fn main() { fn main() {
/* Create the machine */ /* Create the machine */
@ -2707,4 +2705,3 @@ There is a shell script supplied that will do all of the above for you.
Please read Please read
[frustration.4th](./frustration.4th) [frustration.4th](./frustration.4th)
if you want to learn more about how to use Forth. if you want to learn more about how to use Forth.