diff --git a/crates/core/boot.fth b/crates/core/boot.fth index 34a9f3f..6e10977 100644 --- a/crates/core/boot.fth +++ b/crates/core/boot.fth @@ -118,7 +118,8 @@ : M+ S>D D+ ; \ DU< ( ud1 ud2 -- flag ) unsigned double-cell less-than -: DU< ROT 2DUP = IF 2DROP U< ELSE U< NIP NIP THEN ; +\ Compare high cells (unsigned); if equal, compare low cells unsigned. +: DU< ROT 2DUP = IF 2DROP U< ELSE SWAP U< NIP NIP THEN ; \ --------------------------------------------------------------- \ Phase 3: Mixed arithmetic (built on M* and UM/MOD host primitives) diff --git a/crates/core/src/outer.rs b/crates/core/src/outer.rs index 33eb3be..4128808 100644 --- a/crates/core/src/outer.rs +++ b/crates/core/src/outer.rs @@ -4264,6 +4264,34 @@ impl ForthVM { self.register_host_primitive("CREATE", false, func)?; } + // 2CONSTANT: sets pending_define to 9 + { + let pending = Arc::clone(&self.pending_define); + let func = Func::new( + &mut self.store, + FuncType::new(&self.engine, [], []), + move |_caller, _params, _results| { + *pending.lock().unwrap() = 9; + Ok(()) + }, + ); + self.register_host_primitive("2CONSTANT", false, func)?; + } + + // 2VARIABLE: sets pending_define to 10 + { + let pending = Arc::clone(&self.pending_define); + let func = Func::new( + &mut self.store, + FuncType::new(&self.engine, [], []), + move |_caller, _params, _results| { + *pending.lock().unwrap() = 10; + Ok(()) + }, + ); + self.register_host_primitive("2VARIABLE", false, func)?; + } + Ok(()) } @@ -4422,6 +4450,8 @@ impl ForthVM { 6 => self.interpret_find(), 7 => self.interpret_parse(), 8 => self.interpret_parse_name(), + 9 => self.define_2constant(), + 10 => self.define_2variable(), _ => Ok(()), } }