]> git.mdlowis.com Git - projs/onward.git/commitdiff
Added some basic string handling words
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 30 Jan 2015 20:10:48 +0000 (15:10 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 30 Jan 2015 20:10:48 +0000 (15:10 -0500)
source/onward.c
source/onward.ft

index 5f1a2351ae3f891186bd9c369166b957d9852d1c..a4ae923cb14d1706ef577e063793f2eb1c39f6c2 100755 (executable)
@@ -351,12 +351,14 @@ defcode("-!", sub_store, &add_store, 0u) {
 
 /** Fetch a byte from the given location */
 defcode("b@", byte_fetch, &sub_store, 0u) {
-//    onward_aspush( (value_t)*((char*)onward_aspop()) );
+    onward_aspush( (value_t)*((char*)onward_aspop()) );
 }
 
 /** Store a byte in an address at the given location */
 defcode("b!", byte_store, &byte_fetch, 0u) {
-//    *((char*)onward_aspop()) = (char)onward_aspop();
+    char val   = (char)onward_aspop();
+    char* addr = (char*)onward_aspop();
+    *(addr) = val;
 }
 
 /** Copy a block of memory to a new location */
index 98951dcdaebc7f0b18227d2dac18fecc92862de3..b21b43e06045147cfb1468c9d642c4cd2b0a7a20 100644 (file)
@@ -44,8 +44,6 @@
 
 : const word create [compile] literal 0 , ;
 
-: dump word find dumpw ;
-
 \ Stack Manipulation Words
 \ -----------------------------------------------------------------------------
 : nip swap drop ;
     drop               \ drop the depth counter
 ;
 
+\ String Words
+\ -----------------------------------------------------------------------------
+: s" immediate
+    here @
+    here @
+    begin
+    \ while ( key != '"' )
+    key dup 34 <> while
+        over swap b!
+        1 +
+    repeat
+    drop
+    dup 0 b!
+    here over align !
+    drop
+;
+
+: emit+
+    dup b@ dup if
+        emit 1 +
+    else
+        drop
+    then
+;
+
+: semit
+    begin
+    dup b@ dup while
+        emit
+        1 +
+    repeat
+    drop
+;
+
+: sput semit 10 emit ;
+