aboutsummaryrefslogtreecommitdiffstats
path: root/libalee/dictionary.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-11-18 08:13:19 -0500
committerClyne Sullivan <clyne@bitgloo.com>2023-11-18 08:13:19 -0500
commit6e4c0430de5ade2c8375ddcdeec93d4df3b163b1 (patch)
tree33886ae29401d4508298c6d63592ccdfb37a0e17 /libalee/dictionary.cpp
parenta3fca07d87a2d057657af9bb79de9f595e4b1a10 (diff)
add _nx word, use for most of core
not seeing performance improvement yet
Diffstat (limited to 'libalee/dictionary.cpp')
-rw-r--r--libalee/dictionary.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libalee/dictionary.cpp b/libalee/dictionary.cpp
index e4f6761..e946c59 100644
--- a/libalee/dictionary.cpp
+++ b/libalee/dictionary.cpp
@@ -29,6 +29,22 @@ void Dictionary::initialize()
}
LIBALEE_SECTION
+void Dictionary::addNativeWord(const char *s, void (*func)(State&))
+{
+ const Addr h = read(Here);
+ Addr n = h + sizeof(Cell);
+ for (; *s; ++s, ++n)
+ writebyte(n, *s);
+ addDefinition(Word(h + sizeof(Cell), n));
+ add(CoreWords::token("_nx"));
+ add((Cell)func);
+
+ const auto dcell = h - latest();
+ write(h, (read(h) & 0x1F) | Native | static_cast<Cell>(dcell << DistancePos));
+ latest(h);
+}
+
+LIBALEE_SECTION
Addr Dictionary::allot(Cell amount) noexcept
{
Addr old = here();