]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
optimize ip incrementation
authorClyne Sullivan <clyne@bitgloo.com>
Sun, 26 Feb 2023 13:37:24 +0000 (08:37 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Sun, 26 Feb 2023 13:37:24 +0000 (08:37 -0500)
corewords.cpp
state.cpp

index 97f53dc669490ba5307848b9a58b5d1f06d616cf..9043dba428060a63b6fdafdfe450f2b174119c15 100644 (file)
@@ -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)
index c27d95b9d68eb29eba60aaf66ee259da45a01a83..8e0f78dbcacc8689ecae74531d3f75b9c0c60865 100644 (file)
--- 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);
             }
         }