Added CMOVE>
authorTim Vaughan <tgvaughan@gmail.com>
Wed, 1 Jun 2016 09:32:48 +0000 (21:32 +1200)
committerTim Vaughan <tgvaughan@gmail.com>
Wed, 1 Jun 2016 09:32:48 +0000 (21:32 +1200)
src/forth.jl
src/lib_5_strings.4th

index c5c7175..5730c38 100644 (file)
@@ -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,
index 99d1d39..9fef145 100644 (file)
@@ -3,6 +3,7 @@
 : CMOVE ( src dest length -- )
 
         DUP 0<= IF
+                DROP DROP DROP
                 EXIT
         THEN
 
         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 )