aboutsummaryrefslogtreecommitdiff
path: root/j1/toolchain/strings.fs
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-06-18 14:38:03 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-06-18 14:38:03 +0200
commitcf01b391440fc9de43597b907acfc22dba1aa15e (patch)
tree5cef95c1fd6556af1f9b67360fdc8f02eaf8e2cd /j1/toolchain/strings.fs
parentb468c5579f42134da43d1dccf828300f5c8fb4c3 (diff)
Add j1
Diffstat (limited to 'j1/toolchain/strings.fs')
m---------j10
-rw-r--r--j1/toolchain/strings.fs25
2 files changed, 25 insertions, 0 deletions
diff --git a/j1 b/j1
deleted file mode 160000
-Subproject 911439641c002a8f7a6e306ce1b1d3fd4b389fd
diff --git a/j1/toolchain/strings.fs b/j1/toolchain/strings.fs
new file mode 100644
index 0000000..cbd9b0e
--- /dev/null
+++ b/j1/toolchain/strings.fs
@@ -0,0 +1,25 @@
+( Strings JCB 11:57 05/18/12)
+
+: >str ( c-addr u -- str ) \ a new u char string from c-addr
+ dup cell+ allocate throw dup >r
+ 2dup ! cell+ \ write size into first cell
+ ( c-addr u saddr )
+ swap cmove r>
+;
+: str@ dup cell+ swap @ ;
+: str! ( str c-addr -- c-addr' ) \ copy str to c-addr
+ >r str@ r>
+ 2dup + >r swap
+ cmove r>
+;
+: +str ( str2 str1 -- str3 )
+ over @ over @ + cell+ allocate throw >r
+ over @ over @ + r@ !
+ r@ cell+ str! str! drop r>
+;
+
+: example
+ s" sailor" >str
+ s" hello" >str
+ +str str@ type
+;