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) diff --git a/state.cpp b/state.cpp index c27d95b..8e0f78d 100644 --- a/state.cpp +++ b/state.cpp @@ -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); } }