diff options
Diffstat (limited to 'corewords.cpp')
-rw-r--r-- | corewords.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/corewords.cpp b/corewords.cpp index c0cec48..63ccc7d 100644 --- a/corewords.cpp +++ b/corewords.cpp @@ -49,6 +49,7 @@ void CoreWords::run(unsigned int index, State& state) }; Cell cell; + DoubleCell dcell; switch (index) { default: @@ -79,17 +80,23 @@ void CoreWords::run(unsigned int index, State& state) cell = state.pop(); state.top() -= cell; break; - case 7: // mul + case 7: // mul ( n n -- d ) cell = state.pop(); - state.top() *= cell; + dcell = state.pop() * cell; + state.push(dcell); + state.push(dcell >> (sizeof(Cell) * 8)); break; - case 8: // div + case 8: // div ( d n -- n ) cell = state.pop(); - state.top() /= cell; + dcell = state.pop() << (sizeof(Cell) * 8); + dcell |= state.pop(); + state.push(dcell / cell); break; - case 9: // mod + case 9: // mod ( d n -- n ) cell = state.pop(); - state.top() %= cell; + dcell = state.pop() << (sizeof(Cell) * 8); + dcell |= state.pop(); + state.push(dcell % cell); break; case 10: // peek if (state.pop()) |