<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Utilities</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>Recent changes to Utilities</description><atom:link href="https://sourceforge.net/p/flashforth/wiki/Utilities/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 07 Jan 2015 07:01:36 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/flashforth/wiki/Utilities/feed" rel="self" type="application/rss+xml"/><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -8,7 +8,7 @@
 \ www.moonvalleycircuits.com
 \ ************************************************

-fl+ empty   \ allow flash writes
+fl+   \ allow flash writes
 decimal
 utilwords
 marker utilwords
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 07:01:36 -0000</pubDate><guid>https://sourceforge.net5e3f7b0914d612086c924cb51f56ab0b03b42a47</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v6
+++ v7
@@ -102,17 +102,17 @@
 : &amp;gt;&amp;lt; ( n --- n | byte-swap 16 bitt number)
   split swap combine ;

-\ : &amp;gt;w@&amp;lt; ( addr -- n | sign-extended fetch)
-\   w@ dup 7fff &amp;gt; if ffff0000 + then ;
+: &amp;gt;w@&amp;lt; ( addr -- n | sign-extended fetch)
+  w@ dup 7fff &amp;gt; if ffff0000 + then ;

-\ : wconvert ( addr --- | flips word at addr)
-\   dup w@ &amp;gt;&amp;lt; swap w! ;
+: wconvert ( addr --- | flips word at addr)
+  dup w@ &amp;gt;&amp;lt; swap w! ;
 decimal

-\ : u- ( u1, u2 --- u | u1-u2 )
-\  dup 0&amp;lt; 2 pick 0&amp;lt; not and if swap then - ;
-\ swap if u2 is negative but u1 is not
-\ : u-  - ;
+: u- ( u1, u2 --- u | u1-u2 )
+ dup 0&amp;lt; 2 pick 0&amp;lt; not and if swap then - ;
+ swap if u2 is negative but u1 is not
+: u-  - ;

 : -dump ( addr -- )   \ dump before, after addr
   $10 - $40 dump ;
@@ -123,8 +123,8 @@
 : count ( addr -- addr+1, count )  \ Get count &amp;amp; address of counted string
   c@+ ; \  dup 1+   swap c@  ;

-\ : -count ( addr+1, count, --- addr )  \ Get staddr from count &amp;amp; address in RAM
-\  over 1- c! 1- ;
+: -count ( addr+1, count, --- addr )  \ Get staddr from count &amp;amp; address in RAM
+  over 1- c! 1- ;

 : #&amp;gt;str  ( d -- addr, cnt )   \ simple number to string &amp;amp; sign
   tuck dabs  &amp;lt;# #s  rot sign  #&amp;gt;  ;
@@ -165,28 +165,27 @@
 \ addr2 is the address of the first unconvertable digit.  

   begin
-   1+ dup &amp;gt;r       \ save addr1+1, address of the first digit, on return stack.
-   c@              \ get a digit
-   digit?          \ A primitive.  ( c n1 -- n2 tf or nx ff )
+        1+ dup &amp;gt;r       \ save addr1+1, address of the first digit, on return stack.
+        c@              \ get a digit
+        digit?          \ A primitive.  ( c n1 -- n2 tf or nx ff )
                         \ Convert the character c according to base to a binary
                         \ number n2 with a true flag on top of stack.  
   while                 \ successful conversion, accumulate into d1.
-   swap            \ get the high order part of d1 to the top.
-   base @ um*      \ multiply by base value
-   drop            \ drop the high order part of the product
-   rot             \ move the low order part of d1 to top of stack
-   base @ um*      \ multiply by base value
-   d+              \ accumulate result into d1
-   p+              \ inc conversion flag
-   dpl @ 1+        \ see if dpl is other than -1
-   if              \ DPL is not -1, a decimal point was encountered
-      1 dpl +!     \ Increment DPL, one more digit to right of decimal point
-   then
-   r&amp;gt;              \ Pop addr1+1 back to convert the next digit.
- \       1+             \ Pop addr1+1 back to convert the next digit.
+        swap            \ get the high order part of d1 to the top.
+        base @ um*      \ multiply by base value
+        drop            \ drop the high order part of the product
+        rot             \ move the low order part of d1 to top of stack
+        base @ um*      \ multiply by base value
+        d+              \ accumulate result into d1
+        p+              \ inc conversion flag
+        dpl @ 1+        \ see if dpl is other than -1
+        if              \ DPL is not -1, a decimal point was encountered
+           1 dpl +!     \ Increment DPL, one more digit to right of decimal point
+        then
+        r&amp;gt;              \ Pop addr1+1 back to convert the next digit.
   repeat                \ If an invalid digit was found, exit the loop here. Otherwise
                         \ repeat the conversion until the string is exhausted.
