From: Clyne Sullivan Date: Thu, 2 Nov 2023 12:10:42 +0000 (-0400) Subject: fix if condition on 16-bit cpus X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=6dcf780a3b39e54127468af4682b3df480c4bdbd;p=bitgloo%2Falee-forth.git fix if condition on 16-bit cpus --- diff --git a/libalee/corewords.cpp b/libalee/corewords.cpp index 6900b45..8f903e1 100644 --- a/libalee/corewords.cpp +++ b/libalee/corewords.cpp @@ -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(((1 << (sizeof(Cell) * 8 - 6)) - 1) << 6)); - state.dict.write(static_cast(cell) + sizeof(Cell), static_cast(dcell >> 6)); + state.dict.write(static_cast(cell) + sizeof(Cell), static_cast(dcell)); } else { state.dict.write(cell, - (state.dict.read(cell) & 0x1F) | static_cast(dcell)); + (state.dict.read(cell) & 0x1F) | static_cast(dcell << 6)); } state.dict.latest(cell); break;