From a76977af62010a392c16010c367185e61e856ffe Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 30 Oct 2019 20:04:56 +0100 Subject: mv to docs --- docs/j1/toolchain/strings.fs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/j1/toolchain/strings.fs (limited to 'docs/j1/toolchain/strings.fs') diff --git a/docs/j1/toolchain/strings.fs b/docs/j1/toolchain/strings.fs new file mode 100644 index 0000000..cbd9b0e --- /dev/null +++ b/docs/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 +; -- cgit v1.2.3