-  drop r&amp;gt;  ;       \ Pop return stack which contains the address of the first
+  drop r&amp;gt;  ;            \ Pop return stack which contains the address of the first
                         \ non-convertable digit, addr2.

 : number ( addr -- d, n or ff ) \ Fig style number, with thanks to C. H. Ting
@@ -206,7 +205,7 @@
   -1            \ The initial value of DPL
   begin         \ Start the conversion process
      dpl !      \ Store the decimal point counter
-     (number) \ Convert one digit after another until an invalid char occurs.
+     (number)   \ Convert one digit after another until an invalid char occurs.
                 \ Result is accumulated into d .
      dup c@     \ fetch the invalid digit
      $2e =      \ is it "."
@@ -240,7 +239,7 @@

 : jt ( an nn n -- ) \ compile an execution table
      ( m -- )       \ execute aword corresponding to m
-  flash            \ MJM
+  flash                   \ MJM
   create
   dup 1- ,             \ store the table size
   for
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 06:49:11 -0000</pubDate><guid>https://sourceforge.net7d1e9b3999a70970577670b4df98cc14ae143421</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -1,13 +1,14 @@
+~~~~
 \ ************************************************
 \ Utility words for FlashForth 4.8
 \ MJM 9/17/12, 7/14/13
 \ MJM 11/1/13
-\      Some by Mike Miller 
-\      Some by Mikael Nordman, mod by MJM
+\ Some by Mike Miller 
+\ Some by Mikael Nordman, mod by MJM
 \ www.moonvalleycircuits.com
 \ ************************************************

-fl+ empty  \ allow flash writes
+fl+ empty   \ allow flash writes
 decimal
 utilwords
 marker utilwords
@@ -141,22 +142,22 @@
   over c@ 1+ cmove ;

 : $comp ( saddr1, saddr2, -- f ) \ compare counted strings, ft if equal
-  !p&amp;gt;r true swap dup c@    1+      \ saddr2&amp;gt;p, --- ft, saddr1+1, count
+  !p&amp;gt;r true swap dup c@    1+              \ saddr2&amp;gt;p, --- ft, saddr1+1, count
   for
-     c@+ pc@ =             \ compare chr
+     c@+ pc@ =                          \ compare chr
      p+
-     rot and swap          \ AND flag
+     rot and swap                       \ AND flag
   next 
   drop r&amp;gt;p  ;

 : strcat ( straddr1, count1, straddr2, count2 --- straddr1, count )
-\ concatenate strings, \ straddr1 must be in RAM
-  &amp;gt;r &amp;gt;r                \ -- straddr1, count1   R-- count2, straddr2
-  2dup + r&amp;gt; swap r@ cmove  \ -- straddr1, count1  R-- count2 
+\ concatenate strings           \ straddr1 must be in RAM
+  &amp;gt;r &amp;gt;r                         \ -- straddr1, count1   R-- count2, straddr2
+  2dup + r&amp;gt; swap r@ cmove       \ -- straddr1, count1  R-- count2 
   r&amp;gt; + 
-  over 1- over swap c! ;   \ store new count in case we concatenate again
-
-variable dpl   \ decimal point location for (number), number
+  over 1- over swap c! ;        \ store new count in case we concatenate again
+
+variable dpl   \ decimal point location for (number), number

 : (number) ( d1 addr1 --- d2 addr2 ) \ similar to FIG
 \ Run-time routine of number conversion.   Convert an ASCII text beginning at
@@ -164,29 +165,29 @@
 \ addr2 is the address of the first unconvertable digit.  

   begin
-   1+ dup &amp;gt;r   \ save addr1+1, address of the first digit, on return stack.
-   c@      \ get a digit
-   digit?      \ A primitive.  ( c n1 -- n2 tf or nx ff )
-           \ Convert the character c according to base to a binary
-           \ number n2 with a true flag on top of stack.  
-  while        \ successful conversion, accumulate into d1.
-   swap        \ get the high order part of d1 to the top.
-   base @ um*  \ multiply by base value
-   drop        \ drop the high order part of the product
-   rot         \ move the low order part of d1 to top of stack
-   base @ um*  \ multiply by base value
-   d+      \ accumulate result into d1
-   p+      \ inc conversion flag
-   dpl @ 1+    \ see if dpl is other than -1
-   if      \ DPL is not -1, a decimal point was encountered
+   1+ dup &amp;gt;r       \ save addr1+1, address of the first digit, on return stack.
+   c@              \ get a digit
+   digit?          \ A primitive.  ( c n1 -- n2 tf or nx ff )
+                        \ Convert the character c according to base to a binary
+                        \ number n2 with a true flag on top of stack.  
+  while                 \ successful conversion, accumulate into d1.
+   swap            \ get the high order part of d1 to the top.
+   base @ um*      \ multiply by base value
+   drop            \ drop the high order part of the product
+   rot             \ move the low order part of d1 to top of stack
+   base @ um*      \ multiply by base value
+   d+              \ accumulate result into d1
+   p+              \ inc conversion flag
+   dpl @ 1+        \ see if dpl is other than -1
+   if              \ DPL is not -1, a decimal point was encountered
       1 dpl +!     \ Increment DPL, one more digit to right of decimal point
    then
