From 824a4be938c62e1254237eef0315d9248ab68dc5 Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Wed, 1 Jun 2016 21:32:48 +1200 Subject: [PATCH] Added CMOVE> --- src/forth.jl | 2 +- src/lib_5_strings.4th | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/forth.jl b/src/forth.jl index c5c7175..5730c38 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -899,7 +899,7 @@ DOES_HELPER_CFA = defPrimWord("(DOES>)", () -> begin end)), name="doesPrim") return NEXT -end, flags=F_IMMED) +end, flags=F_IMMED | F_HIDDEN) DOES_CFA = defWord("DOES>", [LIT_CFA, LIT_CFA, COMMA_CFA, HERE_CFA, LIT_CFA, 3, ADD_CFA, COMMA_CFA, diff --git a/src/lib_5_strings.4th b/src/lib_5_strings.4th index 99d1d39..9fef145 100644 --- a/src/lib_5_strings.4th +++ b/src/lib_5_strings.4th @@ -3,6 +3,7 @@ : CMOVE ( src dest length -- ) DUP 0<= IF + DROP DROP DROP EXIT THEN @@ -18,6 +19,24 @@ DROP ; +: CMOVE> ( src dest length -- ) + DUP 0<= IF + DROP DROP DROP + EXIT + THEN + + -ROT OVER - ( length src (dest-src) ) + -ROT DUP ROT + 1- ( (dest-src) src (src+length-1) ) + + DO + I @ + OVER I + + ! + -1 +LOOP + + DROP +; + : S" IMMEDIATE ( -- addr len ) STATE @ IF ( compiling? ) ['] LITSTRING , ( compile LITSTRING ) -- 2.20.1