From f186ff2a22459ebf2fd83b63b66370d018dcbbef Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 11 Mar 2023 16:11:24 -0500 Subject: find --- libalee/corewords.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libalee/corewords.cpp') diff --git a/libalee/corewords.cpp b/libalee/corewords.cpp index 1a09936..f22772c 100644 --- a/libalee/corewords.cpp +++ b/libalee/corewords.cpp @@ -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(caddr + 1), + static_cast(caddr + 1 + state.dict.readbyte(caddr)) + }; + find(state, word); + } + break; default: state.push(index - WordCount); break; -- cgit v1.2.3