diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2023-03-09 19:27:47 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2023-03-09 19:27:47 -0500 |
commit | c5e10679c7e10345e9bf6db4efeda4f5ee7d573c (patch) | |
tree | bc2ca275730568990e0acf25cba360df1b61cd75 | |
parent | 76dfbba52449acb1f4c31eabf42f678060559ec3 (diff) |
packed literals again
-rw-r--r-- | core.fth | 2 | ||||
-rw-r--r-- | libalee/corewords.cpp | 9 | ||||
-rw-r--r-- | libalee/parser.cpp | 8 |
3 files changed, 11 insertions, 8 deletions
@@ -189,7 +189,7 @@ : 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 diff --git a/libalee/corewords.cpp b/libalee/corewords.cpp index 4de9413..d981098 100644 --- a/libalee/corewords.cpp +++ b/libalee/corewords.cpp @@ -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); diff --git a/libalee/parser.cpp b/libalee/parser.cpp index d709d45..a9c9aaa 100644 --- a/libalee/parser.cpp +++ b/libalee/parser.cpp @@ -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); } |