]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
find
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 11 Mar 2023 21:11:24 +0000 (16:11 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 11 Mar 2023 21:11:24 +0000 (16:11 -0500)
README.md
compat.txt
forth/test/core.fr
libalee/corewords.cpp
libalee/corewords.hpp

index d262a87dc4d03c3f4510276459b19ab5fd48e0df..d57ae3a099add1ff25efec5b31182d80961a5157 100644 (file)
--- a/README.md
+++ b/README.md
@@ -20,7 +20,6 @@ Running Alee without `core.fth` or `core-ext.fth` passed as arguments will leave
 * Pictured numeric output conversion (e.g. `<# #>`)
 * Words for unsigned integers: `U. U< UM* UM/MOD`
 * `>NUMBER`
-* `FIND`
 
 **Missing** core extensions:  
 ```
index 890871a44d73d80a567a9296d77ff76dbc4bb02b..2410bd52997e1d6d50db4d53dd1bf27f749f6217 100644 (file)
@@ -78,7 +78,7 @@ yes 6.1.1360 EVALUATE
 yes 6.1.1370 EXECUTE
 yes 6.1.1380 EXIT
 yes 6.1.1540 FILL
-    6.1.1550 FIND
+yes 6.1.1550 FIND
 yes 6.1.1561 FM/MOD
 yes 6.1.1650 HERE
     6.1.1670 HOLD
index 2d8b8e42428298aa1528fe65c67834ba284029f2..d2724e1d81d88889fdd444f56ee93337dae9cb58 100644 (file)
@@ -647,8 +647,8 @@ T{ : GT2 ['] GT1 ; IMMEDIATE -> }T
 T{ GT2 EXECUTE -> 123 }T
 HERE 3 C, CHAR G C, CHAR T C, CHAR 1 C, CONSTANT GT1STRING
 HERE 3 C, CHAR G C, CHAR T C, CHAR 2 C, CONSTANT GT2STRING
-T{ GT1STRING FIND -> ' GT1 -1 }T
-T{ GT2STRING FIND -> ' GT2 1 }T
+T{ GT1STRING FIND -> ' GT1 -1 }T
+T{ GT2STRING FIND -> ' GT2 1 }T
 \ ( HOW TO SEARCH FOR NON-EXISTENT WORD? )
 T{ : GT3 GT2 LITERAL ; -> }T
 T{ GT3 -> ' GT1 }T
index 1a099369baeb55b2c293c4c006e6182318a56e14..f22772cd80d96cfaf5f5371562e2c1b713f6523a 100644 (file)
@@ -39,9 +39,8 @@ void newdef(State& state, Word word)
     dict.addDefinition(word);
     state.push(addr);
 };
-void tick(State& state)
+void find(State& state, Word word)
 {
-    auto word = getword(state);
     if (auto j = state.dict.find(word); j > 0) {
         state.push(state.dict.getexec(j));
         auto imm = state.dict.read(j) & Dictionary::Immediate;
@@ -165,7 +164,7 @@ execute:
         state.compiling(true);
         break;
     case 23: // tick
-        tick(state);
+        find(state, getword(state));
         break;
     case 24: // execute
         index = state.pop();
@@ -213,6 +212,16 @@ execute:
         state.load(st);
         }
         break;
+    case 33: // find
+        {
+        const Addr caddr = state.pop();
+        const Word word {
+            static_cast<Addr>(caddr + 1),
+            static_cast<Addr>(caddr + 1 + state.dict.readbyte(caddr))
+        };
+        find(state, word);
+        }
+        break;
     default:
         state.push(index - WordCount);
         break;
index 5798f598e265a163ece05460ab2f218d8738fd28..684b94b6dbef2c931262908276a1986097f9a3de 100644 (file)
@@ -31,7 +31,7 @@ void user_sys(State&);
 class CoreWords
 {
 public:
-    constexpr static std::size_t WordCount = 33;
+    constexpr static std::size_t WordCount = 34;
     constexpr static int Semicolon = 26;
 
     /**
@@ -53,7 +53,7 @@ public:
         "<\0&\0|\0^\0"
         "<<\0>>\0:\0_'\0execute\0"
         "exit\0;\0_jmp0\0_jmp\0"
-        "depth\0_rdepth\0_in\0_ev\0";
+        "depth\0_rdepth\0_in\0_ev\0find\0";
 };
 
 #endif // ALEEFORTH_COREWORDS_HPP