From a96b5f1dec78e7e03f71d0dfe47e031c2769b050 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 3 May 2020 20:24:54 -0400 Subject: [PATCH] Restore DOES> section in usage guide I removed it because it was redundant with Starting Forth, but I directly reference it in the dictionary, so well... --- blk/003 | 2 +- blk/017 | 16 ++++++++++++++++ blk/040 | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 blk/017 diff --git a/blk/003 b/blk/003 index 54d4869..b8bf848 100644 --- a/blk/003 +++ b/blk/003 @@ -12,5 +12,5 @@ Contents 4 Number literals 6 Compilation vs meta-comp. 8 Interpreter I/O 11 Signed-ness -14 Addressed devices +14 Addressed devices 17 DOES> diff --git a/blk/017 b/blk/017 new file mode 100644 index 0000000..2be2060 --- /dev/null +++ b/blk/017 @@ -0,0 +1,16 @@ +DOES> + +Used inside a colon definition that itself uses CREATE, DOES> +transforms that newly created word into a "does cell", that is, +a regular cell ( when called, puts the cell's addr on PS), but +right after that, it executes words that appear after the +DOES>. + +"does cells" always allocate 4 bytes (2 for the cell, 2 for the +DOES> link) and there is no need for ALLOT in colon definition. + +At compile time, colon definition stops processing words when +reaching the DOES>. + +Example: ": CONSTANT CREATE HERE @ ! DOES> @ ;" + diff --git a/blk/040 b/blk/040 index e116f4a..d7159f0 100644 --- a/blk/040 +++ b/blk/040 @@ -8,7 +8,7 @@ CREATE x -- Create cell named x. Doesn't allocate a PF. COMPILE x -- Meta compiles. See B6. CONSTANT x n -- Creates cell x that when called pushes its value. -DOES> -- See B4. +DOES> -- See B17. IMMED? a -- f Checks whether wordref at a is immediate. IMMEDIATE -- Flag the latest defined word as immediate. LITA n -- Write address n as a literal.