]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
packed literals again
authorClyne Sullivan <clyne@bitgloo.com>
Fri, 10 Mar 2023 00:27:47 +0000 (19:27 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Fri, 10 Mar 2023 00:27:47 +0000 (19:27 -0500)
core.fth
libalee/corewords.cpp
libalee/parser.cpp

index c5b80b62ceb9fc49bb2745a4f312268ff3332dce..7807489c55f37b152f12fed7bedcf046ae3338b7 100644 (file)
--- a/core.fth
+++ b/core.fth
 : compile, postpone literal postpone execute ;
 
 : buffer:  create allot ;
-: variable create 1 cells allot ;
+: variable 1 cells buffer: ;
 : constant create , does> @ ;
 : value    constant ;
 : to       ' 4 cells + state @ if postpone literal ['] ! , else ! then ; imm
index 4de94138882d7bc6798156a9a4d420bf425608fe..d981098c6abece4196a979654e502b6c1ba88e3f 100644 (file)
@@ -60,14 +60,14 @@ void CoreWords::run(unsigned int index, State& state)
     DoubleCell dcell;
 
 execute:
-    if (/*(index & 1) == 0 &&*/ index >= WordCount) {
+    if (index >= Dictionary::Begin) {
         // must be calling a defined subroutine
         state.pushr(state.ip);
         state.ip = index;
         return;
-    } else switch (index & 0x1F) {
+    } else switch (index) {
     case 0: // _lit
-        state.push(/*(index & 0xFF00) ? ((Addr)index >> 8u) - 1 :*/ state.beyondip());
+        state.push(state.beyondip());
         break;
     case 1: // drop
         state.pop();
@@ -206,6 +206,9 @@ execute:
     case 31: // _in
         state.input(state);
         break;
+    default:
+        state.push(index - WordCount);
+        break;
     }
 
     state.ip += sizeof(Cell);
index d709d45ad93ca01dffc716816b38f350c2ad64ab..a9c9aaa19c9beb2b7d4af6e9ae1fd3020d7ef0d7 100644 (file)
@@ -111,12 +111,12 @@ int Parser::parseNumber(State& state, Word word)
     if (state.compiling()) {
         auto ins = CoreWords::findi("_lit");
 
-        //if (l >= 0 && l < 0xFF) {
-        //    state.dict.add(ins | ((l + 1) << 8));
-        //} else {
+        if (value >= 0 && value < static_cast<Cell>(Dictionary::Begin - CoreWords::WordCount)) {
+            state.dict.add(value + CoreWords::WordCount);
+        } else {
             state.dict.add(ins);
             state.dict.add(value);
-        //}
+        }
     } else {
         state.push(value);
     }