-   r&amp;gt;          \ Pop addr1+1 back to convert the next digit.
- \       1+        \ Pop addr1+1 back to convert the next digit.
-  repeat       \ If an invalid digit was found, exit the loop here. Otherwise
-           \ repeat the conversion until the string is exhausted.
-  drop r&amp;gt;  ;   \ Pop return stack which contains the address of the first
-           \ non-convertable digit, addr2.
+   r&amp;gt;              \ Pop addr1+1 back to convert the next digit.
+ \       1+             \ Pop addr1+1 back to convert the next digit.
+  repeat                \ If an invalid digit was found, exit the loop here. Otherwise
+                        \ repeat the conversion until the string is exhausted.
+  drop r&amp;gt;  ;       \ Pop return stack which contains the address of the first
+                        \ non-convertable digit, addr2.

 : number ( addr -- d, n or ff ) \ Fig style number, with thanks to C. H. Ting
 \ Convert counted character string at addr to signed double integer number,
@@ -194,30 +195,30 @@
 \ in the text, its position will  be given in DPL, number of digits is in
 \ the conversion  flag.  
 \ String must have a trailing (unconvertible) chr
-  0 !p&amp;gt;r   \ conversion flag
-  0 0 rot  \ push two zero's on stack as the initial value of d .
-  dup 1+ c@    \ get the first digit
-  $2d =    \ is it a - sign?
-  dup &amp;gt;r   \ Save the sign flag on return stack.
-  negate +     \ If the first digit is -, the flag is 1, and addr+1 points to
-       \ the second digit.  If the first digit is not -, the flag is 0.
-       \ addr+0 remains the same, pointing to the first digit.
-  -1       \ The initial value of DPL
-  begin    \ Start the conversion process
-     dpl !     \ Store the decimal point counter
+  0 !p&amp;gt;r        \ conversion flag
+  0 0 rot       \ push two zero's on stack as the initial value of d .
+  dup 1+ c@     \ get the first digit
+  $2d =         \ is it a - sign?
+  dup &amp;gt;r        \ Save the sign flag on return stack.
+  negate +      \ If the first digit is -, the flag is 1, and addr+1 points to
+                \ the second digit.  If the first digit is not -, the flag is 0.
+                \ addr+0 remains the same, pointing to the first digit.
+  -1            \ The initial value of DPL
+  begin         \ Start the conversion process
+     dpl !      \ Store the decimal point counter
      (number) \ Convert one digit after another until an invalid char occurs.
-       \ Result is accumulated into d .
-     dup c@    \ fetch the invalid digit
-     $2e = \ is it "."
-  while    \ it is a decimal point
-    0      \ A decimal point was found.  Set DPL to 0
-  repeat   \ exit here if non-convertible chr found,  otherwise repeat the
-       \ conversion process.
-  drop         \ discard addr on stack
-  r&amp;gt;       \ pop the flag of - sign back
-  if dnegate   \ negate d if the first digit is a - sign.
-  then     \ All done.  A double integer is on stack.
-  @p r&amp;gt;p   \ conversion count on stack
+                \ Result is accumulated into d .
+     dup c@     \ fetch the invalid digit
+     $2e =      \ is it "."
+  while         \ it is a decimal point
+    0           \ A decimal point was found.  Set DPL to 0
+  repeat        \ exit here if non-convertible chr found,  otherwise repeat the
+                \ conversion process.
+  drop          \ discard addr on stack
+  r&amp;gt;            \ pop the flag of - sign back
+  if dnegate    \ negate d if the first digit is a - sign.
+  then          \ All done.  A double integer is on stack.
+  @p r&amp;gt;p        \ conversion count on stack
   dup 0= 
   if nip nip then ; \ drop double in no digits

@@ -245,7 +246,7 @@
   for
     , ,                \ store an entry
   next
-  ram             \ MJM
+  ram                  \ MJM
   does&amp;gt;                \ m addr 
   dup @                \ m a n
   for
@@ -262,7 +263,7 @@
 ;
 ram

