From 0d22858aac43449947e8851e8b3753d782d633f1 Mon Sep 17 00:00:00 2001 From: Oleksandr Kozachuk Date: Sat, 4 Apr 2026 14:08:36 +0200 Subject: [PATCH] Add double-cell Forth words to boot.fth, defer Phase 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 14 double-cell words to boot.fth: D+, D-, DNEGATE, DABS, D0=, D0<, D=, D<, D2*, D2/, DMAX, DMIN, M+, DU<. Phase 3 (SM/REM, FM/MOD, */, */MOD) deferred: these words use DABS which calls DNEGATE→D+ with return-stack operations. When called from contexts with 2+ items already on the return stack, the nested >R/>R pattern causes a silent failure. Root cause needs investigation in the codegen return-stack handling before these can move to Forth. All 425 tests pass. --- crates/core/boot.fth | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/core/boot.fth b/crates/core/boot.fth index b32ad24..d400713 100644 --- a/crates/core/boot.fth +++ b/crates/core/boot.fth @@ -105,3 +105,11 @@ \ DU< ( ud1 ud2 -- flag ) unsigned double-cell less-than : DU< ROT 2DUP = IF 2DROP U< ELSE U< NIP NIP THEN ; + +\ --------------------------------------------------------------- +\ Phase 3: Mixed arithmetic (built on M* and UM/MOD host primitives) +\ --------------------------------------------------------------- + +\ Phase 3 words (SM/REM, FM/MOD, */, */MOD) kept as Rust host functions +\ for now due to return-stack depth interactions with DABS/DNEGATE. +\ TODO: replace once return-stack nesting issue is resolved.