---------------------------------------------------------------- 0 ================================================================ 1 2 crc's _ __ _ _ 3 _ __ ___| |_ _ __ ___ / _| ___ _ __| |_| |__ 4 | '__/ _ \ __| '__/ _ \ | |_ / _ \| '__| __| '_ \ 5 | | | __/ |_| | | (_) | | _| (_) | | | |_| | | | 6 |_| \___|\__|_| \___/ |_| \___/|_| \__|_| |_| 7 for ilo 8 9 ================================================================ 10 11 Quick start: 12 13 `manual` for the users guide 14 `blocks` for help using the block editor 15 `describe name` for help on a specific word ---------------------------------------------------------------- 0 (startup:configure-blocks,_load_extensions) 1 2 . You should setup the numbers of blocks in your system. 3 4 #1024 !Blocks 5 6 . To load extensions, wrap the code to load them in a quotation 7 . and call it. Note that the call should be the last thing in 8 . the block. (All code blocks are loaded to a shared buffer, so 9 . not doing this may leave the block buffer in an unexpected 10 . state.) 11 12 [ (`blocks`,_`manual`,_`describe) 13 '(crc/blocks) needs '(crc/manual) needs 14 '(tools/describe) needs 15 ] call ---------------------------------------------------------------- 0 (startup:local-configuration) 1 2 . If you load things like (termina) or (graphica), you may want 3 . to set various variables relating to the local environment. Do 4 . this here. 5 6 7 8 9 10 11 12 . The last line here displays the contents of block 0 on 13 . startup. 14 15 [ #0 set load list* nl ] call ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (constants) 1 2 . Constants for numeric range limits. 3 4 :n:MIN #-2147483647 ; 5 :n:MAX #2147483646 ; 6 7 . Constants for flags. 8 9 :TRUE #-1 ; 10 :FALSE #0 ; 11 12 . Constants for memory layout 13 14 :sys:BUFFERS #60000 ; 15 :sys:EOM #65535 ; ---------------------------------------------------------------- 0 (std) (s:) (constants) 1 2 :s:DIGITS '0123456789ABCDEF ; 3 :s:VOWELS 'aeiouAEIOU ; 4 :s:ASCII-UPPERCASE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ; 5 :s:ASCII-LOWERCASE 'abcdefghijklmnopqrstuvwxyz ; 6 :s:ASCII-LETTERS 7 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ; 8 's:WHITESPACE d:create #4 comma 9 #9 comma #10 comma #13 comma #32 comma 10 :s:PUNCTUATION '_!"#$%&'()*+,-./:;<=>?@[\]^`{|}~ ; 11 :s:CONSONANTS 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ ; 12 13 14 15 ---------------------------------------------------------------- 0 (std) (c:) (constants) 1 2 :c:consonant? (c-f) s:CONSONANTS swap s:contains? ; 3 :c:vowel? (c-f) s:VOWELS swap s:contains? ; 4 :c:letter? (c-f) s:ASCII-LETTERS swap s:contains? ; 5 :c:digit? (c-f) s:DIGITS swap s:contains? ; 6 :c:whitespace? (c-f) s:WHITESPACE swap s:contains? ; 7 :c:visible? (c-f) #32 #126 n:between? ; 8 :c:-consonant? (c-f) c:consonant? not ; 9 :c:-vowel? (c-f) c:vowel? not ; 10 :c:-letter? (c-f) c:letter? not ; 11 :c:-digit? (c-f) c:digit? not ; 12 :c:-whitespace? (c-f) c:whitespace? not ; 13 :c:-uppercase? (c-f) c:uppercase? not ; 14 :c:-lowercase? (c-f) c:lowercase? not ; 15 :c:-visible? (c-f) c:visible? not ; ---------------------------------------------------------------- 0 (std) (c:) (conversions) 1 2 :c:toggle-case dup c:lowercase? &c:to-upper &c:to-lower choose ; 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (n:) (even,odd,sign,square,sqrt) 1 2 :n:odd? (n-f) #1 and #1 eq? ; 3 :n:even? (n-f) n:odd? not ; 4 5 :n:negative? (n-f) #0 lt? ; 6 :n:postitive? (n-f) #0 gt? ; 7 :n:strictly-positive? (n-f) #1 gteq? ; 8 9 :n:square (n-n) dup n:mul ; 10 11 :n:sqrt/guess dup-pair n:div over n:sub #2 n:div ; 12 :n:sqrt (n-n) #1 [ n:sqrt/guess &n:add sip ] while nip ; 13 14 :n:sign (n-n) n:negative? [ #-1 ] [ #1 ] choose ; 15 ---------------------------------------------------------------- 0 (std) (v:) 1 2 :v:preserve (aq-) swap dup fetch [ &call dip ] dip swap store ; 3 :v:inc-by (an-) [ fetch n:add ] sip store ; 4 :v:dec-by (an-) [ fetch swap n:sub ] sip store ; 5 :v:on (a-) #-1 swap store ; 6 :v:off (a-) #0 swap store ; 7 :v:update (aq-) swap [ fetch swap call ] sip store ; 8 :v:limit (alu-) [ [ dup fetch ] dip ] dip n:limit swap store ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (buffer:) 1 2 {{ 3 'Start var 'Ptr var 4 :at @Start @Ptr ; 5 :update @Ptr @Start store ; 6 ---reveal--- 7 :buffer:size (-n) at nip ; 8 :buffer:end (-a) at n:inc n:add ; 9 :buffer:start (-a) @Start ; 10 :buffer:empty (-) #0 !Ptr update ; 11 :buffer:add (na-) at a:store &Ptr v:inc update ; 12 :buffer:get (a-) &Ptr v:dec at a:fetch update ; 13 :buffer:set (a-) !Start #0 !Ptr update ; 14 }} 15 ---------------------------------------------------------------- 0 (std) (s:) (begins-with,ends-with) 1 2 {{ 3 :prepare dup s:length &swap dip ; 4 ---reveal--- 5 :s:begins-with? (ss-f) prepare s:left &s:hash bi@ eq? ; 6 :s:ends-with? (ss-f) prepare s:right &s:hash bi@ eq? ; 7 }} 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (s:) (contains/s?) 1 2 {{ 3 'tar var 'src var 4 'tar.l var 'src.l var 5 ---reveal--- 6 :s:contains/s? (ss-f) 7 [ s:keep [ s:length !tar.l ] [ !tar ] bi 8 s:keep [ s:length !src.l ] [ !src ] bi 9 #0 @src.l @tar.l n:sub n:inc 10 [ @src I @tar.l s:middle @tar s:eq? or ] indexed-times 11 ] gc ; 12 }} 13 14 15 ---------------------------------------------------------------- 0 (std) (s:) (index/s) 1 2 {{ 3 'tar var 'src var 4 'tar.l var 'src.l var 5 ---reveal--- 6 :s:index/s (ss-n) 7 [ s:keep [ s:length !tar.l ] [ !tar ] bi 8 s:keep [ s:length !src.l ] [ !src ] bi 9 #65535 @src.l @tar.l n:sub n:inc 10 [ @src I @tar.l s:middle @tar s:eq? [ I n:min ] if ] 11 indexed-times ] gc ; 12 }} 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (bit:) (bit-access) 1 2 :bit:get (vi-b) [ #1 swap shift-left and ] sip shift-right ; 3 :bit:set (vi-v) #1 swap shift-left or ; 4 :bit:clear (vi-v) #1 swap shift-left not and ; 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (b:) (byte-addressing) 1 2 'Byte var 3 4 :byte-mask (xn-b) 5 #255 swap #8 n:mul dup 6 [ shift-left and ] dip shift-right ; 7 8 [ drop @Byte ] 9 [ [ drop @Byte ] dip ] 10 [ [ [ drop @Byte ] dip ] dip ] 11 [ [ [ [ drop @Byte ] dip ] dip ] dip ] 12 'replacements d:create comma comma comma comma 13 14 :replace &replacements n:add fetch call ; 15 ---------------------------------------------------------------- 0 (std) (b:) (byte-addressing) 1 2 :b:to-byte-address (a-a) #4 n:mul ; 3 4 :b:unpack (c-bbbb) 5 dup #255 and swap 6 dup #8 shift-right #255 and swap 7 dup #16 shift-right #255 and swap 8 #24 shift-right #255 and ; 9 10 :b:pack (bbbb-c) 11 #24 shift-left swap 12 #16 shift-left n:add swap 13 #8 shift-left n:add swap n:add ; 14 15 ---------------------------------------------------------------- 0 (std) (b:) (byte-addressing) 1 2 :b:fetch (a-b) 3 #4 n:divmod swap 4 #4 n:divmod 5 rot n:add fetch swap byte-mask ; 6 7 :b:store (ba-) 8 swap !Byte 9 #4 n:divmod swap [ dup fetch b:unpack ] dip 10 replace b:pack swap store ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (pali) (assembler) 1 2 'Instructions d:create #30 comma 3 #5861473 comma #5863578 comma #5863326 comma 4 #5863323 comma #5863823 comma #5863722 comma 5 #5863716 comma #5863524 comma #5863273 comma 6 #5863275 comma #5863282 comma #5863772 comma 7 #5863355 comma #5863640 comma #5863589 comma 8 #5863424 comma #5863376 comma #5863820 comma 9 #5863210 comma #5863821 comma #5863623 comma 10 #5863314 comma #5863220 comma #5863686 comma 11 #5863980 comma #5863812 comma #5863818 comma 12 #5863288 comma #5863297 comma #5863485 comma 13 14 :inst s:hash &Instructions swap a:index ; 15 ---------------------------------------------------------------- 0 (std) (pali) (assembler) 1 2 :pack (nnnn-n) 3 #24 shift-left swap #16 shift-left n:add swap 4 #8 shift-left n:add swap n:add ; 5 6 :split (s-nnnn) 7 dup #2 s:left inst swap dup #2 #2 s:middle inst swap 8 dup #4 #2 s:middle inst swap #2 s:right inst ; 9 10 :assemble:opcode (s-n) split pack ; 11 12 :i (s-) assemble:opcode comma ; 13 &comma \d (n-) 14 &comma \r (n-) 15 :s (s-) dup s:length comma &comma s:for-each ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (reorder) (a-word-for-restructuring-the-stack) 1 2 {{ 3 'values d:create #27 allot 4 :from s:length dup [ [ &values n:add store ] sip n:dec ] times 5 drop ; 6 :to [ n:inc ] [ s:length ] bi 7 [ fetch-next $a n:sub n:inc &values n:add fetch swap ] 8 times drop ; 9 ---reveal--- 10 :reorder (...ss-?) &from dip to ; 11 }} 12 13 14 15 ---------------------------------------------------------------- 0 (ASCII) (ASCII_control_character_constants) 1 2 :ASCII:NUL #0 ; :ASCII:SOH #1 ; :ASCII:STX #2 ; 3 :ASCII:ETX #3 ; :ASCII:EOT #4 ; :ASCII:ENQ #5 ; 4 :ASCII:ACK #6 ; :ASCII:BEL #7 ; :ASCII:BS #8 ; 5 :ASCII:HT #9 ; :ASCII:LF #10 ; :ASCII:VT #11 ; 6 :ASCII:FF #12 ; :ASCII:CR #13 ; :ASCII:SO #14 ; 7 :ASCII:SI #15 ; :ASCII:DLE #16 ; :ASCII:DC1 #17 ; 8 :ASCII:DC2 #18 ; :ASCII:DC3 #19 ; :ASCII:DC4 #20 ; 9 :ASCII:NAK #21 ; :ASCII:SYN #22 ; :ASCII:ETB #23 ; 10 :ASCII:CAN #24 ; :ASCII:EM #25 ; :ASCII:SUB #26 ; 11 :ASCII:ESC #27 ; :ASCII:FS #28 ; :ASCII:GS #29 ; 12 :ASCII:RS #30 ; :ASCII:US #31 ; :ASCII:SPACE #32 ; 13 :ASCII:DEL #127 ; 14 15 ---------------------------------------------------------------- 0 (symbolic-names) 1 2 . RetroForth has verbose, non-symbolic names for most things. 3 . I recognize that this will be uncomfortable for many, so I am 4 . providing symbolic names for some of the common math words. 5 6 &n:add \+ 7 &n:sub \- 8 &n:mul \* 9 &n:div \/ 10 &n:mod \% 11 &n:divmod \/mod 12 &comma \, 13 14 15 ---------------------------------------------------------------- 0 (const) (creating_constants) 1 2 . If you want a constant you can call like a word, write it as a 3 . word. For a more efficient approach, you can use the \ sigil. 4 . 5 . :foo #100 ; #100 \bar 6 . 7 . Note that if using \, you will need to use & to get the value: 8 . 9 . &bar 10 11 . 12 . You can also use these (along with the & sigil): 13 14 :const (ns-) d:create @Dictionary d:address store ; 14 15 :s:const (ss-) swap s:keep swap const ; ---------------------------------------------------------------- 0 (immediate) 1 2 . RetroForth has only a few immediate words (just these: [ ] ; ) 3 . It's still useful to be able to define new immediate words, so 4 . I implemented `immediate` in this block. 5 6 :immediate (-) #-1 &Dictionary fetch d:flags store ; 7 8 . Using this is easy: write a normal word, then add `immediate` 9 . after the `;`. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (iota) 1 2 :iota (n-a) 3 [ #0 swap here 4 [ dup comma [ dup comma n:inc ] times drop ] dip 5 a:temp ] gc ; 6 7 . iota takes a number and returns an array of values. This will 8 . be in the sequence of 0 .. (n-1). 9 . 10 . An example: 11 . 12 . #4 iota [ 'Happy_Birthday_ s:put 13 . #2 eq? [ 'dear_NAME ] [ 'to_you ] choose 14 . s:put nl ] a:for-each 15 ---------------------------------------------------------------- 0 (rng) (a-pseudorandom-number-generator) 1 2 {{ 3 #876 'a var-n #5384 'b var-n #56295 'c var-n 'temp var 4 :n:div/safe dup n:zero? &drop &n:div choose ; 5 ---reveal--- 6 :set-seeds (abc-) !c !b !a ; 7 :get-seeds (-abc) @a @b @c ; 8 :random (-n) 9 get-seeds nip #9868 n:mul n:sub n:inc #3 shift-left @b 10 n:add #1 shift-right !a 11 @b #9364 n:add @b #25 @a #7 shift-right @c n:add #957 12 n:div/safe n:mul n:div/safe n:sub !b 13 @c @b @a @temp n:add n:add n:add n:mul !c 14 @a #3538 n:mul @b #257 n:div @c #2578 n:mod n:mul ; 15 }} ---------------------------------------------------------------- 0 fixed-point 1 2 I sometimes need to work with numbers that contain fractional 3 values. Rather than adding a full on floating point system, I 4 wrote a very simple fixed point vocabulary. 5 6 This won't work well for large values as the scaling is limited. 7 But it's enough for my needs. 8 9 The vocabulary is the same as the n: words for basic operations. 10 If I have a need later, I'll expand it to cover more functions. 11 But a nice side effect of the fixed point model is that the n: 12 words will work in most cases. 13 14 15 ---------------------------------------------------------------- 0 (fixed-point) 1 2 #100 'f:scale var-n 3 4 (ff-f) &n:add \f:add 5 (ff-f) &n:sub \f:sub 6 (ff-f) :f:mul n:mul @f:scale n:div ; 7 (ff-f) :f:div [ @f:scale n:mul ] dip n:div ; 8 9 {{ 10 :pad @f:scale n:to-s s:length n:dec over n:to-s s:length 11 12 n:sub [ $0 c:put ] times ; 13 ---reveal--- 14 :f:put (f-) @f:scale n:divmod n:put $. c:put pad n:put ; 15 }} ---------------------------------------------------------------- 0 (editor-ext) 1 2 :e:copy/block (src,dest) swap set load set save ; 3 4 'Line d:create #64 allot 5 :e:copy/line (n-) e:to-line &Line #64 copy ; 6 :e:paste/line (n-) e:to-line &Line swap #64 copy ; 7 8 {{ 9 :get '_ s:temp #64 over store [ n:inc #64 copy ] sip ; 10 :update n:inc swap #64 copy ; 11 :at e:to-line dup get ; 12 ---reveal--- 13 :e:indent at #62 s:left '__ s:prepend update ; 14 :e:unindent at #62 s:right '__ s:append update ; 15 }} ---------------------------------------------------------------- 0 (editor-ext) 1 2 :e:move/block (src,dest) 3 dup-pair e:copy/block swap set new save set load ; 4 5 :e:erase/block (n-) set new save ; 6 7 :e:for-each-line (q-) 8 #16 [ block:buffer n:dec 9 I #64 n:mul #64 s:middle swap &call sip ] 10 indexed-times drop ; 11 12 :n (-) next list ; 13 :p (-) prev list ; 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ll) (linked-lists,_cons_cells) 1 2 :cons (car,cdr-ptr) here [ swap comma comma ] dip ; 3 :car (cons-ptr) ; 4 :cdr (cons-ptr) n:inc ; 5 6 :car@ (cons-value) car fetch ; 7 :car! (value,cons-) car store ; 8 :cdr@ (cons-value) cdr fetch ; 9 :cdr! (value,cons-) cdr store ; 10 11 :END (-) ; 12 13 14 15 ---------------------------------------------------------------- 0 (ll) (forward-linked-lists) 1 2 {{ 3 'r var 4 ---reveal--- 5 :fll:create (v-p) &END cons ; 6 :fll:to-end (p-p) 7 dup !r [ cdr@ dup &END -eq? dup 8 [ over !r ] &nip choose ] while @r ; 9 :fll:append/value (pv-) &END cons swap fll:to-end cdr! ; 10 :fll:to-index (pn-p) &cdr@ times ; 11 :fll:del (pn-) 12 dup-pair n:dec fll:to-index 13 [ n:inc fll:to-index ] dip cdr! ; 14 }} 15 ---------------------------------------------------------------- 0 (ll) (forward-linked-lists) 1 2 {{ 3 'Action var 4 ---reveal--- 5 :fll:for-each (aq-) 6 !Action [ [ car@ @Action call ] sip cdr@ dup &END -eq? ] 7 while drop ; 8 :fll:length (p-n) #0 swap [ drop n:inc ] fll:for-each n:dec ; 9 :fll:drop dup fll:length n:dec fll:to-index &END swap cdr! ; 10 }} 11 12 13 14 15 ---------------------------------------------------------------- 0 (ll) (forward-linked-lists) 1 2 {{ 3 'i var 4 ---reveal--- 5 :fll:inject (piv-) 6 fll:create !i dup-pair n:dec fll:to-index 7 &fll:to-index dip @i swap cdr! @i cdr! ; 8 :fll:put (a-) [ n:put sp ] fll:for-each ; 9 }} 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (unu) 1 2 {{ 3 'in-block var 'action var 4 :toggle-block @in-block not !in-block drop ; 5 :run? @in-block ; 6 :fence? dup s:hash #1692041119 eq? ; 7 :not-fence run? [ s:evaluate ] [ drop ] choose ; 8 :process fence? [ toggle-block ] [ not-fence ] choose ; 9 :line-text I e:to-line n:dec #64 s:left ; 10 :perform-action line-text @action call ; 11 ---reveal--- 12 :e:for-each-line !action #16 &perform-action indexed-times ; 13 :unu &process e:for-each-line ; 14 }} 15 ---------------------------------------------------------------- 0 (unu) (needs,use,using) 1 2 {{ 3 'Hash var 4 :reset #64 block:buffer n:dec store ; 5 :actual block:buffer n:dec dup #32 s:index/c s:left ; 6 :code? block:buffer fetch $( eq? ; 7 ---reveal--- 8 :unu:needs (s-) 9 @Hash [ @Block swap s:hash !Hash 10 @Blocks [ I set load reset code? 11 [ actual s:hash @Hash eq? &unu if ] if ] 12 indexed-times !Block load ] dip !Hash ; 13 }} 14 :unu:use (block) set load unu ; 15 :unu:using over n:sub swap unu:use [ next unu ] times ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (reset) (quickly-empty-the-data-stack) 1 2 :reset (...-) 3 depth/data dup n:negative? 4 [ n:abs [ #0 ] ] 5 [ &drop ] choose times ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (if;) 1 2 :if; (fq-) 3 over &if dip n:-zero? 4 [ pop pop pop pop pop pop drop-pair drop-pair drop-pair ] if ; 5 6 . This conditional combinator behaves like `if`, but with the 7 . added action of exiting the caller if the flag is true. You 8 . can use this to process guard clauses, or in other cases where 9 . an early exit is desirable. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (case) 1 2 :case (nq-) 3 compiling? not [ drop-pair 'ERR:_Compile-Only! s:put nl ] if; 4 &push comma &over comma &eq? comma &pop comma &if; comma ; 5 immediate 6 7 :s:case (sq-) 8 compiling? not [ drop-pair 'ERR:_Compile-Only! s:put nl ] if; 9 &push comma &over comma &s:eq? comma &pop comma &if; comma ; 10 immediate 11 12 . This implements `case`, which executes the same as: 13 . dup eq? if; 14 . But with a syntax like: 15 . case ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc/blocks) (block-editor-reference) 1 2 . `blocks` starts the editor on a set of tutorial/reference 3 . blocks. 4 5 :blocks (-) #1000 edit ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc/manual) (minimal-manual-viewer) 1 2 #600 'man:start var-n #638 'man:end var-n 3 #0 'man:cur var-n #0 'man:done var-n 4 5 :man:page (-) @man:start @man:cur n:add set load list* ; 6 :man:length (-n) @man:end @man:start n:sub ; 7 :man:hints '(1)_prev__(2)_next__(0)_exit s:put tab c:get ; 8 :man:display (-) @Block man:page !Block load man:hints ; 9 :man:limit (-) @man:cur #0 man:length n:limit !man:cur ; 10 :man:0 (n-n) dup $0 eq? [ #-1 !man:done ] if ; 11 :man:1 (n-n) dup $1 eq? [ &man:cur v:dec ] if ; 12 :man:2 (n-) $2 eq? [ &man:cur v:inc ] if man:limit ; 13 :man:prepare (-) #0 !man:done ; 14 :manual (-) man:prepare 15 [ man:display man:0 man:1 man:2 @man:done ] until ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 tools/describe 1 2 This adds a word, `describe`, that scans the blocks for glossary 3 data. It takes a word name from the input stream, and looks for 4 a block with a title of `Glossary: wordname` 5 6 In example, to display the glossary data for `s:put`, you would 7 run: 8 9 describe s:put 10 11 The output strips blank lines. 12 13 Note that as this requires one block per word it is not a space 14 efficient tool. You will need around 250 blocks to cover the 15 core language, and many more to cover everything. ---------------------------------------------------------------- 0 (tools/describe) (glossary-lookups) 1 2 {{ 3 :empty? (-f) 4 #-1 I #2 n:add e:to-line 5 #64 [ fetch-next #32 eq? swap &and dip ] times drop ; 6 ---reveal--- 7 :describe:line (-) empty? [ I #2 n:add e:line ] -if ; 8 :describe:word (s-) @Block swap 9 [ 'Glossary:_ s:prepend '_ s:append s:keep @Blocks 10 [ I set load block:buffer n:dec over 11 dup s:length &swap dip s:left &s:hash bi@ eq? 12 [ nl #13 &describe:line indexed-times nl ] if 13 ] indexed-times drop ] gc !Block load ; 14 :describe ('-) s:get/token s:temp describe:word ; 15 }} ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (debug) (display-stack) 1 2 {{ 3 'Data d:create #33 allot 4 :gather depth/data dup &Data store-next swap 5 [ store-next ] times drop ; 6 :display &Data a:reverse [ n:put sp ] a:for-each nl ; 7 :restore &Data a:reverse [ ] a:for-each ; 8 ---reveal--- 9 :.s (-) gather display restore ; 10 }} 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 tools/titles 1 2 The basic system includes a `titles` word. This is useful for 3 getting a list of block titles, but with a larger block set it 4 requires scrollback to be useful. 5 6 This adds a replacement `titles` that paginates the block titles 7 and ignores empty blocks. 8 9 TODO: 10 11 - Arland suggests adding a way to abort the listing 12 - Adding a word to return titles matching a given starting 13 string 14 15 ---------------------------------------------------------------- 0 (tools/titles) (display-block-titles) 1 2 {{ 3 'Count var 4 :setup #64 block:buffer n:dec store ; 5 :has-description? block:buffer fetch #32 -eq? ; 6 :break? @Count #16 eq? ; 7 :more '..._hit_enter_to_continue s:put nl c:get drop ; 8 :... &Count v:inc break? [ #0 !Count more ] if ; 9 :display [ I n:put tab block:buffer n:dec s:put nl ... ] if ; 10 :describe I set load setup has-description? display ; 11 ---reveal--- 12 :titles 13 @Block #0 !Count @Blocks &describe indexed-times 14 !Block load ; 15 }} ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Termina : A Vocabulary for Terminal Applications =============== 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (terminal-config) 1 2 #74 'ti:width var-n 3 #21 'ti:height var-n 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (support;_cursor_movement;_clear_screen) 1 2 :vt:esc (-) #27 c:put ; 3 :vt:csi (-) vt:esc $[ c:put ; 4 :vt:dcs (-) vt:esc $P c:put ; 5 :vt:osc (-) vt:esc $] c:put ; 6 7 :vt:home (-) vt:csi $H c:put ; 8 :vt:row,col (nn-) vt:csi swap n:put $; c:put n:put $H c:put ; 9 :vt:up (-) vt:csi n:put $A c:put ; 10 :vt:down (-) vt:csi n:put $B c:put ; 11 :vt:right (-) vt:csi n:put $C c:put ; 12 :vt:left (-) vt:csi n:put $D c:put ; 13 :vt:clear (-) vt:csi '2J s:put ; 14 :vt:reset vt:csi '0m s:put ; 15 ---------------------------------------------------------------- 0 (termina) (colors) 1 2 (foreground_________background_____) 3 :fg:black #30 ; :bg:black #40 ; 4 :fg:red #31 ; :bg:red #41 ; 5 :fg:green #32 ; :bg:green #42 ; 6 :fg:yellow #33 ; :bg:yellow #43 ; 7 :fg:blue #34 ; :bg:blue #44 ; 8 :fg:magenta #35 ; :bg:magenta #45 ; 9 :fg:cyan #36 ; :bg:cyan #46 ; 10 :fg:white #37 ; :bg:white #47 ; 11 12 :vt:set/color (n-) vt:csi '1;34; s:put n:put $m c:put ; 13 14 15 ---------------------------------------------------------------- 0 (termina) (key-to-action-mapping) 1 2 'ti:Actions d:create #128 comma #128 allot 3 4 :ti:set-action (qc-) &ti:Actions swap a:store ; 5 6 :ti:reset-actions (-) 7 #128 [ #0 I ti:set-action ] indexed-times ; 8 9 :ti:get-action (c-q) &ti:Actions swap a:fetch ; 10 11 :ti:perform-action (c-) 12 ti:get-action dup n:-zero? &call &drop choose ; 13 14 :ti:input (-) c:get ti:perform-action ; 15 ---------------------------------------------------------------- 0 (termina) (keyboard-hints) 1 2 {{ 3 'ti:Hints d:create #10 comma #10 allot 4 :prepare (s-s) dup s:length #12 gt? [ #12 s:left ] if ; 5 :this (-n) I n:inc #10 n:mod ; 6 :entry (n-s) &ti:Hints swap a:fetch ; 7 :select (n-s) entry n:-zero? [ this entry ] [ '_ ] choose ; 8 :display (s-) &s:put sip s:length #12 swap n:sub &sp times ; 9 :ti:hint (-) this [ n:put sp ] [ select display ] bi ; 10 ---reveal--- 11 :ti:add-hint (sn-) [ prepare s:keep &ti:Hints ] dip a:store ; 12 :ti:reset-hints (-) 13 #10 [ #0 &ti:Hints I a:store ] indexed-times ; 14 :ti:hints (-) #10 [ ti:hint I #4 eq? &nl if ] indexed-times ; 15 }} ---------------------------------------------------------------- 0 (termina) (display) 1 2 :ti:display/none ; 3 4 &ti:display/none 'ti:Display var-n 5 6 :ti:set-display (a-) !ti:Display ; 7 :ti:reset-display (-) &ti:display/none ti:set-display ; 8 9 :ti:display (-) 10 vt:home @ti:Display call 11 @ti:height #3 n:sub #0 vt:row,col @ti:width [ $- c:put ] times 12 nl ti:hints ; 13 14 15 ---------------------------------------------------------------- 0 (termina) (application-loop) 1 2 'ti:Done var 3 :ti:done #-1 !ti:Done vt:reset nl ; 4 :ti:done? @ti:Done ; 5 6 :ti:application (aaa-) 7 !ti:Display ti:reset-hints call ti:reset-actions call 8 #0 !ti:Done [ ti:display ti:input ti:done? ] until ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Graphica : A Vocabulary for Graphical Applications ============= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Arland's _ _ 1 __ _ _ __ __ _ _ __ | |__ (_) ___ __ _ 2 / _` | '__/ _` | '_ \| '_ \| |/ __/ _` | 3 | (_| | | | (_| | |_) | | | | | (_| (_| | 4 \__, |_| \__,_| .__/|_| |_|_|\___\__,_| 5 |___/ |_| 6 ---------------------------------------------------------------- 7 Graphica is a graphics extension for ilo, napia, and nga. It 8 adds a framebuffer based display, 8 color palette, and drawing 9 primitives. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (core_words) 1 2 :g:io #63 io ; 3 :g:set-palette (a-) #0 g:io ; 4 :g:set-color (n-) #1 g:io ; 5 :g:draw-pixel (xy-) #2 g:io ; 6 :g:render (a-) #3 g:io ; 7 :g:color/current (-n) #4 g:io ; 8 :g:color/pixel (xy-n) #5 g:io ; 9 :g:cursor (-xy) #6 g:io ; 10 :g:set-cursor (xy-) #7 g:io ; 11 :g:mouse (-xyb) #8 g:io ; 12 :g:set-mouse (xy-) #9 g:io ; 13 :g:keypress (-c) #10 g:io ; 14 :g:screen-size (-wh) #11 g:io ; 15 :g:clear #8 io ; ---------------------------------------------------------------- 0 (graphica) (core_words) 1 2 :g:fill (xyb-) #12 g:io ; 3 :g:fill/diff (xy-) #13 g:io ; 4 5 :g:set-text-colors (fb-) #14 g:io ; 6 :g:get-text-colors (-bf) #15 g:io ; 7 8 :g:get-font-size (-wh) #16 g:io ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (points) 1 2 :g:point (xy-a) here [ swap comma comma ] dip ; 3 4 :< ; 5 :> (xy-a) g:point ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (shapes) 1 2 :g:pixel (p-a) here [ #0 comma comma ] dip ; 3 :g:rect (pp-a) here [ #1 comma comma comma ] dip ; 4 :g:rect/filled (pp-a) g:rect #2 over store ; 5 :g:circle (pr-a) here [ #3 comma swap comma comma ] dip ; 6 :g:circle/filled (pr-a) g:circle #4 over store ; 7 :g:triangle (ppp-a) here [ #5 comma comma comma comma ] dip ; 8 :g:triangle/filled (ppp-a) g:triangle #6 over store ; 9 10 11 :g:line (pp-a) here [ #9 comma comma comma ] dip ; 12 :g:hline (pw-a) here [ #10 comma swap comma comma ] dip ; 13 :g:vline (ph-a) here [ #11 comma swap comma comma ] dip ; 14 15 :g:render/scene (scene-) [ g:render ] a:for-each ; ---------------------------------------------------------------- 0 (graphica) (palette/solar) 1 2 'g:palette/solar d:create 3 #8 comma (length) 4 #11062 comma (#002b36) 5 #15657173 comma (#eee8d5) 6 #14430767 comma (#dc322f) 7 #8755456 comma (#859900) 8 #2526162 comma (#268bd2) 9 #13323030 comma (#cb4b16) 10 #11897088 comma (#b58900) 11 #7107012 comma (#6c71c4) 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (palette_default) 1 2 'g:palette/default d:create 3 #8 comma (length) 4 #0 comma (#000000) 5 #16774110 comma (#fff3de) 6 #7544320 comma (#731e00) 7 #11516072 comma (#afb8a8) 8 #2707119 comma (#294eaf) 9 #39852 comma (#009bac) 10 #15981312 comma (#f3db00) 11 #6884792 comma (#690db8) 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (palette_dark) 1 2 'g:palette/dark d:create 3 #8 comma (length) 4 #0 comma (#000000) 5 #16771265 comma (#ffe8c1) 6 #3408896 comma (#340400) 7 #7702125 comma (#75866d) 8 #465016 comma (#071878) 9 #24180 comma (#005e74) 10 #15252480 comma (#e8bc00) 11 #2818437 comma (#2b0185) 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (palette_light) 1 2 'g:palette/light d:create 3 #8 comma (length) 4 #0 comma (#000000) 5 #16776950 comma (#fffef6) 6 #15087872 comma (#e63900) 7 #14013638 comma (#d5d4c6) 8 #5412330 comma (#5295ea) 9 #63209 comma (#00f6e9) 10 #16776192 comma (#fffc00) 11 #13769197 comma (#d219ed) 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (hotkey_hints) 1 2 'g:hint-list d:create #10 comma #10 allot 3 4 :g:hints 5 [ #0 g:screen-size drop #20 n:sub g:set-cursor 6 &g:hint-list #9 a:right [ s:put sp sp ] a:for-each 7 &g:hint-list #0 a:fetch s:put ] gc ; 8 9 :g:add-hint (sn-) &s:keep dip &g:hint-list a:store ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Graphica : Screens 1 2 The Graphica screens model provides a simple way of drawing into 3 a grid. 4 5 The vocabulary is provided under the `gs:` prefix. 6 7 Loading: 8 9 '(graphica) needs 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Graphica : Screens - Reference 1 2 gs:create (wh-s) Create a grid of w columns and h rows. 3 gs:display (s-) Display a screen 4 gs:set (vxys-) Set a grid coordinate to color v 5 gs:get (xys-v) Read the color of a grid coordinate 6 gs:flush (vs-) Fill all grid cells with color v 7 gs:set-res (wh-) Update the system screen resolution. You 8 can use this to restrict the grid to a 9 subset of the actual resolution 10 gs:rescale (wh-) Update the grid scaling factors after you 11 use `gs:set-res` 12 gs:set-sep (n-) Set grid cell spacing 13 14 15 ---------------------------------------------------------------- 0 (graphica) (screens) (data-structures;_support-code) 1 2 #720 'size.w var-n 3 #720 'size.h var-n 4 'gs.separation var 5 'sh var 6 'sw var 7 8 :gs:set-resolution (wh-) !size.h !size.w ; 9 :gs:rescale (wh-) 10 @size.h swap n:div !sh @size.w swap n:div !sw ; 11 12 :gs:unpack (s-awh) 13 dup #2 n:add swap fetch-next swap fetch dup-pair gs:rescale ; 14 15 ---------------------------------------------------------------- 0 (graphica) (screens) (screen-creation;_updates) 1 2 :gs:create (wh-s) 3 here [ dup-pair swap comma comma n:mul allot ] dip ; 4 5 {{ 6 'x var 'y var 7 :gs:index 8 [ !y !x ] dip gs:unpack drop @y n:mul @x n:add n:add ; 9 ---reveal--- 10 :gs:set (vxys-) gs:index store ; 11 :gs:get (xys-v) gs:index fetch ; 12 }} 13 14 15 ---------------------------------------------------------------- 0 (graphica) (screens) (display-screen;_flush) 1 2 {{ 3 :draw-square (xy) 4 [ [ @sw n:mul ] [ @sh n:mul ] bi* dup-pair g:point 5 [ [ @sw n:add @gs.separation n:sub ] 6 [ @sh n:add @gs.separation n:sub ] bi* g:point ] dip 7 g:rect/filled g:render ] gc ; 8 ---reveal--- 9 :gs:display (s-) gs:unpack [ 10 [ [ fetch-next g:set-color I J draw-square ] indexed-times ] 11 sip ] indexed-times drop-pair ; 12 :gs:flush (vs-) gs:unpack 13 n:mul [ over [ store-next ] dip swap ] times drop-pair ; 14 }} 15 ---------------------------------------------------------------- 0 Graphica : Interface 1 2 The next set of blocks is reserved for the Graphica Interface 3 (gi: namespace) words. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Graphica : Interface 1 2 The graphica interface (gi) provides a vocabulary and scaffold 3 for writing programs using a keyboard-centric model that also 4 allows use of a pointing device (e.g., mouse) for pointing and 5 drawing. 6 7 This is not required. You can freely use the underlying graphica 8 words to develop your programs as you see fit. In writing this 9 we hope it proves useful for creating a consistent set of tools 10 and games following our design philosophy. 11 12 13 14 15 ---------------------------------------------------------------- 0 Graphica : Interface 1 2 The model used here is pretty simple. You have key handlers, 3 mouse handler, and a display. Number keys (1-0) can have hints 4 attached; these display at the bottom of the screen. The rest 5 is available for the display. 6 7 Press a key to invoke the key handler. Click the mouse button 8 to trigger the mouse handler. The display gets redrawn by the 9 display word. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (interface) (key-actions) 1 2 'gi:Actions d:create #128 allot 3 4 :gi:reset-actions (-) 5 &gi:Actions #128 [ #0 swap store-next ] times drop ; 6 7 :gi:add-action (ac-) &gi:Actions n:add store ; 8 9 :gi:get-action (c-a) &gi:Actions n:add fetch ; 10 11 :gi:perform (c-) gi:get-action dup n:-zero? &call &drop choose ; 12 13 14 15 ---------------------------------------------------------------- 0 (graphica) (interface) (1-0_hints) 1 2 'gi:hint-list d:create #10 comma #10 allot 3 4 :gi:hints 5 [ #0 g:screen-size drop #20 n:sub g:set-cursor 6 &g:hint-list #9 a:right [ s:put sp sp ] a:for-each 7 &g:hint-list #0 a:fetch s:put ] gc ; 8 9 :gi:add-hint (sn-) &s:keep dip &g:hint-list a:store ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Graphica/Terminal ---------------------------------------------- 1 2 The graphica terminal does not emulate a VT100. 3 4 Since the vt: words are useful in developing textual interfaces, 5 these blocks provide an implementation that works with graphica. 6 7 Just load (graphica:terminal) instead of (terminal) to make use 8 of these. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (graphica:terminal) 1 2 :vt:c_fix g:get-font-size nip n:mul swap 3 g:get-font-size drop n:mul swap ; 4 5 :vt:home #0 #0 g:set-cursor ; 6 :vt:row,col n:dec swap n:dec vt:c_fix g:set-cursor ; 7 :vt:up g:cursor g:get-font-size nip n:sub g:set-cursor ; 8 :vt:down g:cursor g:get-font-size nip n:add g:set-cursor ; 9 :vt:right g:cursor swap g:get-font-size 10 drop n:add swap g:set-cursor ; 11 :vt:left g:cursor swap g:get-font-size drop n:sub swap 12 g:set-cursor ; 13 14 15 ---------------------------------------------------------------- 0 (graphica:terminal) 1 2 &g:clear \vt:clear 3 4 'bg? var 5 6 (foreground (background 7 :fg:black #0 #0 !bg? ; :bg:black #0 #-1 !bg? ; 8 :fg:red #2 #0 !bg? ; :bg:red #2 #-1 !bg? ; 9 :fg:green #3 #0 !bg? ; :bg:green #3 #-1 !bg? ; 10 :fg:yellow #6 #0 !bg? ; :bg:yellow #6 #-1 !bg? ; 11 :fg:blue #4 #0 !bg? ; :bg:blue #4 #-1 !bg? ; 12 :fg:magenta #7 #0 !bg? ; :bg:magenta #7 #-1 !bg? ; 13 :fg:cyan #5 #0 !bg? ; :bg:cyan #5 #-1 !bg? ; 14 :fg:white #1 #0 !bg? ; :bg:white #1 #-1 !bg? ; 15 ---------------------------------------------------------------- 0 (graphica:terminal) 1 2 :vt:reset #3 #0 g:set-text-colors ; 3 4 :vt:set/color g:get-text-colors @bg? 5 [ drop swap ] [ nip ] choose g:set-text-colors ; 6 7 :cls g:clear #0 #0 g:set-cursor ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 ====================== USER BLOCKS BEGIN ======================= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (manual) (display) 1 2 #600 'manual:start var-n 3 #630 'manual:end var-n 4 'manual:page var 5 6 :manual:display 7 @Block vt:clear vt:home 8 @manual:page @manual:start n:add !Block load list* 9 !Block ; 10 11 :manual:constrain-page 12 @manual:page #0 @manual:end @manual:start n:sub n:dec n:limit 13 !manual:page ; 14 15 ---------------------------------------------------------------- 0 (manual) (keyboard-hints) 1 2 :manual:hints 3 'Prior #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Quit #0 ti:add-hint 6 ; 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (manual) (key-bindings) 1 2 :manual:prev &manual:page v:dec manual:constrain-page ; 3 :manual:next &manual:page v:inc manual:constrain-page ; 4 5 :manual:actions 6 &manual:prev $1 ti:set-action 7 &manual:next $2 ti:set-action 8 &ti:done $0 ti:set-action 9 ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (manual) (main-loop) 1 2 :manual 3 &manual:actions &manual:hints &manual:display ti:application ; 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (http) (serving-.plan-as-HTTP) 1 2 :respond 3 #1022 set load list# bye ; 4 5 :startup respond ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Mandelbrot Set : Rendering to ASCII 1 2 This is a port of jmf's mandelbrot set code from RetroForth 3 on nga. It's been refactored a bit, the calcuations are now 4 written in assembly. Arland has added a graphica version of this 5 in the (dusk/mandelbrot) blocks. 6 7 Loading: 8 9 '(pali) needs 10 '(mandelbrot) needs 11 12 13 14 15 ---------------------------------------------------------------- 0 (mandelbrot) (jmf's_mandlebrot) 1 2 'x var 'y var 'iter var #128 'max-iter var-n 3 'posx var 'posy var #1 'zoom var-n 4 5 :ascii-equiv (n-c) 6 #9 n:mul @max-iter n:div '_.:-=+*#%@ swap s:fetch ; 7 8 :f* n:mul #10000 n:div ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (mandelbrot) (jmf's_mandlebrot) 1 2 'a d:create 3 'lilifemu i #2 d &x r 'lifelica i &y r &f* r 'adsw.... i 4 'lifedu.. i &x r 'lica.... i &f* r 'lifedu.. i &y r 5 'lica.... i &f* r 'suadlist i &x r 'list.... i &y r 6 'lifelife i &x r &y r 'lica.... i &f* r 'lifedu.. i &y r 7 'lica.... i &f* r 'adlilica i #40000 d <eq? r 8 'lifelife i &iter r &max-iter r 'ltanre.. i 9 10 :mb:value (xy-v) #0 dup !x !y #-1 !iter 11 [ &iter v:inc dup-pair a ] while drop-pair @iter ; 12 13 14 15 ---------------------------------------------------------------- 0 (mandelbrot) (jmf's_mandlebrot) 1 2 :mb:draw/ascii 3 #25 [ 4 #80 [ 5 I #438 n:mul #25000 n:sub @zoom n:div @posx n:add 6 J #800 n:mul #10000 n:sub @zoom n:div @posy n:add 7 mb:value ascii-equiv c:put 8 ] indexed-times nl 9 ] indexed-times 10 ; 11 12 mb:draw/ascii 13 14 15 ---------------------------------------------------------------- 0 (mandelbrot) (jmf's_mandlebrot) 1 2 :zoom+ @zoom #2 n:mul !zoom ; 3 :zoom- @zoom #2 n:div #1 n:max !zoom ; 4 :up @posy #10000 @zoom n:div n:sub !posy ; 5 :down @posy #10000 @zoom n:div n:add !posy ; 6 :left @posx #10000 @zoom n:div n:sub !posx ; 7 :right @posx #10000 @zoom n:div n:add !posx ; 8 :res+ @max-iter #2 n:mul !max-iter ; 9 :res- @max-iter #2 n:div #1 n:max !max-iter ; 10 11 'done var 12 :nop ; 13 :end-viewer #-1 !done ; 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1D Cellular Automota 1 2 Assume an array of cells with an initial distribution of live 3 and dead cells, and imaginary cells off the end of the array 4 having fixed values. 5 6 Cells in the next generation of the array are calculated based 7 on the value of the cell and its left and right nearest 8 neighbours in the current generation. 9 10 If, in the following table, a live cell is represented by 1 and 11 a dead cell by 0 then to generate the value of the cell at a 12 particular index in the array of cellular values you use the 13 table in the next block. 14 15 ---------------------------------------------------------------- 0 1D Cellular Automota 1 2 000 -> 0 # 3 001 -> 0 # 4 010 -> 0 # Dies without enough neighbours 5 011 -> 1 # Needs one neighbour to survive 6 100 -> 0 # 7 101 -> 1 # Two neighbours giving birth 8 110 -> 1 # Needs one neighbour to survive 9 111 -> 0 # Starved to death. 10 11 12 To use: 13 14 '(std-library) needs 15 '(1d-cellular-automota) needs ---------------------------------------------------------------- 0 (1d-cellular-automota) 1 2 :string, (s-) dup s:length comma &comma s:for-each ; 3 4 'This d:create 5 '.###.##.#.#.#.#..#.. string, 6 7 'Next d:create 8 '.................... string, 9 10 :display (-) 11 &This s:put nl ; 12 13 :update (-) 14 &Next &This dup s:length copy ; 15 ---------------------------------------------------------------- 0 (1d-cellular-automota) 1 2 :group (a-nnn) 3 [ #1 n:add fetch ] 4 [ #2 n:add fetch ] 5 [ #3 n:add fetch ] tri ; 6 7 :evolve (nnn-c) 8 [ $# eq? ] tri@ + + 9 #-2 eq? [ $# ] [ $. ] choose ; 10 11 :at (n-na) 12 &This over + ; 13 14 :record (c-) 15 buffer:add n:inc ; ---------------------------------------------------------------- 0 (1d-cellular-automota) 1 2 :generation (-) 3 &Next buffer:set 4 #-1 &This s:length 5 [ at group evolve record ] times drop update ; 6 7 :generations (n-) 8 [ display generation ] times drop ; 9 10 #10 generations 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (conways-life) 1 2 :w/l [ $. eq? [ #0 ] [ #1 ] choose comma ] s:for-each ; 3 'World d:create 4 '.................................... w/l 5 '.................................... w/l 6 '.................................... w/l 7 '..............................o..... w/l 8 '.ooo..........................o..... w/l 9 '...o..........................o..... w/l 10 '..o................................. w/l 11 '.................................... w/l 12 '.................................... w/l 13 '..ooo............................... w/l 14 '.ooo...................ooo.......... w/l 15 '.................................... w/l ---------------------------------------------------------------- 0 (conways-life) 1 2 'Next d:create 3 #36 #12 n:mul allot 4 5 'Surrounding var 6 7 :get (rc-v) 8 dup-pair [ #0 #35 n:between? ] bi@ and 9 [ &World n:add [ #36 n:mul ] dip n:add fetch ] 10 [ drop-pair #0 ] choose ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (conways-life) 1 2 :neighbor? (rc-) get &Surrounding v:inc-by ; 3 4 :NW (rc-rc) dup-pair [ n:dec ] bi@ neighbor? ; 5 :NN (rc-rc) dup-pair [ n:dec ] dip neighbor? ; 6 :NE (rc-rc) dup-pair [ n:dec ] dip n:inc neighbor? ; 7 :WW (rc-rc) dup-pair n:dec neighbor? ; 8 :EE (rc-rc) dup-pair n:inc neighbor? ; 9 :SW (rc-rc) dup-pair [ n:inc ] dip n:dec neighbor? ; 10 :SS (rc-rc) dup-pair [ n:inc ] dip neighbor? ; 11 :SE (rc-rc) dup-pair [ n:inc ] bi@ neighbor? ; 12 13 14 15 ---------------------------------------------------------------- 0 (conways-life) 1 2 :count (rc-rcn) 3 #0 !Surrounding NW NN NE 4 WW EE 5 SW SS SE @Surrounding ; 6 7 :alive (rc-n) 8 count #2 #3 n:between? [ #1 ] [ #0 ] choose ; 9 10 :dead (rc-n) 11 count #3 eq? [ #1 ] [ #0 ] choose ; 12 13 :new-state (rc-n) 14 dup-pair get #1 eq? &alive &dead choose ; 15 ---------------------------------------------------------------- 0 (conways-life) 1 2 :set (nrc-) &Next n:add [ #36 n:mul ] dip n:add store ; 3 4 :cols (r-) 5 #36 [ I over swap new-state rot rot set ] indexed-times drop ; 6 7 :output (n-) n:-zero? [ $o ] [ $. ] choose c:put sp ; 8 9 :display (-) 10 nl &World #12 [ #36 [ fetch-next output ] times nl ] 11 times drop ; 12 13 14 15 ---------------------------------------------------------------- 0 (conways-life) 1 2 :gen (-) 3 #12 [ I cols ] indexed-times 4 &Next &World #36 #12 n:mul copy ; 5 6 {{ 7 :divide #72 [ $- c:put ] times nl 'Gen:_ s:put dup n:put nl ; 8 ---reveal--- 9 :gens (n-) #0 swap [ display divide n:inc gen ] times drop ; 10 }} 11 12 #12 gens 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (s:format) (initialization;_reading_characters) 1 2 {{ 3 'at var 'done var 'src var 4 ---reveal--- 5 :s:fmt/prepare (s-) dup s:length !done !src ; 6 :s:fmt/c (-c) @src @at s:fetch ; 7 :s:fmt/next (-) &at v:inc ; 8 :s:fmt/done? (-f) @done @at eq? ; 9 }} 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (s:format) (primary-action) 1 2 :s:fmt/insert (...s-s) 3 s:fmt/next s:fmt/c 4 's:fmt/action:_ [ #13 s:store ] sip 5 d:lookup dup n:-zero? [ d:address fetch call ] &drop choose ; 6 7 :s:fmt/process (s-) 8 s:fmt/prepare 9 [ s:fmt/c $% eq? 10 [ s:fmt/insert ] [ s:fmt/c buffer:add ] choose 11 s:fmt/next s:fmt/done? ] until drop ; 12 13 :s:format (...s-s) 14 #0 !at '_ s:temp buffer:set s:fmt/process buffer:start ; 15 ---------------------------------------------------------------- 0 (s:format) (%-actions) 1 2 :s:fmt/action:c buffer:add ; 3 :s:fmt/action:s &buffer:add s:for-each ; 4 :s:fmt/action:n n:to-s s:fmt/action:s ; 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Metablock 1 2 Additional I/O can be accessed via the metablock if your system 3 is running a metablock daemon. This is an optional way of adding 4 host-specific functionality without needing changes to the ilo 5 computer. 6 7 Block 191 is used as the metablock in my tests. 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Gopher Server (for use with inetd) 1 2 Loading this will save a modified ilo.rom that runs a little 3 Gopher server. The server will send a directory list of blocks, 4 or individual blocks, depending on the provided selector. 5 6 To make use of this, you need to run the server under inetd or 7 similar. 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (gopher-server) 1 2 :nl #13 c:put #10 c:put ; 3 :get I set load block:buffer n:dec #64 s:left ; 4 :used? dup s:first #32 -eq? ; 5 6 :type $1 c:put ; 7 :desc I n:put sp s:trim-right s:put tab ; 8 :selector $/ c:put I n:put tab ; 9 :server 'forth.works s:put tab ; 10 :port #100 n:put nl ; 11 :entry type desc selector server port ; 12 :done $. c:put nl ; 13 :process &entry &drop choose ; 14 :dir @Blocks [ get used? process ] indexed-times done ; 15 ---------------------------------------------------------------- 0 (gopher-server) 1 2 :type $i c:put ; 3 :desc #64 [ fetch-next c:put ] times tab ; 4 :line type desc selector server port ; 5 :list block:buffer #16 &line times drop done ; 6 :block dup s:first $/ eq? &s:behead if s:to-n set load list ; 7 8 :startup 9 s:get s:trim-right dup s:length 10 #0 gt? [ dup '/ s:eq? [ drop dir ] [ block ] choose ] 11 [ drop dir ] choose bye ; 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 -> ASCII Chart 1 2 After loading, run `chart` to display ASCII character codes and 3 the actual characters. Character codes are output in decimal. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Insulin Dose Calculator :: Usage 1 2 Provide details on the meal. This just requires passing the 3 values to `fat`, `protein`, and `carbs`. Then run `dose`. 4 5 Example: 6 7 #26 carbs #40 fat #30 protein dose 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (insulin-calculator) 1 2 'Carbs var 'Protein var 'Fat var 3 :carbs !Carbs ; :protein !Protein ; :fat !Fat ; 4 5 :dose:carbs 6 @Carbs #10 n:mul #15 n:divmod n:put $. c:put n:put nl ; 7 8 :scale #10 n:mul ; 9 :dose:protein&fat @Fat @Protein [ scale ] bi@ #4 n:div 10 swap #10 n:div n:add #50 n:divmod 11 n:put $. c:put n:put nl ; 12 13 :dose dose:carbs dose:protein&fat ; 14 15 ---------------------------------------------------------------- 0 (crc/insulin-cost) 1 2 . I am a diabetic, and use insulin. This is a small utility I 3 . wrote to help me track the cost of the insulin & supplies I 4 . use. 5 6 . You will need to adjust these for your specific insulin type 7 . and needle costs. 8 9 :cost/pen #9.00 ; 10 :cost/needle #0.10 ; 11 :cost/unit cost/pen #300 f:div ; 12 13 :units (n-f) ; 14 :cost (f-) cost/unit f:mul cost/needle f:add f:put nl ; 15 ---------------------------------------------------------------- 0 (denney/transformer-ampacity) 1 2 . To find the KVA on a 3 phase transformer, we use a formula: 3 . 4 . KVA = (V * A * 1.73) / 1000 5 . 6 . I'm using fixed point math to implement this. 7 8 :scale #100 n:mul ; 9 :kva #1000 n:mul scale #173 n:div ; 10 :v n:div ; 11 :amps n:put nl ; 12 13 . Example: 14 . 15 . #30 kva #208 v amps ---------------------------------------------------------------- 0 sea level rise : a calculation 1 2 The next block contains some quick calculations on the potential 3 increase in the ocean levels if the Antartic and Greenland ice 4 sheets were to melt. 5 6 This derives from conversation in the #forth irc channel. See 7 http://forthworks.com/forth/irc-logs/19.12.30 for the log from 8 that conversation. 9 10 Source Data (via https): 11 12 www.the-cryosphere.net/7/375/2013/tc-7-375-2013.pdf 13 web.viu.ca/earle/geol305/The%20Greenland%20Ice%20Sheet.pdf 14 www.realworldvisuals.com/blog-1/could-rocks-cause-sea-levels-to- 15 rise ---------------------------------------------------------------- 0 (example/sea-level-rise) 1 2 :ice:ANTARTIC #26540000 ; (from_the_bedrock2_survey 3 :ice:GREENLAND #2900000 ; (from_web.viu.ca/earle/geol305 4 :ice:total ice:ANTARTIC ice:GREENLAND n:add ; 5 :ice:rise ice:total #361 n:div ; 6 :ice:rise ice:rise #1000 n:div ; 7 :ice:rise ice:rise #91 n:mul #100 n:div ; 8 9 ice:total 'Total_volume_(km^3):_ s:put n:put nl 10 ice:rise 'Rise_(mm):___________ s:put n:put nl 11 ice:rise 'Rise_(m):____________ s:put n:put nl nl 12 13 ice:rise 'Rise_(m,_adjusted_for_density):_ s:put n:put nl 14 15 ---------------------------------------------------------------- 0 (example/s:palindrome?) 1 2 :s:palindrome? (s-f) [ s:hash ] [ s:reverse s:hash ] bi eq? ; 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (example/s:pangram?) 1 2 {{ 3 :FULL 'abcdefghijklmnopqrstuvwxyz ; 4 :TEST '__________________________ ; 5 ---reveal--- 6 :s:pangram? (s-f) 7 '__________________________ TEST #27 copy 8 s:to-lower [ c:letter? ] s:filter 9 [ dup $a - TEST swap s:store ] s:for-each 10 TEST FULL s:eq? ; 11 }} 12 13 14 15 ---------------------------------------------------------------- 0 (example/ascii-table) 1 2 :pad dup n:to-s s:length #3 swap n:sub [ sp ] times ; 3 4 :col I pad n:put sp 5 I #32 gt? [ sp I c:put sp ] [ sp sp sp ] choose tab ; 6 :row col I #9 n:mod n:zero? &nl if ; 7 :ascii-table #128 [ row ] indexed-times nl ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 rem : a visual block editor 1 2 This is a visual, command-oriented block editor. It builds on 3 the minimalist block editor included with Retro, adding useful 4 things like a visual display, shortcut key text, movable cursor, 5 and entry without erasing entire lines. 6 7 The editor commands are modular and can be extended at any time. 8 9 Dependencies: 10 11 - (terminal) or (graphica:terminal) 12 13 Note that this works best with a terminal that properly breaks 14 after each entered character. On Unix, this can be enabled by 15 running `stty cbreak` prior to starting. ---------------------------------------------------------------- 0 rem : a visual block editor : default key bindings 1 2 +-----+------------+-----+------------+ 3 | Key | Action | Key | Action | 4 +=====+============+=====+============+ 5 | 1 | Save Block | 2 | Load Block | 6 | 3 | Prev Block | 4 | Next Block | 7 | 5 | Run Block | 6 | Left | 8 | 7 | Right | 8 | Down | 9 | 9 | Up | 0 | Enter Here | 10 | q | Quit | | | 11 +-----+------------+-----+------------+ 12 13 Above is the default key bindings. Additional key bindings for 14 specific keyboard layouts will be provided as separate blocks. 15 ---------------------------------------------------------------- 0 (rem) (a-visual-block-editor) (display) 1 2 'rem:col var 'rem:row var 'rem:mode var 3 4 :rem:cursor @rem:row #2 n:add @rem:col n:inc dup-pair 5 vt:row,col $* c:put vt:row,col ; 6 7 {{ 8 :redraw vt:home list* ; 9 :sep #64 [ $- c:put ] times nl ; 10 :hints '1:Save_2:Load_3:Prev_4:Next_5:Eval_6:Left_ s:put 11 '7:Right_8:Down_9:Up_0:Entry s:put nl ; 12 :status sys:info hints ; 13 ---reveal--- 14 :rem:display vt:home sep redraw sep status rem:cursor ; 15 }} ---------------------------------------------------------------- 0 (rem) (a-visual-block-editor) (command-processing) 1 2 {{ 3 'done var 4 :command 'rem:cmd:_ ; 5 :process command #8 s:store 6 command d:lookup [ command interpret ] if ; 7 ---reveal--- 8 :rem cls #0 !done [ rem:display c:get process @done ] until ; 9 :rem:cmd:q #-1 !done cls ; 10 }} 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem) (a-visual-block-editor) (navigation) 1 2 &prev dup \rem:cmd:3 \rem:cmd:, 3 &next dup \rem:cmd:4 \rem:cmd:. 4 5 :constrain @rem:row #0 #15 n:limit !rem:row 6 @rem:col #0 #63 n:limit !rem:col ; 7 8 :rem:cmd:9 &rem:row v:dec constrain ; 9 :rem:cmd:6 &rem:col v:dec constrain ; 10 :rem:cmd:8 &rem:row v:inc constrain ; 11 :rem:cmd:7 &rem:col v:inc constrain ; 12 13 14 15 ---------------------------------------------------------------- 0 (rem) (a-visual-block-editor) (text-entry) 1 2 {{ 3 :target @rem:row #64 n:mul @rem:col n:add block:buffer n:add ; 4 :insert target swap [ over store n:inc ] s:for-each drop ; 5 ---reveal--- 6 :rem:cmd:0 rem:cursor s:get/line insert cls ; 7 }} 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem) (a-visual-block-editor) (block-evaluation,_save/load) 1 2 :rem:cmd:5 run ; 3 &save \rem:cmd:1 4 &load \rem:cmd:2 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 rem : a visual block editor : addition key bindings 1 2 The next several blocks contain additional sets of key bindings 3 for a number of common layouts (dvorak, qwerty, colmak, workman) 4 5 The keys are all in the primary alpha area. This is laid out as: 6 7 .**.. ..*.. 8 *.... .***. 9 *...* **... 10 11 There are numerous keys left open on the left hand. I'll look at 12 attaching some of these to other functions in the future. 13 14 15 ---------------------------------------------------------------- 0 (rem:dvorak) (a-visual-block-editor) (dvorak-bindings) 1 2 &rem:cmd:1 \rem:cmd:b &rem:cmd:2 \rem:cmd:m 3 &rem:cmd:3 \rem:cmd:, &rem:cmd:4 \rem:cmd:. 4 &rem:cmd:5 \rem:cmd:x &rem:cmd:6 \rem:cmd:h 5 &rem:cmd:7 \rem:cmd:n &rem:cmd:8 \rem:cmd:t 6 &rem:cmd:9 \rem:cmd:c &rem:cmd:0 \rem:cmd:a 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem:qwerty) (a-visual-block-editor) (qwerty-bindings) 1 2 &rem:cmd:1 \rem:cmd:n &rem:cmd:2 \rem:cmd:m 3 &rem:cmd:3 \rem:cmd:w &rem:cmd:4 \rem:cmd:e 4 &rem:cmd:5 \rem:cmd:x &rem:cmd:6 \rem:cmd:j 5 &rem:cmd:7 \rem:cmd:l &rem:cmd:8 \rem:cmd:k 6 &rem:cmd:9 \rem:cmd:i &rem:cmd:0 \rem:cmd:b 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem:colmak) (a-visual-block-editor) (colmak-bindings) 1 2 &rem:cmd:1 \rem:cmd:b &rem:cmd:2 \rem:cmd:k 3 &rem:cmd:3 \rem:cmd:w &rem:cmd:4 \rem:cmd:f 4 &rem:cmd:5 \rem:cmd:b &rem:cmd:6 \rem:cmd:h 5 &rem:cmd:7 \rem:cmd:e &rem:cmd:8 \rem:cmd:n 6 &rem:cmd:9 \rem:cmd:l &rem:cmd:0 \rem:cmd:q 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem:workman) (a-visual-block-editor) (workman-bindings) 1 2 &rem:cmd:1 \rem:cmd:k &rem:cmd:2 \rem:cmd:l 3 &rem:cmd:3 \rem:cmd:d &rem:cmd:4 \rem:cmd:w 4 &rem:cmd:5 \rem:cmd:v &rem:cmd:6 \rem:cmd:n 5 &rem:cmd:7 \rem:cmd:o &rem:cmd:8 \rem:cmd:e 6 &rem:cmd:9 \rem:cmd:u &rem:cmd:0 \rem:cmd:a 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 paint2 by Arland Childers 1 2 This is a simple drawing application using the Graphica words. 3 to use it, make sure your system supports Graphica, and load 4 Graphica prior to running. 5 6 '(graphica) needs '(paint2) needs 7 8 Tho above should load everything needed. To run, execute paint2 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (paint2) 1 'px var 'py var 'done var 'cx var 'cy var 2 3 :cursor (-xy) (returns_x_and_y_for_mouse) 4 g:mouse drop ; 5 6 :button (-b) (returns_the_button_state_of_the_mouse) 7 g:mouse nip nip ; 8 9 :set-color (-) (selects_the_drawing_colors) 10 @cx #50 lteq? [ cursor g:color/pixel g:set-color ] if ; 11 12 13 :set-cursor (-) (sets_the_drawing_cursor) 14 cursor !cy !cx ; 15 ---------------------------------------------------------------- 0 (paint2) 1 :set-prev (-) (saves_current_pos_to_buffer) 2 @cx @cy !py !px ; 3 4 :draw-rect g:line g:render ; 5 6 :tick (-) (draws_the_line) 7 @Free set-color 8 < @px n:inc @py > < @cx n:inc @cy > draw-rect 9 < @px @py n:inc > < @cx @cy n:inc > draw-rect 10 < @px @py n:dec > < @cx @cy n:dec > draw-rect 11 < @px n:dec @py > < @cx n:dec @cy > draw-rect 12 < @px @py > < @cx @cy > draw-rect !Free ; 13 14 15 :rect (cpp-) rot g:set-color g:rect/filled g:render ; ---------------------------------------------------------------- 0 (paint2) 1 2 :draw-palette (-) 3 #0 < #0 #0 > < #50 #50 > rect 4 #1 < #0 #50 > < #50 #100 > rect 5 #2 < #0 #100 > < #50 #150 > rect 6 #3 < #0 #150 > < #50 #200 > rect 7 #4 < #0 #200 > < #50 #250 > rect 8 #5 < #0 #250 > < #50 #300 > rect 9 #6 < #0 #300 > < #50 #350 > rect 10 #7 < #0 #350 > < #50 #400 > rect ; 11 12 :color-line (-) (draws_the_color_selector_line) 13 < #50 #0 > g:screen-size drop #45 n:sub g:vline g:render ; 14 15 ---------------------------------------------------------------- 0 (paint2) 1 2 :setup-gui (-) (sets_up_the_gui) 3 [ draw-palette #0 g:set-color color-line 4 < #0 g:screen-size drop #45 n:sub > 5 g:screen-size nip g:hline g:render 6 ] gc ; 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (paint2) 1 2 3 '1:Fill #1 g:add-hint 4 '2:Add_Text #2 g:add-hint 5 '3:light #3 g:add-hint 6 '4:standard #4 g:add-hint 7 '5:dark #5 g:add-hint 8 '6:solar #6 g:add-hint 9 '7: #7 g:add-hint 10 '8: #8 g:add-hint 11 '9:Refresh_UI #9 g:add-hint 12 '0:Quit #0 g:add-hint 13 14 15 :setup set-cursor setup-gui g:hints #-1 !done ; ---------------------------------------------------------------- 0 (paint2) 1 2 3 :key? (cq-) [ [ g:keypress ] dip eq? ] dip if ; 4 5 :paint2 (-) (main_loop) 6 g:clear setup #0 g:set-color 7 [ g:keypress #32 -eq? &set-cursor if 8 button &tick if 9 set-prev 10 $0 [ #0 !done ] key? 11 $1 [ cursor g:fill/diff ] key? 12 $2 [ cursor g:set-cursor s:get/line drop ] key? 13 $3 [ &g:palette/light g:set-palette ] key? 14 $4 [ &g:palette/default g:set-palette ] key? 15 $5 [ &g:palette/dark g:set-palette ] key? ---------------------------------------------------------------- 0 (paint2) 1 $6 [ &g:palette/solar g:set-palette ] key? 2 $9 [ g:color/current setup g:set-color ] key? 3 @done ] while ; 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (*) (shortcuts_for_loading_programs) 1 2 :*graphica '(graphica) needs '(graphica:terminal) needs ; 3 :*termina '(termina) needs ; 4 :*fs '(fs) needs '(fs-ext) needs ; 5 :*unu '(unu) needs ; 6 :*pali '(pali) needs ; 7 :*bad '(bad) needs ; 8 :*ll '(ll) needs ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (*) (shortcuts_for_loading_programs) 1 2 :*rem *terminal '(rem) needs ; 3 :*rem/g *graphica '(rem) needs ; 4 :*paint2 *graphica '(paint2) needs ; 5 :*paint3 *graphica '(paint3) needs ; 6 7 :*nonix *fs '(nonix) needs ; 8 9 :*ascii-table '(ascii-table) needs ; 10 :*insulin '(insulin-calculator) needs '(insulin-cost) needs ; 11 12 13 14 :*rarangi *terminal '(rarangi) needs ; 15 :*rarangi/g *graphica '(rarangi) needs ; ---------------------------------------------------------------- 0 paint3 : a more advanced drawing program by Arland Childers 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 paint3 : image format 1 2 Images made with paint3 are 360x360, with three bits per pixel. 3 Ten pixels are packed into each cell of memory. 4 5 Memory Usage: 6 7 360 x 360 = 129,600 pixels 8 129,600 / 10 = 12,960 cells of memory 9 10 This will consume 14 blocks of memory 11 12 Images will use the first line to store metadata, followed by 13 the actual bitmap data. 14 15 ---------------------------------------------------------------- 0 paint3 : image metadata 1 2 Each block of a saved image will start with some metadata. This 3 is stored in the first line of each block used. Doing this lets 4 `titles` continue to be usable. 5 6 Metadata Format 7 8 image : 360x360 : description 339184372 9 ^^^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ 10 title size free-form description text 11 12 The number at the end is the hash of `paint3`, used to let the 13 paint3 application know this is image data. 14 15 ---------------------------------------------------------------- 0 paint3 : todo 1 2 - pixel drawing that updates the Drawing 3 - identify cell containing pixel data 4 - unpack it 5 - replace the value being altered 6 - pack it 7 - store the updated cell 8 - write Drawing to blocks 9 - words to set the metadata 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (paint3) (data-structures) 1 2 'Drawing d:create #13440 allot (padded_to_14_blocks,_less_title) 3 4 'Description var 5 6 'TargetBlock var 7 8 9 10 11 12 13 14 :height #360 ; 15 :width #360 ; ---------------------------------------------------------------- 0 (paint3) (packing-pixel-data) 1 2 :pack (nnnnnnnnnn-n) #10 [ #3 shift-left n:add ] times ; 3 :unpack (n-nnnnnnnnnn) 4 #10 [ dup #7 and swap #3 shift-right ] times #7 and ; 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (paint3) (pixel-drawing) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (paint3) (write-to-blocks) 1 2 {{ 3 :to-block @TargetBlock I n:add set new ; 4 :set-metadata 5 'image_360x360_:_ @Description s:append 6 block:buffer over s:length [ [ n:inc ] dip ] dip copy 7 '_339184372 n:inc block:buffer #54 n:add #10 copy ; 8 :save-segment 9 to-block set-metadata 10 &Drawing I #960 n:mul n:add 11 block:buffer #64 n:add #960 copy save ; 12 ---reveal--- 13 :save-drawing #14 &save-segment indexed-times ; 14 }} 15 ---------------------------------------------------------------- 0 (paint3) (update-metadata) 1 2 :set-desc s:keep !Description ; 3 :set-target !TargetBlock ; 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (dusk/mandelbrot) (display) 1 2 :graphical-equiv (n-n) #7 n:mul @max-iter n:div ; 3 4 :mb:draw/graphical g:clear 5 [ #7 g:set-color < #0 #0 > < #641 #481 > g:rect g:render ] gc 6 #480 [ (height 7 #640 [ (width 8 I #50 n:mul #25000 n:sub @zoom n:div @posx n:add 9 J #50 n:mul #12000 n:sub @zoom n:div @posy n:add 10 mb:value graphical-equiv g:set-color I J g:draw-pixel 11 ] indexed-times 12 ] indexed-times ; 13 14 15 ---------------------------------------------------------------- 0 (dusk/mandelbrot) (keybindings) 1 2 'mb:actions d:create 3 &end-viewer comma 4 &zoom- comma 5 &zoom+ comma 6 &up comma 7 &down comma 8 &left comma 9 &right comma 10 &res+ comma 11 &res- comma 12 &nop comma 13 14 15 ---------------------------------------------------------------- 0 (dusk/mandelbrot) (keyboard-hints) 1 2 '0:exit #0 g:add-hint 3 '1:zoom- #1 g:add-hint 4 '2:zoom+ #2 g:add-hint 5 '3:up #3 g:add-hint 6 '4:down #4 g:add-hint 7 '5:left #5 g:add-hint 8 '6:right #6 g:add-hint 9 '7:res+ #7 g:add-hint 10 '8:res- #8 g:add-hint 11 '9:_ #9 g:add-hint 12 13 14 15 ---------------------------------------------------------------- 0 (dusk/mandelbrot) (application-loop) 1 2 :mb:input 3 c:get dup $0 $9 n:between? 4 [ $0 n:sub &mb:actions n:add fetch call ] 5 [ drop ] choose ; 6 7 :mb:stats 8 #50 #500 g:set-cursor 9 'x: s:put @posx n:put '__y: s:put @posy n:put 10 '__res: s:put @max-iter n:put 11 '__zoom: s:put @zoom n:put ; 12 13 :run:mandelbrot 14 #0 !done [ mb:draw/graphical g:hints mb:stats 15 mb:input @done ] until ; ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 g/life : Conway's Life, for Graphica 1 2 Dependencies: 3 4 '(graphica) needs 5 '(std-library) needs 6 7 Loading: 8 9 '(g/life) needs 10 run:life 11 12 13 14 15 ---------------------------------------------------------------- 0 (g/life) (world-map-1/2) 1 2 :w/l [ $. eq? [ #0 ] [ #1 ] choose comma ] s:for-each ; 3 4 'World d:create 5 '.................................... w/l 6 '.................................... w/l 7 '.................................... w/l 8 '.................................... w/l 9 '.................................... w/l 10 '.................................... w/l 11 '.................................... w/l 12 '.................................... w/l 13 '.................................... w/l 14 '..............oo.................... w/l 15 '..............oo.................... w/l ---------------------------------------------------------------- 0 (g/life) (world-map-2/2) 1 2 '....oo.............................. w/l 3 '....oo........oooo.................. w/l 4 '.............o.o..o.oo.............. w/l 5 '....oooo.....o..o.o.oo.............. w/l 6 '...o....o.oo.o..o.o................. w/l 7 '...o...oo.oo.o....o................. w/l 8 'oo.o.oo.o.....oooo.................. w/l 9 'oo.o....o........................... w/l 10 '....oooo........oo.................. w/l 11 '................oo.................. w/l 12 '......oo............................ w/l 13 '......oo............................ w/l 14 '.................................... w/l 15 ---------------------------------------------------------------- 0 (g/life) (buffer-for-next-generation;_get-cell-data) 1 2 #36 allot 3 4 'Next d:create 5 #36 #24 n:mul allot 6 7 'Surrounding var 8 9 :get (rc-v) 10 dup-pair [ #0 #35 n:between? ] bi@ and 11 [ &World n:add [ #36 n:mul ] dip n:add fetch ] 12 [ drop-pair #0 ] choose ; 13 14 :neighbor? (rc-) get &Surrounding v:inc-by ; 15 ---------------------------------------------------------------- 0 (g/life) (counting-surrounding-cells) 1 2 :NW (rc-rc) dup-pair [ n:dec ] bi@ neighbor? ; 3 :NN (rc-rc) dup-pair [ n:dec ] dip neighbor? ; 4 :NE (rc-rc) dup-pair [ n:dec ] dip n:inc neighbor? ; 5 :WW (rc-rc) dup-pair n:dec neighbor? ; 6 :EE (rc-rc) dup-pair n:inc neighbor? ; 7 :SW (rc-rc) dup-pair [ n:inc ] dip n:dec neighbor? ; 8 :SS (rc-rc) dup-pair [ n:inc ] dip neighbor? ; 9 :SE (rc-rc) dup-pair [ n:inc ] bi@ neighbor? ; 10 11 :count (rc-rcn) 12 #0 !Surrounding NW NN NE 13 WW EE 14 SW SS SE @Surrounding ; 15 ---------------------------------------------------------------- 0 (g/life) (determine-new-state) 1 2 :alive (rc-n) 3 count #2 #3 n:between? [ #1 ] [ #0 ] choose ; 4 5 :dead (rc-n) 6 count #3 eq? [ #1 ] [ #0 ] choose ; 7 8 :new-state (rc-n) 9 dup-pair get #1 eq? &alive &dead choose ; 10 11 :set (nrc-) &Next n:add [ #36 n:mul ] dip n:add store ; 12 :get (rc-n) &Next n:add [ #36 n:mul ] dip n:add fetch ; 13 14 :cols (r-) 15 #36 [ I over swap new-state rot rot set ] indexed-times drop ; ---------------------------------------------------------------- 0 (g/life) (draw-world) 1 2 :draw-square (vxy) 3 [ dup-pair [ #18 n:add ] bi@ &n:inc dip g:point &g:point dip 4 g:rect/filled g:render ] gc ; 5 6 'x 'y var var 7 8 :g/display (-) 9 #1 dup !x !y &World #24 [ 10 #36 [ 11 fetch-next n:-zero? [ #1 ] [ #7 ] choose g:set-color 12 @x @y draw-square #20 &x v:inc-by 13 ] times #20 &y v:inc-by #1 !x ] 14 times drop ; 15 ---------------------------------------------------------------- 0 (g/life) (process-generation;_basic_hints) 1 2 :gen (-) 3 #24 [ I cols ] indexed-times 4 &Next &World #36 #24 n:mul copy ; 5 6 :base-hints 7 '0:exit #0 g:add-hint '1:next #1 g:add-hint 8 '2: #2 g:add-hint '3:pause #3 g:add-hint 9 '4: #4 g:add-hint '5:edit #5 g:add-hint 10 '6: #6 g:add-hint '7: #7 g:add-hint 11 '8: #8 g:add-hint '9: #9 g:add-hint ; 12 13 14 15 ---------------------------------------------------------------- 0 (g/life) (editor-hints) 1 2 :edit-hints 3 '0:exit #0 g:add-hint '1:light #1 g:add-hint 4 '2:dark #2 g:add-hint '3: #3 g:add-hint 5 '4: #4 g:add-hint '5:stop_editing #5 g:add-hint 6 '6: #6 g:add-hint '7: #7 g:add-hint 7 8 '8: #8 g:add-hint '9: #9 g:add-hint ; 9 10 :display_one 11 g/display gen ; 12 13 14 15 ---------------------------------------------------------------- 0 (g/life) (some-ui;_support-for-editor) 1 2 #1 'Color var 3 4 :reset-cursor #25 #525 g:set-cursor ; 5 :moved? #-1 ; 6 :valid? (rc-rcf) dup-pair 7 #0 #23 n:between? [ #0 #35 n:between? ] dip and ; 8 9 :set-cell @Color swap [ swap ] dip swap set ; 10 11 :mouse-to-grid 12 [ #20 n:div ] bi@ (swap ; 13 14 :update-world 15 &Next &World #36 #24 n:mul copy g/display ; ---------------------------------------------------------------- 0 (g/life) (editor-core) 1 2 :edit-screen g:mouse update-world 3 [ mouse-to-grid valid? 4 [ set-cell ] 5 [ drop-pair ] choose 6 ] 7 [ drop-pair ] choose 8 g:keypress dup $1 eq? [ #1 !Color ] if 9 $2 eq? [ #0 !Color ] if ; 10 11 :g:wait-for-keyup [ g:keypress ] while ; 12 13 14 15 ---------------------------------------------------------------- 0 (g/life) (editor-loop;_status-bar) 1 2 'done? var 'paused? var 'editing? var 3 4 :status reset-cursor @paused? @editing? dup-pair 5 or [ 'Running s:put ] -if reset-cursor 6 not and [ 'Paused_ s:put ] if reset-cursor 7 @editing? [ 'Editing s:put ] if ; 8 9 :editloop #-1 !editing? edit-hints g:hints status 10 g:wait-for-keyup 11 [ edit-screen g:keypress $5 eq? ] until 12 base-hints g:hints #0 !editing? '_________ s:put ; 13 14 15 ---------------------------------------------------------------- 0 (g/life) (primary-actions) 1 2 :a0 #-1 !done? ; 3 :a1 display_one ; 4 :a2 ; 5 :a3 @paused? not !paused? ; 6 :a4 ; 7 :a5 editloop g:wait-for-keyup ; 8 9 'Actions d:create 10 &a0 comma 11 &a1 comma 12 &a2 comma 13 &a3 comma 14 &a4 comma 15 &a5 comma ---------------------------------------------------------------- 0 (g/life) (primary-interface-loop) 1 2 :input 3 g:keypress $0 $5 n:between? 4 [ g:keypress $0 n:sub &Actions n:add fetch 5 g:wait-for-keyup call ] if ; 6 7 :actions [ input status @paused? ] while ; 8 9 :prep #0 !done? #0 !paused? g:clear base-hints g:hints status ; 10 11 :run:life prep 12 [ [ display_one actions ] gc @done? ] until ; 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (packed-strings) (requires: (bad) ) 1 2 {{ 3 's:null d:create #1 comma #0 comma 4 :pad? (s-sf) dup s:length #4 n:mod n:-zero? ; 5 :pad (s-s) #3 [ pad? [ &s:null s:append ] if ] times ; 6 :group (s-ns) #4 [ fetch-next swap ] times &b:pack dip ; 7 :prepare (s-an) pad &n:inc [ s:length #4 n:div ] bi ; 8 :condense (s-) 9 here [ dup comma [ group swap comma ] times drop ] dip ; 10 ---reveal--- 11 :s:pack (s-p) prepare &condense gc s:temp ; 12 }} 13 14 15 ---------------------------------------------------------------- 0 (packed-strings) (requires: (bad) ) 1 2 {{ 3 :ungroup (n-) 4 b:unpack swap [ [ swap comma comma ] dip comma ] dip comma ; 5 :resize (a-s) here over n:sub n:dec over [ swap store ] dip ; 6 :expand (p-a) here [ #0 comma &ungroup a:for-each ] dip ; 7 ---reveal--- 8 :s:unpack (p-a) [ expand resize ] gc s:temp ; 9 }} 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (unnamed) 1 2 :def ("name") s:get/token sigil:: ; 3 :return (-) &; call ; immediate 4 :int ("name") s:get/token var ; 5 :let ("name","=","value") s:get/token d:lookup d:address fetch 6 s:get/token drop s:get/token s:to-n 7 swap store ; 8 9 10 int a 11 int b 12 let a = 100 13 let b = 200 14 @a n:put tab @b n:put nl 15 ---------------------------------------------------------------- 0 (aoc:2022.02-part1) 1 2 :, s:hash comma ; 3 4 'Matches d:create 5 #9 comma 'AX , 'AY , 'AZ , 'BX , 'BY , 'BZ , 'CX , 'CY , 'CZ , 6 7 'Outcomes d:create 8 #9 comma #4 comma #8 comma #3 comma 9 #1 comma #5 comma #9 comma 10 #7 comma #2 comma #6 comma 11 12 :seek (ss-n) s:append s:hash &Matches swap a:index ; 13 :result (nn-n) &Outcomes swap a:fetch n:add ; 14 :A 'A ; :B 'B ; :C 'C ; 15 :X 'X seek result ; :Y 'Y seek result ; :Z 'Z seek result ; ---------------------------------------------------------------- 0 (aoc:2022.02-part2) 1 2 :, s:hash comma ; 3 4 'Matches d:create 5 #9 comma 'AX , 'AY , 'AZ , 'BX , 'BY , 'BZ , 'CX , 'CY , 'CZ , 6 7 'Outcomes d:create 8 #9 comma #3 comma #4 comma #8 comma 9 #1 comma #5 comma #9 comma 10 #2 comma #6 comma #7 comma 11 12 :seek (ss-n) s:append s:hash &Matches swap a:index ; 13 :result (nn-n) &Outcomes swap a:fetch n:add ; 14 :A 'A ; :B 'B ; :C 'C ; 15 :X 'X seek result ; :Y 'Y seek result ; :Z 'Z seek result ; ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (configuration) 1 2 &fg:cyan 'tuhi:cfg/colors,line# var-n 3 &fg:red 'tuhi:cfg/colors,sep var-n 4 &bg:blue 'tuhi:cfg/colors,bg var-n 5 &fg:white 'tuhi:cfg/colors,fg var-n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (display) 1 2 {{ 3 :colorize call vt:set/color ; 4 :line# @tuhi:cfg/colors,line# colorize I $a n:add c:put ; 5 :sep @tuhi:cfg/colors,sep colorize '_|_ s:put ; 6 :text @tuhi:cfg/colors,bg colorize 7 @tuhi:cfg/colors,fg colorize I e:line ; 8 :reset bg:black vt:set/color fg:white vt:set/color ; 9 ---reveal--- 10 :tuhi:display (-) 11 vt:clear vt:home 12 #16 [ line# sep text reset ] indexed-times ; 13 }} 14 15 ---------------------------------------------------------------- 0 (tuhi) (key-actions) 1 2 :tuhi:9 #4 edit ; 3 :tuhi:a #1 #5 vt:row,col 0 ; :tuhi:b #1 #5 vt:row,col 1 ; 4 :tuhi:c #3 #5 vt:row,col 2 ; :tuhi:d #4 #5 vt:row,col 3 ; 5 :tuhi:e #5 #5 vt:row,col 4 ; :tuhi:f #6 #5 vt:row,col 5 ; 6 :tuhi:g #7 #5 vt:row,col 6 ; :tuhi:h #8 #5 vt:row,col 7 ; 7 :tuhi:i #9 #5 vt:row,col 8 ; :tuhi:j #10 #5 vt:row,col 9 ; 8 :tuhi:k #11 #5 vt:row,col 10 ; :tuhi:l #12 #5 vt:row,col 11 ; 9 :tuhi:m #13 #5 vt:row,col 12 ; :tuhi:n #14 #5 vt:row,col 13 ; 10 :tuhi:o #15 #5 vt:row,col 14 ; :tuhi:p #16 #5 vt:row,col 15 ; 11 :tuhi:3 s:get/line s:to-n !Block load ; 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (keys-actions) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (key-actions) 1 2 :tuhi:actions (-) 3 &prev $1 ti:set-action &next $2 ti:set-action 4 &run $5 ti:set-action &ti:done $0 ti:set-action 5 &tuhi:9 $9 ti:set-action 6 &tuhi:a $a ti:set-action &tuhi:b $b ti:set-action 7 &tuhi:c $c ti:set-action &tuhi:d $d ti:set-action 8 &tuhi:e $e ti:set-action &tuhi:f $f ti:set-action 9 &tuhi:g $g ti:set-action &tuhi:h $h ti:set-action 10 &tuhi:i $i ti:set-action &tuhi:j $j ti:set-action 11 &tuhi:k $k ti:set-action &tuhi:l $l ti:set-action 12 &tuhi:m $m ti:set-action &tuhi:n $n ti:set-action 13 &tuhi:o $o ti:set-action &tuhi:p $p ti:set-action 14 &save $6 ti:set-action &load $7 ti:set-action 15 &tuhi:3 $3 ti:set-action ; ---------------------------------------------------------------- 0 (tuhi) (hints) 1 2 :tuhi:hints (-) 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Save #6 ti:add-hint 6 'Load #7 ti:add-hint 7 'Quit #0 ti:add-hint 8 'Run #5 ti:add-hint 9 'Help #9 ti:add-hint 10 'Jump_To #3 ti:add-hint 11 ; 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (main-loop) 1 2 :tuhi (-) 3 &tuhi:actions &tuhi:hints &tuhi:display ti:application ; 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 rarangi : managing the blocks 1 2 This is a collection of tools for organizing the blocks. 3 4 Functionality desired: 5 6 - move (or copy) blocks to a new area 7 - swap contents of blocks 8 - remove unused blocks in range (shifting later blocks to fill) 9 - list blocks matching starting string 10 - easily launch editor on a block 11 - browse through the blocks 12 - find unused block 13 14 15 ---------------------------------------------------------------- 0 rarangi : managing the blocks : shortcuts 1 2 +-----+----------------------------+-----+---------------------- 3 | Key | Action | Key | Action 4 +=====+============================+=====+====================== 5 | 1 | Edit | 2 | Display 6 | 3 | Previous | 4 | Next 7 | 5 | Run Current | 6 | Run All In Set 8 | 7 | Copy To | 8 | Move To 9 | 9 | | 0 | Erase 10 +-----+----------------------------+-----+---------------------- 11 12 13 14 15 ---------------------------------------------------------------- 0 rarangi : todo 1 2 - display titles from block range 3 - move selector up/down 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rarangi) (a-block-manager) (display-list) 1 2 'rarangi:current var 3 4 :list-blocks 5 @rarangi:current #16 [ dup set load #64 block:buffer n:dec 6 store block:buffer n:dec sp sp s:put nl n:inc ] times ; 7 8 :next-set @rarangi:current #16 n:add !rarangi:current ; 9 :prev-set @rarangi:current #16 n:dec !rarangi:current ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rarangi) 1 2 'rarangi:current var 3 4 {{ 5 :.block @Block 6 [ n:put ] [ n:to-s s:length #4 swap n:sub &sp times ] bi ; 7 :.name @Block set load 8 #64 block:buffer n:dec [ store ] sip s:put nl ; 9 :.cursor 10 @rarangi:current @Block eq? [ $* c:put ] [ sp ] choose sp ; 11 :describe .cursor .block sp .name ; 12 ---reveal--- 13 :list-blocks @rarangi:current #16 [ I set describe ] 14 indexed-times ; 15 }} ---------------------------------------------------------------- 0 (rarangi) (move,_copy_blocks) 1 2 {{ 3 :relocate over set load dup set save ; 4 :erase over set new save ; 5 :next &n:inc bi@ ; 6 ---reveal--- 7 :move-blocks (from,to,count) 8 [ relocate erase next ] times drop-pair ; 9 :copy-blocks (from,to,count) 10 [ relocate next ] times drop-pair ; 11 }} 12 13 14 15 ---------------------------------------------------------------- 0 (rarangi) (blocks-matching) 1 2 :blocks-matching (s-) 3 [ s:keep @Blocks 4 [ I set load block:buffer n:dec over s:begins-with? 5 [ I n:put tab #0 e:line ] if ] indexed-times drop ] gc ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rarangi) (block-usage-stats) 1 2 #-967633659 'empty var-n 3 4 :get-usage (-nn) 5 #0 #0 @Blocks 6 [ I set load block:buffer n:dec s:hash @empty eq? 7 &n:inc [ &n:inc dip ] choose ] indexed-times ; 8 9 :block-stats (-) 10 get-usage 11 [ 'Used:___ s:put n:put nl ] 12 [ 'Unused:_ s:put n:put nl ] bi* ; 13 14 15 ---------------------------------------------------------------- 0 (rarangi) (swap-blocks) 1 2 :swap-blocks (nn-) 3 [ dup-pair 4 set load block:buffer here #1024 copy 5 set load block:buffer here #1024 n:add #1024 copy 6 set here #1024 n:add block:buffer #1024 copy save 7 set here block:buffer #1024 copy save ] gc ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rarangi) (find-unused-block) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rarangi) (compactify-blocks) 1 2 {{ 3 'Start var :this (-n) I @Start n:add ; 4 :empty? (n-f) 5 set load block:buffer n:dec s:hash #-967633659 eq? ; 6 :shift (-) this set save this n:inc set new save ; 7 :setup (start,end-blocks) over n:sub swap !Start ; 8 :compact (start,end) 9 setup [ this empty? [ this n:inc empty? &shift -if ] if ] 10 indexed-times ; 11 ---reveal--- 12 :rarangi:defrag (start,end) 13 dup-pair swap n:sub #2 n:div 14 [ $. c:put dup-pair compact ] times drop-pair nl ; 15 }} ---------------------------------------------------------------- 0 () 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 notes : (rng) 1 2 Written by Arland Childers, this is a random number generator 3 using three seed values. It's not an implementation of any 4 existing prng algorithims. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 notes : (fixed-point) 1 2 This implements a limited set of words for using fixe& point 3 math. 4 5 The default scaling factor (`f:scale`) is #100, for two digits 6 of precision. Change this as needed for your applications. 7 8 Loading: 9 10 '(fixed-point) needs 11 12 13 14 15 ---------------------------------------------------------------- 0 notes : (unu) 1 2 Unu is a simple format for writing literate source programs. I 3 wrote the earliest versions as part of my old Parable language 4 before bringing it along to RetroForth/nga. 5 6 In RetroForth/ilo, I am using blocks for storing code and data. 7 But I miss Unu, so I've now written an implementation that works 8 when evaluating a block. 9 10 As with Unu for files, the code fences need to be on separate 11 lines. Unu will evaluate each line individually (as opposed to 12 the standard method of running a block as a single unit). This 13 means a loss of at least two lines, or 128 characters. But it 14 is optional, so you can use Unu where it makes sense or just 15 run the block as normal. ---------------------------------------------------------------- 0 notes : (ll) 1 2 A linked list is a very useful data structure. The following 3 blocks will contain the basic building blocks for a simple cons 4 cell, then build forward linked and back linked lists. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 notes : (ll) : cons cells 1 2 A cons cell is a pair of values. The first element is the `car` 3 and the second is the `cdr`. (Names derive from LISP). 4 5 To create one, pass the two values to `cons`, and a pointer to 6 the cons will be returned. 7 8 You can then use `car` or `cdr` to get a pointer to either of 9 the elements, or the `car@` and `cdr@` to fetch the values. Or 10 `car!` and `cdr!` to store a value into the fields. 11 12 An `END` constant is defined. This will be used to mark the 13 last value in a linked list of cons cells. 14 15 ---------------------------------------------------------------- 0 notes : (ll) : structure 1 2 The cons cells are intended for use in making linked lists of 3 values. 4 5 For a forward linked list the `car` of each cons will hold the 6 value, and the `cdr` will hold a pointer to the next cell. The 7 last cell will point to `END`. 8 9 For a back linked list, the `car` holds the value and the `cdr` 10 holds a pointer to the prior cons. As with the forward linked 11 list, the final cdr will point to `END`. 12 13 14 15 ---------------------------------------------------------------- 0 notes : (reorder) 1 2 Ok, This is a bit of a hack, but very useful at times. 3 4 Assume you have a bunch of values: 5 6 #3 #1 #2 #5 7 8 And you want to reorder them into something new: 9 #1 #3 #5 #5 #2 #1 10 11 Rather than using a lot of shufflers, `reorder` simplfies this 12 into: 13 14 #3 #1 #2 #5 15 'abcd 'baddcb reorder ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) 1 2 . This vocabulary provides words for using the additional I/O 3 . on the Teensy 4.1 implementation of ilo. 4 5 . Currently this covers reading/writing the GPIO pins and the 6 . RTC. Other devices are expected to be added in the future. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) 1 2 . These blocks add words for interacting with the i/o on the 3 . Teensy 4.1 4 5 :teensy:io (...n-) #100 io ; 6 7 :pin:high (n-) #1 teensy:io ; 8 :pin:low (n-) #2 teensy:io ; 9 :pin:mode (nm-) #3 teensy:io ; 10 :pin:read (n-m) #4 teensy:io ; 11 12 :delay/ms (n-) #10 teensy:io ; 13 :delay/us (n-) #11 teensy:io ; 14 :delay/ns (n-) #12 teensy:io ; 15 ---------------------------------------------------------------- 0 (teensy4.1) 1 2 . The Teensy has a real time clock. The words here allow you to 3 . make use of this. 4 5 :rtc:hour (-n) #20 teensy:io ; 6 :rtc:minute (-n) #21 teensy:io ; 7 :rtc:second (-n) #22 teensy:io ; 8 :rtc:day (-n) #23 teensy:io ; 9 :rtc:month (-n) #24 teensy:io ; 10 :rtc:year (-n) #25 teensy:io ; 11 :rtc:set (hmsdmy-) #26 teensy:io ; 12 :rtc:adjust (n-) #27 teensy:io ; 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 RetroForth : User Guide 1 2 Welcome to Retro, a modern, pragmatic Forth. 3 4 Retro is Forth. It is untyped, using a stack to pass data 5 between functions called words, and a dictionary which 6 tracks the word names and data structures. 7 8 But it's not a traditional Forth. Retro draws influences 9 from many sources and takes a unique approach to the language. 10 11 Retro has a large vocabulary of words. Keeping a copy of this 12 manual and the dictionary on hand is highly recommended as 13 you learn to use Retro. 14 15 ---------------------------------------------------------------- 0 Welcome 1 2 The system described here is RetroForth/ilo, running on the ilo 3 virtual computer. There are related implementations available 4 for the napia and nga systems as well. Those systems have 5 separate documentation. 6 7 This guide will refer to the system as Retro or RetroForth 8 throughout the text. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Overview of RetroForth/ilo 1 2 A RetroForth system consists of three parts: a virtual machine 3 (named "ilo"), an image file (named "ilo.rom"), and a set of 4 data blocks (named "ilo.blocks"). 5 6 The virtual machine is designed to be small, portable, and easy 7 to implement. It's the only part that's specific to your system. 8 All ilo implementations share the same image and blocks. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Obtaining RetroForth 1 2 Snapshots 3 4 You can obtain the latest version of RetroForth from 5 ilo.retroforth.org via the Gemini or HTTP(s) protocols. 6 7 * gemini://ilo.retroforth.org 8 * https://ilo.retroforth.org 9 10 Daily snapshots are provided. These include ilo, the image, a 11 set of data blocks, and documentation. 12 13 14 15 ---------------------------------------------------------------- 0 Source Repositories 1 2 The snapshots do not include the full source tree. To obtain 3 this you will need to use either the Fossil or Git version 4 control systems. 5 6 Via Fossil: 7 8 fossil clone http://fossils.retroforth.org:8000/ilo \ 9 retro-ilo.fossil 10 mkdir retro-ilo; cd retro-ilo 11 fossil open ../retro-ilo.fossil 12 13 Via Git: 14 15 git clone https://git.sr.ht/~crc_/retro-ilo ---------------------------------------------------------------- 0 Building The System (C) 1 2 Requirements: 3 4 * C89 (or newer) compiler 5 6 Process: 7 8 cc ilo/ilo.c -o ilo/ilo 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (C) 1 2 Requirements: 3 4 * C89 (or newer) compiler 5 6 Process: 7 8 cc ilo.c -o ilo 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (C++) 1 2 Requirements: 3 4 * C++ compiler 5 6 Process: 7 8 c++ vm/ilo.cpp -o ilo 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (C#) 1 2 Requirements: 3 4 * C# compiler (mcs) 5 6 Process: 7 8 mcs vm/ilo.cs -out:ilo.exe 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (Go) 1 2 Requirements: 3 4 * Go 5 6 Process: 7 8 go build vm/ilo.cs 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (Kotlin) 1 2 Requirements: 3 4 * Kotlin compiler 5 6 Process: 7 8 kotlinc vm/ilo.kt -include-runtme -d ilo.jar 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (Nim) 1 2 Requirements: 3 4 * Nim 5 6 Process: 7 8 nim c vm/ilo.nim -o:ilo 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (Rust) 1 2 Requirements: 3 4 * Rust compiler 5 6 Process: 7 8 rustc vm/ilo.rs -o ilo 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Building The System (Swift) 1 2 Requirements: 3 4 * Swift compiler 5 6 Process: 7 8 swiftc vm/ilo.swift -o ilo 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Running RetroForth/ilo 1 2 Make sure you have an ilo vm (build the C or Nim ones, or use 3 ilo.py or ilo.lua), ilo.rom, and ilo.blocks in your working 4 directory, then run the ilo vm. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 The Listener 1 2 The listener is Retro's interaction loop. It reads and evaluates 3 your input in a continual loop. 4 5 By itself, the listener is not feature rich. It does not provide 6 any history or editing (apart from backspace). If you are using 7 a Unix host, I recommend running Retro under rlwrap. An example 8 (ri.sh) is in the source repository; this shows how to use the 9 rlwrap tool to add line editing, history, and tab completion. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Basic Interactions 1 2 At the listener you can enter code, and Retro will run what you 3 type. The code consists of tokens, which are sequences of 4 characters, seperated by whitespace. 5 6 The listener reads and processes tokens as they are entered. On 7 most Unix hosts, the system will buffer input until ENTER is 8 pressed, but this should not be assumed to be the case. If not 9 using rlwrap, on a Unix host, you can run `stty cbreak` before 10 starting the ilo binary to disable the input buffering. 11 12 As an example interaction, enter the following and press 13 ENTER (or SPACE if using character breaking) to exit Retro: 14 15 bye ---------------------------------------------------------------- 0 An Overview of Blocks & The Block Editor 1 2 Retro uses blocks to store code and data. These are fixed size 3 buffers of 1,024 values. For the purposes of code and text, they 4 are displayed as 16 rows, with 64 columns per row. 5 6 A minimal block editor is included. (If you are reading this in 7 Retro, then you are probably using the block editor to do so). 8 This is not a complex program, and learning to use it will help 9 you make Retro into a productive system. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 What Are Blocks 1 2 In RetroForth, blocks are 1,024 values (typically characters) 3 that are used for long-term storage. The ilo computer provides 4 a block storage device, and Retro has words to read blocks into 5 memory and write them back to the storage device. 6 7 I like to think of blocks as being similar to index cards. You 8 can write, draw, etc onto a card, and then file them away until 9 needed. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Format of Code & Text Blocks 1 2 While technically freeform, I like to follow a simple structure 3 for my blocks. 4 5 The first line gets a description of the block contents. For 6 code blocks, this starts with a comment with the block group, 7 followed by comments for the description. 8 9 I leave the line after the description blank. This is not 10 necessary, but I find it to aid in readability a bit. 11 12 The rest of the block is filled with the source code or text. 13 14 I recommend having each block focus on a particular word (or 15 small group of related words). ---------------------------------------------------------------- 0 Format of Binary Blocks 1 2 You can store any data in a block. I still recommend designing 3 the data format to reserve the first line for a human readable 4 description. Not doing so may cause problems with some of the 5 supplied tools (e.g., `titles` or `needs`, which I will cover 6 a little later) 7 8 E.g., for a binary format of drawing data I have the first row 9 contain a type ID, title for the drawing, and other metadata. 10 This is repeated for each block needed. 11 12 13 14 15 ---------------------------------------------------------------- 0 Commenting Code Blocks 1 2 Writing comments on your code is a good idea. There are a few 3 strategies you may wish to consider. 4 5 You can write inline comments. I do this for stack comments in 6 words, and to occasionally explain what I'm doing. 7 8 For general comments, I like to have some blocks prior to the 9 code that explain anything relevant. 10 11 For word-specific comments, a traditional approach is to use 12 shadow blocks. This would involve alternating between blocks 13 with code and blocks with descriptions of the code on the 14 previous block. 15 ---------------------------------------------------------------- 0 Interacting With The Editor 1 2 You begin by telling Retro that you want to edit a block. This 3 is done by providing a block number followed by `edit`. For 4 example, to edit block 689: 5 6 #689 edit 7 8 Retro will show the block contents, along with the line numbers, 9 rulers to aid in determining columns, and some status info. Run 10 `list` to redisplay the contents of the current block. 11 12 To go to the next block, run `next`. And to go to the previous 13 block, run `prev`. 14 15 ---------------------------------------------------------------- 0 Interacting With The Editor (cont.) 1 2 Entering text into the block is easy. Type the line number and 3 then the new contents of the line. For instance, to replace line 4 9 with "Hello" (sans quotes): 5 6 9 Hello 7 8 Run `list` to see the changes. 9 10 When you are happy with the edits, run `save` to write the block 11 to storage. If you need to revert to the currently saved copy, 12 run `load`. 13 14 15 ---------------------------------------------------------------- 0 Running Code In A Block 1 2 You can run the code in the current block with `run`. You should 3 `save` first. 4 5 If you know the number of a block you wish to load and run, you 6 can enter the block number followed by `use` to do this. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Block Groups 1 2 Often you will need more than one block for your programs. Retro 3 provides a means of loading multiple blocks via a block group. 4 For this, the first row of a block must contain the group name 5 as a comment, separated by whitespace from any other text. 6 7 To load these, pass a string with the group name comment to 8 `needs`. E.g., to load the standard library, you can do: 9 10 '(std-library) needs 11 12 All blocks matching the group name will be located and run. They 13 will run in the physical block order, so ensure that the blocks 14 are laid out correctly. 15 ---------------------------------------------------------------- 0 Finding Blocks 1 2 Retro does not have many facilities for locating blocks. The 3 block editor includes a single word, `titles`, for displaying a 4 list of the blocks and their block numbers. You can run this 5 and then read through the output to find the ones you need. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 The RetroForth Language 1 2 Retro is a Forth, but it's not a conventional one. The major 3 differences arise from the use of sigils and quotes. 4 5 All code consists of a series of whitespace separated tokens. 6 Retro will check the first character of the token to see if it 7 matches a known sigil. If it does, the token (sans sigil) is 8 passed to the sigil handler. 9 10 If no sigil was found, Retro tries to find the word in the 11 dictionary. If successful, it will either call or compile a 12 call to the word. 13 14 If both of the above fail, an error is diplayed. 15 ---------------------------------------------------------------- 0 Sigils & The Interpreter 1 2 If you are familiar with traditional Forth, you likely notice 3 that no number handling is done. In Retro, these are handled by 4 a sigil. 5 6 The sigil system is a central part of Retro's design. If you 7 are familiar with ColorForth, it might make sense to consider 8 sigils to be colors, but done via characters instead of needing 9 special editor support. 10 11 Let's take a look at how they work. 12 13 14 15 ---------------------------------------------------------------- 0 Sigils & The Interpreter (cont.) 1 2 Retro maintains a table of sigil handlers. Any character can be 3 a sigil. If the interpreter matches the first character in a 4 token to a sigil, the sigil is removed and the token is passed 5 on the stack to the sigil handler for processing. 6 7 This is used in lieu of parsing words. For instance, a : sigil 8 starts a new colon definition. A # sigil processes the token as 9 a number. An & sigil is used to get a pointer. The ( sigil 10 begins a comment. 11 12 The next block has a table of the sigils provided by Retro. 13 14 15 ---------------------------------------------------------------- 0 The Sigils 1 2 Sigil Use 3 ----- ---------------------------------------------- 4 : Begin a colon definition 5 # Process a number 6 ( Begin a comment (ends at the first whitespace) 7 & Return a pointer to a named item 8 ' Return a pointer to a string 9 $ Return the ASCII code of the first character 10 @ Fetch a stored value from a variable 11 ! Store into a variable 12 \ Create an alias to a named item 13 ----- ---------------------------------------------- 14 15 ---------------------------------------------------------------- 0 Numbers 1 2 Numbers are provided by the # sigil. 3 4 A number can start with a - to make it negative. 5 6 Any comma or periods in a number are ignored. 7 8 Numbers are specified in base 10. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Arrays : Overview 1 2 Arrays are sequences of values. They are one of the central data 3 types in RetroForth. 4 5 In memory, an array consists of a count, followed by the values. 6 For instance, an array with 67, 102, and 33 can be constructed 7 like this: 8 9 (pointer) (count) (first_value) (second_value) (last_value) 10 here #3 comma #67 comma #102 comma #33 comma 11 12 Words operating on arrays are prefixed by `a:`. 13 14 Important: the size of an array is fixed at time of creation. 15 You can not resize an array. ---------------------------------------------------------------- 0 Arrays : Creation 1 2 You can create an array by passing the count and values on the 3 stack to `a:make`. For the previous example of an array of 67, 4 102, and 33, this would look like: 5 6 #33 #102 #67 #3 a:make 7 8 This is limited by the amount of space available on the data 9 stack. For longer arrays, create them using the manual model on 10 the previous block or write a custom creating word. 11 12 For arrays not needed long term you can use of `a:make/temp` 13 instead. This will place the array in a rotating buffer instead 14 of the main system memory. 15 ---------------------------------------------------------------- 0 Arrays : Accessing Elements 1 2 To read a specific value, pass a pointer to the array and the 3 offset to `a:fetch`. 4 5 &my-array #2 a:fetch 6 7 To store a value into an array, pass the value, a pointer to the 8 array and the offset to `a:store`. 9 10 #76 &my-array #2 a:store 11 12 13 14 15 ---------------------------------------------------------------- 0 Arrays : Iteration 1 2 Retro provides `a:for-each` to run a function against each value 3 in an array. For instance, to display the numeric value of each 4 item: 5 6 &my-array [ (n-) n:put sp ] a:for-each 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Arrays : Merging 1 2 To combine two arrays into a new array, Retro provides both 3 `a:append` and `a:prepend`. Each take two pointers to existing 4 arrays and construct a new one. 5 6 &a &b a:append (makes_new_array_from_a,_followed_by_b) 7 &a &b a:prepend (makes_new_array_from_b,_followed_by_a) 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Arrays : Comparisons, Searching 1 2 You can compare two arrays for equality with `a:eq?` or check 3 for inequality with `a:-eq?`. 4 5 &a &b a:eq? 6 7 To see if an array contains a value, use `a:contains?`. 8 9 &a #613 a:contains? 10 11 Finding the indices of values in an array is done with 12 `a:indices`. (And the first occurance can be found with 13 `a:index`). `a:indices` returns a new array of the indexes. 14 15 &a #33 a:indices ---------------------------------------------------------------- 0 Arrays : Subsets 1 2 You can extract subsets of an array. Retro provides `a:left` 3 for returning values from the beginning of the array, `a:right` 4 to get values from the end of the array, and `a:middle` for 5 values in the middle of the array. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Reporting Bugs 1 _ If you find a bug, please report 2 \`*-. it to bugs@retroforth.org 3 ) _`-. 4 . : `. . Please include [retro/ilo] in 5 : _ ' \ the subject line, and describe the 6 ; *` _. `*-._ bug in as much detail as possible. 7 `-.-' `-. 8 ; ` `. 9 :. . \ 10 . \ . : .-' . 11 ' `+.; ; ' : 12 : ' | ; ;-. 13 ; ' : :`-: _.`* ; 14 [bug] .*' / .*' ; .*`- +' `*' 15 `*-* `*-* `*-*' ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: . 1 2 . 3 '- 4 5 Read and discard the next 62 characters. This is used in 6 blocks to provide line width comments. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 0 1 2 0 3 '- 4 5 Parse to end of line. Insert into text line 0 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 1 1 2 1 3 '- 4 5 Parse to end of line. Insert into text line 1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 2 1 2 2 3 '- 4 5 Parse to end of line. Insert into text line 2 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 3 1 2 3 3 '- 4 5 Parse to end of line. Insert into text line 3 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 4 1 2 4 3 '- 4 5 Parse to end of line. Insert into text line 4 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 5 1 2 5 3 '- 4 5 Parse to end of line. Insert into text line 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 6 1 2 6 3 '- 4 5 Parse to end of line. Insert into text line 6 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 7 1 2 7 3 '- 4 5 Parse to end of line. Insert into text line 7 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 8 1 2 8 3 '- 4 5 Parse to end of line. Insert into text line 8 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 9 1 2 9 3 '- 4 5 Parse to end of line. Insert into text line 9 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 10 1 2 10 3 '- 4 5 Parse to end of line. Insert into text line 10 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 11 1 2 11 3 '- 4 5 Parse to end of line. Insert into text line 11 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 12 1 2 12 3 '- 4 5 Parse to end of line. Insert into text line 12 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 13 1 2 13 3 '- 4 5 Parse to end of line. Insert into text line 13 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 14 1 2 14 3 '- 4 5 Parse to end of line. Insert into text line 14 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: 15 1 2 15 3 '- 4 5 Parse to end of line. Insert into text line 15 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: {{ 1 2 {{ 3 - 4 5 Begin a lexical scoped area. Starts the private portion. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: ---reveal--- 1 2 ---reveal--- 3 - 4 5 Within lexical scoped area, switch to global scope area. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: }} 1 2 }} 3 - 4 5 Close off lexical scoped area. Hides words in the private 6 area. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: ) 1 2 ) 3 - 4 5 Ending for comments or visual grouping. Provided for 6 readability purposes 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: -eq? 1 2 -eq? 3 nn-f 4 5 Compare values for inequality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: -if 1 2 -if 3 fp- 4 5 Execute p if flag is zero 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: ; 1 2 ; 3 - 4 5 End a definition 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: ?jump 1 2 ?jump 3 fp- 4 5 Internal. If flag is non-zero, branch to p. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: Compiler 1 2 Compiler 3 - 4 5 Data. Tracks compiler state 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: Dictionary 1 2 Dictionary 3 - 4 5 Data. Pointer to most recent header in dictionary 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: Free 1 2 Free 3 - 4 5 Data. Pointer to next free addr 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: I 1 2 I 3 -n 4 5 Access the loop index for the current loop. (For loops made 6 using indexed-times) 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: J 1 2 J 3 -n 4 5 Access the parent loop index for the current loop. (For loops 6 made using indexed-times) 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: K 1 2 K 3 -n 4 5 Access the grandparent loop index for the current loop. (For 6 loops made using indexed-times) 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: Sigils 1 2 Sigils 3 - 4 5 Data. Table of sigil handlers 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: [ 1 2 [ 3 -p 4 5 Begin a quotation 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: ] 1 2 ] 3 p-p 4 5 End a quotation 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:append 1 2 a:append 3 aa-a 4 5 Create a new array with the contents of a1 followed by a2 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:behead 1 2 a:behead 3 a-a 4 5 Remove first item from an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:chop 1 2 a:chop 3 a-a 4 5 Remove last item from an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:contains? 1 2 a:contains? 3 an-f 4 5 True if array contains n. False otherwise 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:copy 1 2 a:copy 3 ap- 4 5 Copy array a to memory starting at pointer p 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:dup 1 2 a:dup 3 a-a 4 5 Make a copy of an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:eq? 1 2 a:eq? 3 aa-f 4 5 Compare two arrays for equality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:-eq? 1 2 a:-eq? 3 aa-f 4 5 Compare two arrays for inequality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:fetch 1 2 a:fetch 3 an-v 4 5 Fetch value stored at index n in array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:filter 1 2 a:filter 3 ap-a 4 5 Run p once for each value in a. If it returns true, copy value 6 new array 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:first 1 2 a:first 3 a-n 4 5 Return the first value in an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:for-each 1 2 a:for-each 3 ap- 4 5 Run p once for each value in the array. Pushes each value 6 prior to calling p 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:hash 1 2 a:hash 3 a-n 4 5 Return the hash of an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:indices 1 2 a:indices 3 av-a 4 5 Return array of indices for v in source array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:index 1 2 a:index 3 av-n 4 5 Return first index of n in a 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:last 1 2 a:last 3 a-n 4 5 Return the last value in an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:left 1 2 a:left 3 an-a 4 5 Return left n values from array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:length 1 2 a:length 3 a-n 4 5 Return the length of an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:make 1 2 a:make 3 ...n-a 4 5 Create a new permanent array from the provided values 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:make/temp 1 2 a:make/temp 3 ...n-a 4 5 Create a new temporary array from the provided values 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:map 1 2 a:map 3 ap-a 4 5 Run p once for each value in the array. Takes the returned 6 value and creates a new array 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:middle 1 2 a:middle 3 afl-a 4 5 Return new array from f to l, inclusive 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:prepend 1 2 a:prepend 3 aa-a 4 5 Create a new array with the contents of a2 followed by a1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:reduce 1 2 a:reduce 3 anp-n 4 5 Takes an array, a starting value, and a quote. This will apply 6 the quote to each item in the array; the quote should consume 7 two values and return one 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:reverse 1 2 a:reverse 3 a-a 4 5 Reverse the order of items in an array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:right 1 2 a:right 3 an-a 4 5 Return right n values from array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:store 1 2 a:store 3 van- 4 5 Store value v into array at index n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:temp 1 2 a:temp 3 a-a 4 5 Make a copy of the array in the temporary string/array space 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: a:th 1 2 a:th 3 an-p 4 5 Return the address of a specific index into the array 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: allot 1 2 allot 3 n- 4 5 Allocate n cells of memory 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: and 1 2 and 3 nn-n 4 5 Perform a bitwise AND 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: bi 1 2 bi 3 xpp-? 4 5 Execute p1 against x, then p2 against a copy of x 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: bi* 1 2 bi* 3 xypp- 4 5 Execute p1 against x and p2 against y 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: bi@ 1 2 bi@ 3 xyp- 4 5 Execute p against x, execute p against y 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: block:load 1 2 block:load 3 np- 4 5 Read 1024 cells in block n to p 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: block:save 1 2 block:save 3 np- 4 5 Save 1024 cells at p to block n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: block:buffer 1 2 block:buffer 3 -p 4 5 Return a pointer to the start of the block buffer 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: bye 1 2 bye 3 - 4 5 Exit RetroForth/ilo 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:get 1 2 c:get 3 -c 4 5 Read a character from the keyboard 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:lowercase? 1 2 c:lowercase? 3 c-f 4 5 Return true if character is lowercase or false if not 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:put 1 2 c:put 3 c- 4 5 Display a single character 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:to-lower 1 2 c:to-lower 3 c-c 4 5 Convert character to lowercase 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:to-s 1 2 c:to-s 3 c-s 4 5 Convert a character to a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:to-upper 1 2 c:to-upper 3 c-c 4 5 Convert character to uppercase 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: c:uppercase? 1 2 c:uppercase? 3 c-f 4 5 Return true if character is uppercase or false if not 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: call 1 2 call 3 p- 4 5 Call a function 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: choose 1 2 choose 3 fpp- 4 5 Execute p1 if flag is non-zero or p2 if zero. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: comma 1 2 comma 3 n- 4 5 Inline a value to here and increment Free 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: compare 1 2 compare 3 sdn-f 4 5 Compare n cells of memory startng at s to memory starting at 6 d. Return true if all match or false otherwise 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: compiling? 1 2 compiling? 3 -f 4 5 True if Compiler is set, False otherwise 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: compile:lit 1 2 compile:lit 3 n- 4 5 Internal. Compile an ilo li instruction 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: compile:call 1 2 compile:call 3 p- 4 5 Internal. Compile an ilo lica instruction 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: compile:jump 1 2 compile:jump 3 p- 4 5 Internal. Compile an ilo liju instruction 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: copy 1 2 copy 3 sdc- 4 5 Copy c cells starting at s to memory starting at d. Does not 6 support overlapping regions 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: curry 1 2 curry 3 vp-p 4 5 Create a new quote pushing the value, then calling p1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:address 1 2 d:address 3 d-p 4 5 Given a dictionary header, return a pointer to the address 6 field 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:create 1 2 d:create 3 s- 4 5 Create a new header 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:exists? 1 2 d:exists? 3 s-f 4 5 Given a dictionary header, return a flag indicating whether or 6 not the word exists 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:flags 1 2 d:flags 3 d-p 4 5 Given a dictionary header, return a pointer to the flags field 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:hash 1 2 d:hash 3 d-p 4 5 Given a dictionary header, return a pointer to the hash field 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:link 1 2 d:link 3 d-p 4 5 Given a dictionary header, return a pointer to the link field 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: d:lookup 1 2 d:lookup 3 s-d 4 5 Lookup a word in the dictionary. Returns zero if not found or 6 the dictionary header address 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: depths 1 2 depths 3 -nm 4 5 Return depths of data and address stacks 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: depth/data 1 2 depth/data 3 -n 4 5 Return the depth of the data stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: depth/address 1 2 depth/address 3 -n 4 5 Return the depth of the address stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: dip 1 2 dip 3 np-n 4 5 Push n to address stack, call p. then restore n to data stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: drop 1 2 drop 3 n- 4 5 Discard top value on stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: drop-pair 1 2 drop-pair 3 nn- 4 5 Discard top two values on stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: dtc 1 2 dtc 3 - 4 5 Internal. Data following is a direct threaded address list 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: dup 1 2 dup 3 n-nn 4 5 Duplicate top value on stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: dup-pair 1 2 dup-pair 3 nm-nmnm 4 5 Duplicate top two values 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:Display 1 2 e:Display 3 - 4 5 Data. Holds a pointer to a block display word. Called by edit. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:erase/line 1 2 e:erase/line 3 n- 4 5 Erase line n in the block buffer 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:insert 1 2 e:insert 3 n'- 4 5 Erase line n, parse to end of line, insert into line n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:insert-at 1 2 e:insert-at 3 lc'- 4 5 Parse to end of line. Insert text into line l at column c 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:line 1 2 e:line 3 n- 4 5 Display a single line from the current block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:replace 1 2 e:replace 3 ls- 4 5 Insert text s into line l 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:replace-at 1 2 e:replace-at 3 lcs- 4 5 Insert text s into line l at column c 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: e:to-line 1 2 e:to-line 3 n-p 4 5 Return pointer to start of line in the block buffer 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: edit 1 2 edit 3 n- 4 5 Set Block to n. Load and display block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: eq? 1 2 eq? 3 nn-f 4 5 Compare values for equality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: fetch 1 2 fetch 3 p-n 4 5 Fetch a value stored at address 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: fetch-next 1 2 fetch-next 3 a-an 4 5 Fetch a value stored at address Also returns the next address 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: fill 1 2 fill 3 vpn- 4 5 Fill n cells of memory starting at p with value v 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: forever 1 2 forever 3 p- 4 5 Run p repeatedly, in an unending loop 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: gc 1 2 gc 3 p- 4 5 Run function at pointer p. Saves and restores Free to recover 6 any memory allocated during run 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: gt? 1 2 gt? 3 nn-f 4 5 Compare values for n1 greater than n2 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: gteq? 1 2 gteq? 3 nn-f 4 5 Compare two values for greater than or equality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: here 1 2 here 3 -a 4 5 Return the next free memory address 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: if 1 2 if 3 fp- 4 5 Execute p if flag is non-zero 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: indexed-times 1 2 indexed-times 3 np- 4 5 Run a quote the specified number of times, tracking the loop 6 index in I 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: internal:lit 1 2 internal:lit 3 -n 4 5 Internal. Push next value in memory to the stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: internal:quote 1 2 internal:quote 3 -p 4 5 Internal. Skip over quote. Push address of quote to stack. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: interpret 1 2 interpret 3 s- 4 5 Interpret token 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: io 1 2 io 3 ...n- 4 5 Trigger an I/O operation 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: jump 1 2 jump 3 p- 4 5 Internal. Jump to an address 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: list* 1 2 list* 3 - 4 5 Display the text in the block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: list# 1 2 list# 3 - 4 5 Display the block with line numbers 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: list 1 2 list 3 - 4 5 Display the block with line numbers and rules 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: load 1 2 load 3 - 4 5 (re)Load the current block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: lt? 1 2 lt? 3 nn-f 4 5 Compare values for n1 less than n2 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: lteq? 1 2 lteq? 3 nn-f 4 5 Compare two values for less than or equality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:abs 1 2 n:abs 3 n-n 4 5 Return the absolute value of n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:add 1 2 n:add 3 nn-n 4 5 Add n1 to n2, returning n3 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:between? 1 2 n:between? 3 nlu-f 4 5 True if n is between l and u, inclusive 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:dec 1 2 n:dec 3 n-n 4 5 Decrement n by 1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:div 1 2 n:div 3 nn-n 4 5 Divine n1 by n2; get result 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:divmod 1 2 n:divmod 3 nn-nn 4 5 Divide n1 by n2 and return the result and remainder 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:inc 1 2 n:inc 3 n-n 4 5 Increment n by 1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:limit 1 2 n:limit 3 nlu-n 4 5 Constrain n to between l and u, inclusive 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:max 1 2 n:max 3 nn-n 4 5 Return the greater of two values 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:min 1 2 n:min 3 nn-n 4 5 Return the lower of two values 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:mod 1 2 n:mod 3 nn-n 4 5 Divide n1 by n2; get remainder 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:mul 1 2 n:mul 3 nn-n 4 5 Multiply n1 by n2, returning n3 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:negate 1 2 n:negate 3 n-n 4 5 Invert the sign of n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:put 1 2 n:put 3 n- 4 5 Display a number 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:sub 1 2 n:sub 3 nn-n 4 5 Subtract n2 from n1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:to-s 1 2 n:to-s 3 n-s 4 5 Convert number to a temp string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:zero? 1 2 n:zero? 3 n-f 4 5 Compare n to zero. True if zero, false otherwise 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: n:-zero? 1 2 n:-zero? 3 n-f 4 5 Compare n to zero. True if not zero, false otherwise 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: needs 1 2 needs 3 s- 4 5 Run any blocks (in order found) with a title starting with s 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: new 1 2 new 3 - 4 5 Erase the contents of the current block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: next 1 2 next 3 - 4 5 Switch to and load next block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: nip 1 2 nip 3 xy-y 4 5 Discard second item on stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: nl 1 2 nl 3 - 4 5 Display a newline 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: not 1 2 not 3 n-n 4 5 Perform a logical NOT operation 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: or 1 2 or 3 nn-n 4 5 Perform a bitwise OR 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: over 1 2 over 3 nm-nmn 4 5 Put a copy of NOS on top of stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: pop 1 2 pop 3 -n 4 5 Move top value on address stack to data stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: prelude 1 2 prelude 3 - 4 5 Load & run blocks 1 & 2 if they appear to be code. Called by 6 default `startup`. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: prev 1 2 prev 3 - 4 5 Switch to and load previous block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: process-data 1 2 process-data 3 n-? 4 5 Internal. If compiling, compile value as a literal into the 6 word. If interpreting, leave on the stack 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: push 1 2 push 3 n- 4 5 Move TOS to the address stack 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: restart 1 2 restart 3 - 4 5 Reload the image and empty stacks 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: rom:save 1 2 rom:save 3 - 4 5 Save the current memory to disk (ilo.rom) 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: rot 1 2 rot 3 xyz-yzx 4 5 Rotate the top three values 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: run 1 2 run 3 - 4 5 Run code in the currently loaded block 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:append 1 2 s:append 3 ss-s 4 5 Append s2 to s1, returning new temporary string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:behead 1 2 s:behead 3 s-s 4 5 Remove first item from a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:chop 1 2 s:chop 3 s-s 4 5 Remove last item from a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:contains? 1 2 s:contains? 3 sc-f 4 5 True if string contains c. False otherwise 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:copy 1 2 s:copy 3 sd- 4 5 Copy string s to memory at d 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:dup 1 2 s:dup 3 s-s 4 5 Make a copy of string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:eq? 1 2 s:eq? 3 ss-f 4 5 Compare two strings for equality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:-eq? 1 2 s:-eq? 3 ss-f 4 5 Compare two strings for inequality 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:evaluate 1 2 s:evaluate 3 s-? 4 5 Interpret each token in a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:fetch 1 2 s:fetch 3 sn-c 4 5 Return character at index n in the string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:filter 1 2 s:filter 3 sp-s 4 5 Run p once for each value in s If it returns true, copy value 6 new string 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:first 1 2 s:first 3 s-c 4 5 Return the first character in a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:for-each 1 2 s:for-each 3 sp- 4 5 Run p once for each character in s. Pushes each character to 6 the stack before calling p 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:get/line 1 2 s:get/line 3 '-s 4 5 Read a line of input until enter is encountered. Return input 6 as string 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:get/token 1 2 s:get/token 3 -s 4 5 Read a string from the keyboard ending when a whitespace is 6 encountered 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:hash 1 2 s:hash 3 s-n 4 5 Return the hash of the string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:index/c 1 2 s:index/c 3 sc-f 4 5 True if string contains c, false otherwise 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:keep 1 2 s:keep 3 s-s 4 5 Move string to here, allocating space and returning a pointer 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:last 1 2 s:last 3 s-c 4 5 Return the last character in a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:left 1 2 s:left 3 sn-s 4 5 Return left n characters of string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:length 1 2 s:length 3 s-n 4 5 Return the length of a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:map 1 2 s:map 3 sp-s 4 5 Run p once for each value in the string. Takes the returned 6 value and creates a new string 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:middle 1 2 s:middle 3 sfl-s 4 5 Return substring from f to l, inclusive 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:prepend 1 2 s:prepend 3 ss-s 4 5 Create a new string with the contents of s2 followed by s1 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:put 1 2 s:put 3 s- 4 5 Display a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:reverse 1 2 s:reverse 3 s-s 4 5 Reverse the order of values in the string. Returns a pointer 6 to the new string 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:rewrite 1 2 s:rewrite 3 s-s 4 5 Replace underscores in string with spaces 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:right 1 2 s:right 3 sn-s 4 5 Return right n characters of string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:store 1 2 s:store 3 csn- 4 5 Store character into string at index n 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:temp 1 2 s:temp 3 s-s 4 5 Put a copy of a string in the temporary buffers. Return a 6 pointer to it 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:th 1 2 s:th 3 sn-a 4 5 Given a string and index, return the address 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:to-lower 1 2 s:to-lower 3 s-s 4 5 Make all characters in string lowercase 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:to-n 1 2 s:to-n 3 s-n 4 5 Convert a string to a number 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:to-upper 1 2 s:to-upper 3 s-s 4 5 Make all characters in a string uppercase 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:trim 1 2 s:trim 3 s-s 4 5 Trim both leading and trailing whitespace from a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:trim-right 1 2 s:trim-right 3 s-s 4 5 Trim trailing whitespace from a string 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: s:t