]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
fix if condition on 16-bit cpus
authorClyne Sullivan <clyne@bitgloo.com>
Thu, 2 Nov 2023 12:10:42 +0000 (08:10 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Thu, 2 Nov 2023 12:10:42 +0000 (08:10 -0400)
libalee/corewords.cpp

index 6900b45e9355c58503f9b59b2765a28800c96cf6..8f903e1d6a5bc0bc8fa8b1ebd3b08c52d6708e2c 100644 (file)
@@ -178,14 +178,14 @@ execute:
         state.compiling(false);
 
         cell = state.pop();
-        dcell = (cell - state.dict.latest()) << 6;
-        if (dcell > (((1 << (sizeof(Cell) * 8 - 6)) - 1) << 6)) {
+        dcell = cell - state.dict.latest();
+        if (dcell > (1 << (sizeof(Cell) * 8 - 6)) - 1) {
             state.dict.write(cell,
                 (state.dict.read(cell) & 0x1F) | static_cast<Cell>(((1 << (sizeof(Cell) * 8 - 6)) - 1) << 6));
-            state.dict.write(static_cast<Addr>(cell) + sizeof(Cell), static_cast<Cell>(dcell >> 6));
+            state.dict.write(static_cast<Addr>(cell) + sizeof(Cell), static_cast<Cell>(dcell));
         } else {
             state.dict.write(cell,
-                (state.dict.read(cell) & 0x1F) | static_cast<Cell>(dcell));
+                (state.dict.read(cell) & 0x1F) | static_cast<Cell>(dcell << 6));
         }
         state.dict.latest(cell);
         break;