-: tx2out  ['] tx2 r0 2+ ! ;    \ Set task EMIT vector to TX2 for debug
+: tx2out  ['] tx2 r0 2+ ! ;      \ Set task EMIT vector to TX2 for debug

 \ LMI WinForth structure words by MJM 12/14/94
 \ emulate CSI Mac Forth
@@ -326,12 +327,12 @@

 \ Structure example:
 structure t&amp;amp;drecord        \ time &amp;amp; date
-byte:      +year
-byte:      +month
-byte:      +day
-byte:      +hours
-byte:      +minutes
-byte:      +seconds
+byte:           +year
+byte:           +month
+byte:           +day
+byte:           +hours
+byte:           +minutes
+byte:           +seconds
 structure.end

 create t&amp;amp;d t&amp;amp;drecord 4 * allot   \ create a structure with 4 time &amp;amp; date records
@@ -341,4 +342,4 @@
   t&amp;amp;d +                          \ beginning of desired t&amp;amp;d record
   +minutes c@ ;

-
+~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 06:26:26 -0000</pubDate><guid>https://sourceforge.nete15584bd8b533119f894b87c89bea754c40c9c20</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -150,7 +150,7 @@
   drop r&amp;gt;p  ;

 : strcat ( straddr1, count1, straddr2, count2 --- straddr1, count )
-  \ concatenate strings, \ straddr1 must be in RAM
+\ concatenate strings, \ straddr1 must be in RAM
   &amp;gt;r &amp;gt;r                \ -- straddr1, count1   R-- count2, straddr2
   2dup + r&amp;gt; swap r@ cmove  \ -- straddr1, count1  R-- count2 
   r&amp;gt; + 
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 05:56:40 -0000</pubDate><guid>https://sourceforge.net9d5c9b2f7c3a26f45d8efc256622d7e7961fedd8</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -223,7 +223,7 @@

 create stringbuff  ( -- addr )  #40 allot   \ a convenient string buffer

-: get stringbuff 1+ #40 accept stringbuff c! ;
+: get stringbuff 1+ #40 accept stringbuff c! ; \ accept following text to buffer

 \ *******************************************************************
 \ Copied from jt.txt by Mikael Nordman 
@@ -323,3 +323,22 @@
   2 needed 
   =cells swap !
   ram ;
+
+\ Structure example:
+structure t&amp;amp;drecord        \ time &amp;amp; date
+byte:      +year
+byte:      +month
+byte:      +day
+byte:      +hours
+byte:      +minutes
+byte:      +seconds
+structure.end
+
+create t&amp;amp;d t&amp;amp;drecord 4 * allot   \ create a structure with 4 time &amp;amp; date records
+
+: @minute ( record --- minutes)  \ fetch minutes from record 0 - 3
+  t&amp;amp;drecord *
+  t&amp;amp;d +                          \ beginning of desired t&amp;amp;d record
+  +minutes c@ ;
+  
+
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 05:48:39 -0000</pubDate><guid>https://sourceforge.net39f1995a31b5f85c1638392d33a9cae2aec5520d</guid></item><item><title>Discussion for Utilities page</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Mike Miller&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 05:22:59 -0000</pubDate><guid>https://sourceforge.net8142b695f88ff604133049777c5a06963ae466f7</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 05:22:11 -0000</pubDate><guid>https://sourceforge.net49c46fa0785fab0f739c1d5f089b7592f7ea6e1b</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -4,6 +4,7 @@
 \ MJM 11/1/13
 \      Some by Mike Miller 
 \      Some by Mikael Nordman, mod by MJM
+\ www.moonvalleycircuits.com
 \ ************************************************

 fl+ empty  \ allow flash writes
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 05:18:54 -0000</pubDate><guid>https://sourceforge.net473fbf144df1283234dac6e025b54cc42dce907d</guid></item><item><title>Utilities modified by Mike Miller</title><link>https://sourceforge.net/p/flashforth/wiki/Utilities/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;\ &lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;***&lt;br /&gt;
\ Utility words for FlashForth 4.8&lt;br /&gt;
\ MJM 9/17/12, 7/14/13&lt;br /&gt;
\ MJM 11/1/13&lt;br /&gt;
\       Some by Mike Miller &lt;br /&gt;
\       Some by Mikael Nordman, mod by MJM&lt;br /&gt;
\ &lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;***&lt;/p&gt;
&lt;p&gt;fl+ empty  \ allow flash writes&lt;br /&gt;
decimal&lt;br /&gt;
utilwords&lt;br /&gt;
marker utilwords&lt;/p&gt;
&lt;p&gt;hex&lt;br /&gt;
: 4+ ( n --- n+4 )&lt;br /&gt;
  4 + ;&lt;/p&gt;
&lt;p&gt;: fcon \ make constant in flash that can be written&lt;br /&gt;
  flash create , &lt;br /&gt;
  does&amp;gt; @ ; &lt;br /&gt;
\ to write: &amp;lt;value&amp;gt; ' &amp;lt;name&amp;gt; 4+ !&lt;/p&gt;
&lt;p&gt;: f2con \ make 2constant in flash that can be written&lt;br /&gt;
  flash create swap , ,&lt;br /&gt;
  does&amp;gt; 2@ ;&lt;br /&gt;
\ to write: &amp;lt;dvalue&amp;gt; ' &amp;lt;name&amp;gt; 4+ 2!&lt;/p&gt;
&lt;p&gt;: fcon! ( n, cfa --- ) \ write flash constant&lt;br /&gt;
  fl+  4+ !  iflush  fl- ;&lt;/p&gt;
&lt;p&gt;: f2con! ( d, cfa --- ) \ write flash 2constant&lt;br /&gt;
  fl+  4+ 2!  iflush fl- ;&lt;/p&gt;
&lt;p&gt;: fcmove ( addr1 faddr2 u -- ) \ cmove into flash&lt;br /&gt;
  fl+  cmove  iflush fl-  ;&lt;/p&gt;
&lt;p&gt;: ?  ( addr -- )&lt;br /&gt;
  @ . ;&lt;/p&gt;
&lt;p&gt;: u? ( addr -- )&lt;br /&gt;
  @ u.  ;&lt;/p&gt;
&lt;p&gt;: c? ( addr -- )&lt;br /&gt;
  c@ . ;&lt;/p&gt;
&lt;p&gt;: 0! ( addr -- )&lt;br /&gt;
  0 swap ! ;&lt;/p&gt;
&lt;p&gt;: off ( addr -- ) \ set addr false&lt;br /&gt;
  0 swap ! ;&lt;/p&gt;
&lt;p&gt;: on ( addr -- ) \ set addr true&lt;br /&gt;
  true swap ! ;&lt;/p&gt;
&lt;p&gt;: pick ( xu ... x0 u -- xu ... x0 xu) &lt;br /&gt;
  2* 2+ sp@ swap - @ ;&lt;/p&gt;
&lt;p&gt;: ?dup ( n -- n, n; or-- 0 )   \ dup if not zero&lt;br /&gt;
  dup  if   dup   then ;&lt;/p&gt;
&lt;p&gt;: boolean ( n --- f ) \ convert number to boolean flag&lt;br /&gt;
  0= 0= ;&lt;/p&gt;
&lt;p&gt;: nop ;&lt;/p&gt;
&lt;p&gt;: 4&lt;em&gt; ( n --- 4n )&lt;br /&gt;
 2&lt;/em&gt; 2* ;&lt;/p&gt;
&lt;p&gt;: 4/ ( n --- n\4 )&lt;br /&gt;
 2/ 2/ ;&lt;/p&gt;
&lt;p&gt;: 2swap ( d1, d2 -- d2, d1 )&lt;br /&gt;
  rot &amp;gt;r  rot r&amp;gt; ;&lt;/p&gt;
&lt;p&gt;: scale ( b, n --- b \ scale b by 2^n)&lt;br /&gt;
  dup 0&amp;lt;&lt;br /&gt;
  if&lt;br /&gt;
     abs for 2/ next&lt;br /&gt;
   else&lt;br /&gt;
     for 2* next&lt;br /&gt;
  then ;&lt;/p&gt;
&lt;p&gt;: depth ( --- n ) \ depth of stack&lt;br /&gt;
  sp@ s0 @ - 2/ ;&lt;/p&gt;
&lt;p&gt;: needed ( .., n --- )&lt;br /&gt;
  depth 1-&lt;br /&gt;
  1+ &amp;lt; 0=&lt;br /&gt;
  if&lt;br /&gt;
    ." not enough stack items" abort&lt;br /&gt;
  then ;&lt;/p&gt;
&lt;p&gt;hex&lt;br /&gt;
: combine ( l, h --- n |combine two bytes into words)&lt;br /&gt;
   100 * + ;&lt;/p&gt;
&lt;p&gt;: split ( n --- l, h |split word int high &amp;amp; low bytes)&lt;br /&gt;
   100 /mod ;&lt;/p&gt;
&lt;p&gt;: &amp;gt;&amp;lt; ( n --- n | byte-swap 16 bitt number)&lt;br /&gt;
  split swap combine ;&lt;/p&gt;
&lt;p&gt;\ : &amp;gt;w@&amp;lt; ( addr -- n | sign-extended fetch)&lt;br /&gt;
\   w@ dup 7fff &amp;gt; if ffff0000 + then ;&lt;/p&gt;
&lt;p&gt;\ : wconvert ( addr --- | flips word at addr)&lt;br /&gt;
\   dup w@ &amp;gt;&amp;lt; swap w! ;&lt;br /&gt;
decimal&lt;/p&gt;
&lt;p&gt;\ : u- ( u1, u2 --- u | u1-u2 )&lt;br /&gt;
\  dup 0&amp;lt; 2 pick 0&amp;lt; not and if swap then - ;&lt;br /&gt;
\ swap if u2 is negative but u1 is not&lt;br /&gt;
\ : u-  - ;&lt;/p&gt;
&lt;p&gt;: -dump ( addr -- )   \ dump before, after addr&lt;br /&gt;
  $10 - $40 dump ;&lt;/p&gt;
&lt;p&gt;: hdump ( addr -- )   \ hex dump before, after addr&lt;br /&gt;
  base @ swap  hex -dump base ! ;&lt;/p&gt;
&lt;p&gt;: count ( addr -- addr+1, count )  \ Get count &amp;amp; address of counted string&lt;br /&gt;
  c@+ ; \  dup 1+   swap c@  ;&lt;/p&gt;
&lt;p&gt;\ : -count ( addr+1, count, --- addr )  \ Get staddr from count &amp;amp; address in RAM&lt;br /&gt;
\  over 1- c! 1- ;&lt;/p&gt;
&lt;p&gt;: #&amp;gt;str  ( d -- addr, cnt )   \ simple number to string &amp;amp; sign&lt;br /&gt;
  tuck dabs  &amp;lt;# #s  rot sign  #&amp;gt;  ;&lt;/p&gt;
&lt;p&gt;: #st1  ( d -- addr, cnt )   \  number to string w/ one dp &amp;amp; sign&lt;br /&gt;
  tuck dabs  &amp;lt;#   #  &lt;span&gt;[char]&lt;/span&gt; . hold  #s  rot sign  #&amp;gt;  ;&lt;/p&gt;
&lt;p&gt;: #st2  ( d -- addr, cnt )   \  number to string w/ two dp &amp;amp; sign&lt;br /&gt;
  tuck dabs  &amp;lt;#   #  #  &lt;span&gt;[char]&lt;/span&gt; . hold  #s  rot sign  #&amp;gt;  ;&lt;/p&gt;
&lt;p&gt;: #st3  ( d -- addr, cnt )   \  number to string w/ three dp &amp;amp; sign&lt;br /&gt;
  tuck dabs  &amp;lt;#   #  #  # &lt;span&gt;[char]&lt;/span&gt; . hold  #s  rot sign  #&amp;gt;  ;&lt;/p&gt;
&lt;p&gt;: $&amp;gt;$  ( saddr, daddr --- )  \  move counted string&lt;br /&gt;
  over c@ 1+ cmove ;&lt;/p&gt;
&lt;p&gt;: $comp ( saddr1, saddr2, -- f ) \ compare counted strings, ft if equal&lt;br /&gt;
  !p&amp;gt;r true swap dup c@ 1+      \ saddr2&amp;gt;p, --- ft, saddr1+1, count&lt;br /&gt;
  for&lt;br /&gt;
     c@+ pc@ =              \ compare chr&lt;br /&gt;
     p+&lt;br /&gt;
     rot and swap           \ AND flag&lt;br /&gt;
  next &lt;br /&gt;
  drop r&amp;gt;p  ;&lt;/p&gt;
&lt;p&gt;: strcat ( straddr1, count1, straddr2, count2 --- straddr1, count )&lt;br /&gt;
  \ concatenate strings, \ straddr1 must be in RAM&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;r &amp;gt;r             \ -- straddr1, count1   R-- count2, straddr2&lt;br /&gt;
  2dup + r&amp;gt; swap r@ cmove   \ -- straddr1, count1  R-- count2 &lt;br /&gt;
  r&amp;gt; + &lt;br /&gt;
  over 1- over swap c! ;    \ store new count in case we concatenate again&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;variable dpl    \ decimal point location for (number), number&lt;/p&gt;
&lt;p&gt;: (number) ( d1 addr1 --- d2 addr2 ) \ similar to FIG&lt;br /&gt;
\ Run-time routine of number conversion.   Convert an ASCII text beginning at&lt;br /&gt;
\ addr1+ according to BASE.   The result is accumulated with d1 to become d2.&lt;br /&gt;
\ addr2 is the address of the first unconvertable digit.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;begin&lt;br /&gt;
    1+ dup &amp;gt;r   \ save addr1+1, address of the first digit, on return stack.&lt;br /&gt;
    c@      \ get a digit&lt;br /&gt;
    digit?      \ A primitive.  ( c n1 -- n2 tf or nx ff )&lt;br /&gt;
            \ Convert the character c according to base to a binary&lt;br /&gt;
            \ number n2 with a true flag on top of stack.&lt;br /&gt;
  while         \ successful conversion, accumulate into d1.&lt;br /&gt;
    swap        \ get the high order part of d1 to the top.&lt;br /&gt;
    base @ um&lt;em&gt;  \ multiply by base value&lt;br /&gt;
    drop        \ drop the high order part of the product&lt;br /&gt;
    rot         \ move the low order part of d1 to top of stack&lt;br /&gt;
    base @ um&lt;/em&gt;  \ multiply by base value&lt;br /&gt;
    d+      \ accumulate result into d1&lt;br /&gt;
    p+      \ inc conversion flag&lt;br /&gt;
    dpl @ 1+    \ see if dpl is other than -1&lt;br /&gt;
    if      \ DPL is not -1, a decimal point was encountered&lt;br /&gt;
       1 dpl +!     \ Increment DPL, one more digit to right of decimal point&lt;br /&gt;
    then&lt;br /&gt;
    r&amp;gt;          \ Pop addr1+1 back to convert the next digit.&lt;br /&gt;
 \       1+     \ Pop addr1+1 back to convert the next digit.&lt;br /&gt;
  repeat        \ If an invalid digit was found, exit the loop here. Otherwise&lt;br /&gt;
            \ repeat the conversion until the string is exhausted.&lt;br /&gt;
  drop r&amp;gt;   ;   \ Pop return stack which contains the address of the first&lt;br /&gt;
            \ non-convertable digit, addr2.&lt;/p&gt;
&lt;p&gt;: number ( addr -- d, n or ff ) \ Fig style number, with thanks to C. H. Ting&lt;br /&gt;
\ Convert counted character string at addr to signed double integer number,&lt;br /&gt;
\ using the current base.  If  a decimal point is encountered&lt;br /&gt;
\ in the text, its position will  be given in DPL, number of digits is in&lt;br /&gt;
\ the conversion  flag.&lt;br /&gt;
\ String must have a trailing (unconvertible) chr&lt;br /&gt;
  0 !p&amp;gt;r    \ conversion flag&lt;br /&gt;
  0 0 rot   \ push two zero's on stack as the initial value of d .&lt;br /&gt;
  dup 1+ c@ \ get the first digit&lt;br /&gt;
  $2d =     \ is it a - sign?&lt;br /&gt;
  dup &amp;gt;r    \ Save the sign flag on return stack.&lt;br /&gt;
  negate +  \ If the first digit is -, the flag is 1, and addr+1 points to&lt;br /&gt;
        \ the second digit.  If the first digit is not -, the flag is 0.&lt;br /&gt;
        \ addr+0 remains the same, pointing to the first digit.&lt;br /&gt;
  -1        \ The initial value of DPL&lt;br /&gt;
  begin     \ Start the conversion process&lt;br /&gt;
     dpl !  \ Store the decimal point counter&lt;br /&gt;
     (number) \ Convert one digit after another until an invalid char occurs.&lt;br /&gt;
        \ Result is accumulated into d .&lt;br /&gt;
     dup c@     \ fetch the invalid digit&lt;br /&gt;
     $2e =  \ is it "."&lt;br /&gt;
  while     \ it is a decimal point&lt;br /&gt;
    0       \ A decimal point was found.  Set DPL to 0&lt;br /&gt;
  repeat    \ exit here if non-convertible chr found,  otherwise repeat the&lt;br /&gt;
        \ conversion process.&lt;br /&gt;
  drop      \ discard addr on stack&lt;br /&gt;
  r&amp;gt;        \ pop the flag of - sign back&lt;br /&gt;
  if dnegate    \ negate d if the first digit is a - sign.&lt;br /&gt;
  then      \ All done.  A double integer is on stack.&lt;br /&gt;
  @p r&amp;gt;p    \ conversion count on stack&lt;br /&gt;
  dup 0= &lt;br /&gt;
  if nip nip then ; \ drop double in no digits&lt;/p&gt;
&lt;p&gt;create stringbuff  ( -- addr )  #40 allot   \ a convenient string buffer&lt;/p&gt;
&lt;p&gt;: get stringbuff 1+ #40 accept stringbuff c! ;&lt;/p&gt;
&lt;p&gt;\ &lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;*&lt;/em&gt;&lt;/strong&gt;****&lt;br /&gt;
\ Copied from jt.txt by Mikael Nordman &lt;br /&gt;
\
\ create an execution table with n entries&lt;br /&gt;
\ each entry consists of 'nn' cell sized comparison value&lt;br /&gt;
\ and 'an' the address of the corresponding word to be executed.&lt;br /&gt;
\ At least two entries must be provided, the last one beeing the&lt;br /&gt;
\ default action.&lt;br /&gt;
\ mod 5/12/13 MJM&lt;/p&gt;
&lt;p&gt;: jte nip cell+ @ex ;&lt;/p&gt;
&lt;p&gt;: jt ( an nn n -- ) \ compile an execution table&lt;br /&gt;
     ( m -- )       \ execute aword corresponding to m&lt;br /&gt;
  flash         \ MJM&lt;br /&gt;
  create&lt;br /&gt;
  dup 1- ,             \ store the table size&lt;br /&gt;
  for&lt;br /&gt;
    , ,                \ store an entry&lt;br /&gt;
  next&lt;br /&gt;
  ram              \ MJM&lt;br /&gt;
  does&amp;gt;                \ m addr &lt;br /&gt;
  dup @                \ m a n&lt;br /&gt;
  for&lt;br /&gt;
    cell+&lt;br /&gt;
    2dup @ =           \ m a flag&lt;br /&gt;
    if&lt;br /&gt;
      \ a match was found&lt;br /&gt;
      jte rdrop exit&lt;br /&gt;
    then&lt;br /&gt;
    cell+             \ m a&lt;br /&gt;
  next&lt;br /&gt;
  \ Execute the default action.&lt;br /&gt;
  cell+ jte&lt;br /&gt;
;&lt;br /&gt;
ram&lt;/p&gt;
&lt;p&gt;: tx2out  &lt;span&gt;[']&lt;/span&gt; tx2 r0 2+ ! ; \ Set task EMIT vector to TX2 for debug&lt;/p&gt;
&lt;p&gt;\ LMI WinForth structure words by MJM 12/14/94&lt;br /&gt;
\ emulate CSI Mac Forth&lt;br /&gt;
\ adapted to Flash Forth 5/10/13 MJM&lt;br /&gt;
\ Last Revision: 5/28/13  01:06:59 PM  MJM&lt;/p&gt;
&lt;p&gt;\ macforth structures&lt;/p&gt;
&lt;p&gt;variable evenstructures&lt;br /&gt;
evenstructures on&lt;/p&gt;
&lt;p&gt;: =cells&lt;br /&gt;
  evenstructures @&lt;br /&gt;
  if 1+ -2 and then ;&lt;/p&gt;
&lt;p&gt;: field ( n1 -- )&lt;br /&gt;
  create ,    \ w, w@ if 32 bit&lt;br /&gt;
  does&amp;gt; @ + ; ( n2 -- n1+n2)&lt;/p&gt;
&lt;p&gt;: :aligned&lt;br /&gt;
  2  needed&lt;br /&gt;
  swap =cells swap over field + ;&lt;/p&gt;
&lt;p&gt;: struct:&lt;br /&gt;
  :aligned ;&lt;/p&gt;
&lt;p&gt;: :member&lt;br /&gt;
  2 needed&lt;br /&gt;
  over field + ;&lt;/p&gt;
&lt;p&gt;: byte:&lt;br /&gt;
  1 :member ;&lt;/p&gt;
&lt;p&gt;: bytes:&lt;br /&gt;
  :member ;&lt;/p&gt;
&lt;p&gt;: string:&lt;br /&gt;
  bytes: ;&lt;/p&gt;
&lt;p&gt;: short:&lt;br /&gt;
  2 :aligned ;&lt;/p&gt;
&lt;p&gt;: shorts:&lt;br /&gt;
  2 * :aligned ;&lt;/p&gt;
&lt;p&gt;: long:&lt;br /&gt;
  4 :aligned ;&lt;/p&gt;
&lt;p&gt;: longs:&lt;br /&gt;
  4 * :aligned ;&lt;/p&gt;
&lt;p&gt;: structure&lt;br /&gt;
  flash&lt;br /&gt;
  create here  0 , 0 ( --- here, 0 )&lt;br /&gt;
  does&amp;gt; @ ; ( --- n )&lt;/p&gt;
&lt;p&gt;: structure.end&lt;br /&gt;
  2 needed &lt;br /&gt;
  =cells swap !&lt;br /&gt;
  ram ;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Miller</dc:creator><pubDate>Wed, 07 Jan 2015 05:06:54 -0000</pubDate><guid>https://sourceforge.net8888378a41fccd090f0fb48131239d8686bf7921</guid></item></channel></rss>