aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board-js2x/slof/helper.fs2
-rw-r--r--board-qemu/slof/helper.fs8
-rw-r--r--slof/fs/base.fs5
3 files changed, 7 insertions, 8 deletions
diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
index c522c90..d2f19e6 100644
--- a/board-js2x/slof/helper.fs
+++ b/board-js2x/slof/helper.fs
@@ -11,7 +11,7 @@
\ ****************************************************************************/
: slof-build-id ( -- str len )
- flash-header 10 + a
+ flash-header 10 + dup from-cstring a min
;
: slof-revision s" 001" ;
diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs
index 40d4abc..4b2c1ee 100644
--- a/board-qemu/slof/helper.fs
+++ b/board-qemu/slof/helper.fs
@@ -11,7 +11,7 @@
\ ****************************************************************************/
: slof-build-id ( -- str len )
- flash-header 10 + a
+ flash-header 10 + dup from-cstring a min
;
: slof-revision s" 001" ;
@@ -27,12 +27,6 @@
bdate2human $cat encode-string THEN
;
-\ Fetch C string
-: from-cstring ( addr - len )
- dup dup BEGIN c@ 0 <> WHILE 1 + dup REPEAT
- swap -
-;
-
: invert-region-cs ( addr len cellsize -- )
>r over swap r@ rshift r> swap 1 hv-logical-memop drop
;
diff --git a/slof/fs/base.fs b/slof/fs/base.fs
index 0aca5f5..e2104fb 100644
--- a/slof/fs/base.fs
+++ b/slof/fs/base.fs
@@ -107,6 +107,11 @@ CONSTANT <2constant>
: str= ( str1 len1 str2 len2 -- equal? )
rot over <> IF 3drop false ELSE comp 0= THEN ;
+: from-cstring ( addr - len )
+ dup dup BEGIN c@ 0 <> WHILE 1 + dup REPEAT
+ swap -
+;
+
: test-string ( param len -- true | false )
0 ?DO
dup i + c@ \ Get character / byte at current index