From af8618675b30a7d81b90e7d5aadea26ea9d4e66a Mon Sep 17 00:00:00 2001 From: Peter Fidelman Date: Sat, 28 May 2022 19:10:57 -0700 Subject: [PATCH] Extra polish --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a05a366..767524c 100644 --- a/README.md +++ b/README.md @@ -773,7 +773,6 @@ Some machines use memory mapped IO where certain memory addresses are routed to hardware devices instead of main memory. This machine already has the full 64K of memory connected so no address space is readily available for hardware devices. - Instead we define a separate input-output space of 65536 possible locations. Each of these possible locations is called an IO "[port](https://en.wikipedia.org/wiki/IO_port)". @@ -788,7 +787,7 @@ transmitter that sends data to a computer terminal, or just an output pin controller that is wired to a light bulb. This is a fake software CPU so I am going to hook it up to -stdin and stdout. +[stdin and stdout](https://en.wikipedia.org/wiki/Standard_streams). ```rust use std::io; @@ -821,7 +820,6 @@ a software emulation. /* Dump CPU status. * Like the front panel with the blinking lights that Chuck * talked about. */ - println!("{:?} {:?}", x.ip, x.dstack); let _ = io::stdout().flush(); } @@ -830,6 +828,8 @@ a software emulation. } ``` +That's all the CPU instructions we'll need. + ```rust ]; ``` @@ -861,7 +861,7 @@ Forth family. If you want to learn how to implement a full featured Forth, please read [Jonesforth](http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth.S), and Brad Rodriguez' series of articles -["Moving Forth"](http://www.bradrodriguez.com/papers/index.html). +"[Moving Forth](http://www.bradrodriguez.com/papers/index.html)". The small Forth I write below will probably help you understand those Forths a little better. @@ -1068,7 +1068,7 @@ fn build_dictionary(c: &mut Core) { let mut d = Dict { dp: 0, /* Nothing in the dictionary yet */ - here: 2, /* Reserve address 0 as an "entry point", i.e. where the + here: 2, /* Reserve address 0 as the "reset vector", i.e. where the CPU will jump to start running Forth. We don't have a Forth interpreter yet so we'll leave address 0 alone for now and start the dictionary at address 2 instead. */ @@ -2633,11 +2633,11 @@ Start out in interpreting mode. d.c.store(state_ptr, 0xffff); ``` -```rust - d.c.store(0, quit); -``` +Put a call to the outer interpreter at the CPU's +[reset vector](https://en.wikipedia.org/wiki/Reset_vector). ```rust + d.c.store(0, quit); } ``` @@ -2649,7 +2649,7 @@ fn main() { /* Put the dictionary into memory */ build_dictionary(&mut c); - /* Run Forth */ + /* Start running the CPU from the reset vector */ c.ip = 0; loop { c.step(); @@ -2704,6 +2704,7 @@ There is a shell script supplied that will do all of the above for you. bash build.sh ``` -Please read frustration.4th if you want to learn more about how to -use Forth. +Please read +[frustration.4th](./frustration.4th) +if you want to learn more about how to use Forth.