From: Tim Vaughan Date: Wed, 1 Jun 2016 09:32:48 +0000 (+1200) Subject: Added CMOVE> X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=forth.jl.git;a=commitdiff_plain;h=824a4be938c62e1254237eef0315d9248ab68dc5 Added CMOVE> --- 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 )