diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2023-02-26 08:37:24 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2023-02-26 08:37:24 -0500 |
commit | 42d64c6da242bd100533ab0c31c3835b50fa1b2d (patch) | |
tree | d8cd79a55875b0daee738a99d6fda49401dffb20 | |
parent | 739fce1848538a92f9ae2ca893b65fbd50e6a720 (diff) |
optimize ip incrementation
-rw-r--r-- | corewords.cpp | 10 | ||||
-rw-r--r-- | state.cpp | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/corewords.cpp b/corewords.cpp index 97f53dc..9043dba 100644 --- a/corewords.cpp +++ b/corewords.cpp @@ -60,8 +60,8 @@ execute: default: // must be calling a defined subroutine state.pushr(state.ip); - state.ip = index - sizeof(Cell); - break; + state.ip = index; + return; case 0: // _lit state.push(state.beyondip()); break; @@ -184,8 +184,8 @@ execute: } [[fallthrough]]; case 28: // _jmp - state.ip = state.beyondip() - sizeof(Cell); - break; + state.ip = state.beyondip(); + return; case 29: // depth state.push(state.size()); break; @@ -207,6 +207,8 @@ execute: Dictionary::InputCells - cell)); break; } + + state.ip += sizeof(Cell); } int CoreWords::findi(const char *word) @@ -37,12 +37,12 @@ State::Error State::execute(Addr addr) if (!stat) { if (addr < CoreWords::WordCount) { CoreWords::run(addr, *this); + ip = 0; } else { auto ins = addr; for (;;) { CoreWords::run(ins, *this); - ip += sizeof(Cell); ins = dict.read(ip); } } |