---------------------------------------------------------------- 0 Welcome to Konilo! 1 2 3 _| _| _| _| 4 _| _| _|_| _|_|_| _| _|_| 5 _|_| _| _| _| _| _| _| _| _| 6 _| _| _| _| _| _| _| _| _| _| 7 _| _| _|_| _| _| _| _| _|_| 8 9 10 For some starting points, try `catalogue` to browse the blocks 11 or `tuhi` to start an editor. If your system includes the 12 documentation blocks, load them with `* documentation` and use 13 `manual` or `describe wordname` to access this. 14 15 Please explore, and adapt the system to meet your needs. ---------------------------------------------------------------- 0 (startup) (set_blocks,_load_extensions) 1 2 . You should setup the numbers of blocks in your system. 3 4 #4,096 !Blocks 5 6 . Load desired extensions. As Konilo uses a single shared 7 . buffer for blocks, I wrap these in a quote, and make `call` 8 . the last item in this block. This ensures proper behavior. 9 10 [ @Blocks [ #128 !Blocks 11 '(std) needs '(termina) needs 12 '(tuhi) needs '(nonix) needs 13 '(catalogue) needs '(rem) needs 14 15 ] dip !Blocks ] call ---------------------------------------------------------------- 0 (startup) (local_configuration) 1 2 . You should adjust these to match your terminal settings if 3 . using the (termina) based programs. 4 5 #80 !ti:width #20 !ti:height vt:mono 6 &tuhi:cfg/syntax v:off 7 8 . Set the preferred editor to use with `catalogue` 9 [ (n-) set load tuhi ] !Editor 10 11 . This will restrict `needs` to the first 8,192 blocks 12 [ (s-) @Blocks [ #8,192 !Blocks needs ] dip !Blocks ] \needs 13 14 . This will display the startup message in block 0 15 [ #0 set load list* nl ] gc ---------------------------------------------------------------- 0 Copyright (c) Charles Childers 1 2 Permission to use, copy, modify, and/or distribute this 3 software for any purpose with or without fee is hereby 4 granted, provided that the copyright notice and this 5 permission notice appear in all copies. 6 7 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS 8 ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 9 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 10 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 12 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 13 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 14 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 15 OF THIS SOFTWARE. ---------------------------------------------------------------- 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 #-2,147,483,647 ; 5 :n:MAX #2,147,483,646 ; 6 7 . Constants for flags. 8 9 :TRUE #-1 ; 10 :FALSE #0 ; 11 12 . Constants for memory layout 13 14 :sys:BUFFERS #60,000 ; 15 :sys:EOM #65,535 ; ---------------------------------------------------------------- 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:) (classification) 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:positive? (n-f) #0 gt? ; 7 :n:strictly-positive? (n-f) #1 gteq? ; 8 9 :n:square (n-n) dup n:mul ; 10 11 :~guess dup-pair n:div over n:sub #2 n:div ; 12 :n:sqrt (n-n) #1 [ ~guess &n:add sip ] while nip ; 13 14 :n:sign (n-n) n:negative? [ #-1 ] [ #1 ] choose ; 15 ---------------------------------------------------------------- 0 (std) (v:) (a:) 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 :a:new (ns-) d:create dup comma allot ; 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 :~prepare dup s:length &swap dip ; 3 :s:begins-with? (ss-f) ~prepare s:left &s:hash bi@ eq? ; 4 :s:ends-with? (ss-f) ~prepare s:right &s:hash bi@ eq? ; 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (s:) (contains/s?) (index/s) 1 2 (target) '~tar var '~tar.l var (source) '~src var '~src.l var 3 4 :~setup s:keep [ s:length !~tar.l ] [ !~tar ] bi 5 s:keep [ s:length !~src.l ] [ !~src ] bi ; 6 7 :s:contains/s? (ss-f) 8 [ ~setup #0 @~src.l @~tar.l n:sub n:inc 9 [ @~src I @~tar.l s:middle @~tar s:eq? or ] indexed-times 10 ] gc ; 11 12 :s:index/s (ss-n) 13 [ ~setup #65535 @~src.l @~tar.l n:sub n:inc 14 [ @~src I @~tar.l s:middle @~tar s:eq? [ I n:min ] if ] 15 indexed-times ] gc ; ---------------------------------------------------------------- 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 :~split (s-nnnn) 3 dup #2 s:left inst swap dup #2 #2 s:middle inst swap 4 dup #4 #2 s:middle inst swap #2 s:right inst ; 5 6 :assemble:opcode (s-n) ~split b:pack ; 7 8 :i (s-) assemble:opcode comma ; 9 &comma \d (n-) 10 &comma \r (n-) 11 :s (s-) dup s:length comma &comma s:for-each ; 12 13 :code: ("-) 'liju.... i here #4 n:add comma 14 s:get/token d:create ; 15 &code: \label: ("-) ---------------------------------------------------------------- 0 (std) (reorder,_roll,_unroll) (restructuring-the-stack) 1 2 {{ 3 &sys:buffers/reserved \values 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 :roll (abc-cab) swap &swap dip ; 14 :unroll (cba-abc) roll roll ; 15 ---------------------------------------------------------------- 0 (std) (reset) (quickly-empty-the-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 (std) (.s) (display-stack) 1 2 :~gather depth/data dup &sys:buffers/reserved store-next swap 3 &store-next times drop ; 4 :~display &sys:buffers/reserved a:reverse 5 [ n:put sp ] a:for-each ; 6 :~restore &sys:buffers/reserved a:reverse [ ] a:for-each ; 7 8 :.s (-) ~gather ~display ~restore ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (debug/dump) 1 2 {{ 3 :to-digit (n-c) '0123456789ABCDEF swap s:fetch ; 4 :h. (n-) #16 n:divmod swap [ to-digit c:put ] bi@ sp ; 5 :order 'abcd 'dcba reorder ; 6 :bytes (n-n) dup b:unpack order #4 &h. times ; 7 :display (nn-n) bytes sp n:put nl ; 8 ---reveal--- 9 :dump (an-) [ dup n:put tab fetch-next display ] times drop ; 10 }} 11 12 13 14 15 ---------------------------------------------------------------- 0 (std) (random-number-generator) (xorshift) 1 2 #1 'seed var-n 3 4 :n:random (-n) 5 @seed 6 dup #13 shift-left xor 7 dup #17 shift-right xor 8 dup #5 shift-left xor 9 dup !seed ; 10 11 :n:random-mod (n-n) 12 n:random n:abs swap n:mod ; 13 14 . Note: this works well for small projects, but lacks some 15 . range due to ilo's lack of unsigned numbers. ---------------------------------------------------------------- 0 (std) (block-tools) 1 2 :block:empty? (n-f) 3 @Block [ set load block:buffer n:dec s:hash #-967633659 4 eq? ] dip !Block load ; 5 6 :block:for-each (q-) 7 @Blocks [ [ I set load block:buffer swap call ] sip ] 8 indexed-times drop ; 9 10 :block:first-matching (s-n) 11 @Blocks swap 12 [ s:keep [ n:dec over s:begins-with? 13 [ [ I n:min ] dip ] if ] block:for-each drop ] gc ; 14 15 ---------------------------------------------------------------- 0 (std) (block-tools) 1 2 :block:title (-s) block:buffer n:dec #64 over store ; 3 :block:name (-s) block:title dup #32 s:index/c s:left ; 4 5 'block:Sets var 6 7 :block:set:init (-) 8 here !block:Sets #0 comma @Blocks #4 n:div allot ; 9 10 :block:set:known? (-f) 11 @block:Sets block:name s:hash a:contains? ; 12 13 :block:set:add (-) 14 block:name s:hash @block:Sets dup fetch a:store 15 @block:Sets v:inc ; ---------------------------------------------------------------- 0 (std) (editor-ext) 1 2 &sys:buffers/reserved #64 n:add \Line 3 4 :e:copy (n-) e:to-line &Line #64 copy ; 5 :e:paste (n-) e:to-line &Line swap #64 copy ; 6 :e:cut (n-) dup e:copy #32 swap e:to-line #64 fill ; 7 8 :~get '_ s:temp #64 over store [ n:inc #64 copy ] sip ; 9 :~update n:inc swap #64 copy ; 10 :~at e:to-line dup ~get ; 11 12 :e:indent (n-) ~at #62 s:left '__ s:prepend ~update ; 13 :e:unindent (n-) ~at #62 s:right '__ s:append ~update ; 14 15 ---------------------------------------------------------------- 0 (std) (editor-ext) 1 2 :e:for-each-line (q-) 3 #16 [ block:buffer n:dec 4 I #64 n:mul #64 s:middle swap &call sip ] 5 indexed-times drop ; 6 7 8 9 10 11 12 :n (-) next @e:Display call ; 13 :p (-) prev @e:Display call ; 14 [ @e:Display call ] \l 15 ---------------------------------------------------------------- 0 (std) (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 (----) :~pad @f:scale n:to-s s:length n:dec over 10 n:to-s s:length n:sub [ $0 c:put ] times ; 11 (f-) :f:put @f:scale n:divmod n:put $. c:put ~pad n:put ; 12 13 14 15 ---------------------------------------------------------------- 0 (std) (invoke,_*) 1 2 :invoke (ss-) 3 dup d:exists? &nip [ swap needs ] choose 4 d:lookup d:address fetch call ; 5 6 :~title ("-n) s:get/token '(LOAD: s:prepend ') s:append ; 7 :* ("-) #0 set load ~title block:first-matching set load 8 @Block @Blocks n:dec -eq? 9 [ &[ n:abs call run &] n:abs call call ] if ; 10 11 . `invoke` takes a block set and a word to run, if the word is 12 . found, it will load the block set, then run the word 13 . `*` takes the name of a LOAD: block. This will have a title of 14 . `(LOAD:name)` and will contain a list of words that load the 15 . dependencies and active block set. ---------------------------------------------------------------- 0 (std) (s:trim) 1 2 :s:trim-right (s-s) 3 s:temp [ dup v:dec [ s:last #32 lteq? ] sip swap ] while 4 dup v:inc dup s:last #32 eq? [ dup v:dec ] if ; 5 6 '~Start var '~End var '~Len var 7 :~end dup s:length dup !~Len over n:add n:inc !~End n:inc ; 8 :~size @~Start over swap n:sub @~Len swap n:sub ; 9 :s:trim-left (s-s) 10 s:dup dup #0 s:fetch #32 eq? 11 [ dup !~Start ~end 12 [ fetch-next #32 -eq? over @~End -eq? and ] while 13 ~size (patch over store ) ] if ; 14 15 :s:trim (s-s) s:trim-left s:trim-right ; ---------------------------------------------------------------- 0 nonix : a unix-inspired set of words for working with the blocks 1 2 This provides: 3 4 +--------+--------------+-------------------------------------+ 5 | cp | src dest | copy block src to block dest | 6 | mv | src dest | move block src to block dest | 7 | rm | block | erase block | 8 | cat | block | display contents of a block (text) | 9 | locate | text | show blocks starting with text | 10 | xcp | src dest num | copy num blocks from src to dest | 11 | xmv | src dest num | move num blocks from src to dest | 12 | xrm | start num | remove num blocks starting at start | 13 | clear | | clear the screen | 14 +--------+--------------+-------------------------------------+ 15 ---------------------------------------------------------------- 0 (nonix) (basic-commands) 1 2 :cp n:get set load n:get set save ; 3 :rm n:get set new save ; 4 :mv n:get dup set load n:get set save set new save ; 5 :cat n:get set load list* ; 6 :~to-title n:dec #64 over store ; 7 :~match I n:put tab #60000 s:put nl ; 8 :locate 9 [ s:get/line s:keep 10 [ ~to-title over s:contains/s? &~match if ] block:for-each ] 11 gc drop ; 12 13 :clear (-) vt:clear vt:home ; 14 15 ---------------------------------------------------------------- 0 (nonix) (extended-commands) 1 2 {{ 3 :relocate over set load dup set save ; 4 :erase over set new save ; 5 :next &n:inc bi@ ; 6 :args n:get n:get n:get ; 7 ---reveal--- 8 :xmv ("from,to,count") 9 args [ relocate erase next ] times drop-pair ; 10 :xcp ("from,to,count") 11 args [ relocate next ] times drop-pair ; 12 :xrm ("start,count") 13 n:get n:get swap set [ new save next ] times ; 14 }} 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (opt:nonix) (df:_summarize_block_usage) 1 2 :~usage (-nn) 3 #0 #0 @Blocks [ I block:empty? 4 &n:inc [ &n:inc dip ] choose ] indexed-times ; 5 6 :df (-) 7 ~usage [ 'Used:___ s:put n:put nl ] 8 [ 'Unused:_ s:put n:put nl ] bi* ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (opt:nonix) (block-map) 1 2 'Density var 3 :~sym (-s) '.123456789ABCDEFG ; 4 :~block# (-n) J #16 n:mul I n:add ; 5 :~empty? (-f) ~block# block:empty? ; 6 :~record (f-) [ &Density v:inc ] -if ; 7 :~break I n:-zero? I #64 n:mod n:zero? and &nl if ; 8 :~map ~break ~sym @Density s:fetch c:put ; 9 :~collect #0 !Density #16 [ ~empty? ~record ] indexed-times ; 10 :~pages (-n) @Blocks #16 n:div ; 11 :block-map ~pages [ ~collect ~map ] indexed-times nl ; 12 13 . This will generate a 64 column output of the block usage. It 14 . counts the blocks used in each 16 block page, and displays a 15 . value from 1-G to indicate the used blocks. . is used for nil. ---------------------------------------------------------------- 0 (opt:nonix) (full-block-search) 1 2 :~to-title n:dec ; 3 :~match I n:put sp ; 4 5 :blocks-containing (s-) 6 [ s:keep 7 [ ~to-title over s:contains/s? &~match if ] block:for-each ] 8 gc drop nl ; 9 10 :blocks-containing: ("-) 11 s:get/line blocks-containing ; 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:opt:nonix) 1 2 '(opt:nonix) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:documentation) 1 2 '(describe) needs 3 '(man) needs 4 5 '------------------------------------------------- s:put nl 6 'For_glossary_lookups,_do: s:put nl nl 7 '__describe_name s:put nl nl 8 'To_browse_the_manual,_run_`manual`. s:put nl 9 '------------------------------------------------- s:put nl 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (opt:editor) (indention,_unindention) 1 2 :~new d:create dup 'liliju.. i comma n:inc ; 3 :~i ~new &e:indent comma ; 4 :~u ~new &e:unindent comma ; 5 6 #0 '0i ~i '1i ~i '2i ~i '3i ~i '4i ~i '5i ~i 7 '6i ~i '7i ~i '8i ~i '9i ~i '10i ~i '11i ~i 8 '12i ~i '13i ~i '14i ~i '15i ~i drop 9 10 #0 '0u ~u '1u ~i '2u ~u '3u ~u '4u ~u '5u ~u 11 '6u ~u '7u ~i '8u ~u '9u ~u '10u ~u '11u ~u 12 '12u ~u '13u ~i '14u ~u '15u ~u drop 13 14 15 ---------------------------------------------------------------- 0 (opt:editor) (cut,_copy,_paste) 1 2 :~x ~new &e:cut comma ; (cut) 3 :~c ~new &e:copy comma ; (copy) 4 :~p ~new &e:paste comma ; (paste) 5 6 #0 '0x ~x '1x ~x '2x ~x '3x ~x '4x ~x '5x ~x 7 '6x ~x '7x ~x '8x ~x '9x ~x '10x ~x '11x ~x 8 '12x ~x '13x ~x '14x ~x '15x ~x drop 9 #0 '0c ~c '1c ~c '2c ~c '3c ~c '4c ~c '5c ~c 10 '6c ~c '7c ~c '8c ~c '9c ~c '10c ~c '11c ~c 11 '12c ~c '13c ~c '14c ~c '15c ~c drop 12 #0 '0p ~p '1p ~p '2p ~p '3p ~p '4p ~p '5p ~p 13 '6p ~p '7p ~p '8p ~p '9p ~p '10p ~p '11p ~p 14 '12p ~p '13p ~p '14p ~p '15p ~p drop 15 ---------------------------------------------------------------- 0 (LOAD:opt:editor) 1 2 '(opt:editor) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 manual ========================================================= 1 2 The manual is structured as a wiki, with blocks forming the data 3 nodes. Links start with a *, and glossary data starts with a +. 4 A manual browser is provided, as well as a vocabulary for doing 5 lookups at the Listener. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (man) (configuration,_helper_words) 1 2 :man:START (-n) #1,472 ; 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (man) (locate-blocks) 1 2 :~target (ss-s) s:temp swap s:prepend '_ s:append s:keep ; 3 :~target/lower (ss-s) ~target s:to-lower s:keep ; 4 :~title (-s) block:buffer n:dec #64 over store next ; 5 :~match? (ss-sf) over s:begins-with? ; 6 :~range (-n) man:START n:dec set load #2048 ; 7 :man:locate (s-n) 8 [ 'man:_ swap ~target/lower #0 swap 9 ~range [ ~title ~match? [ [ I n:max ] dip ] if ] 10 indexed-times drop man:START n:add ] gc ; 11 12 :glossary:locate (s-n) 13 [ 'Glossary:_ swap ~target #0 swap 14 ~range [ ~title ~match? [ [ I n:max ] dip ] if ] 15 indexed-times drop man:START n:add ] gc ; ---------------------------------------------------------------- 0 (man) (display-block,_find_and_display_block) 1 2 :~display-char (c-) 3 dup $* eq? &fg:red if 4 dup $+ eq? &fg:cyan if 5 dup #32 eq? &vt:reset if c:put ; 6 7 :~line #64 [ fetch-next ~display-char ] times vt:reset nl ; 8 9 :~title fg:white bg:blue 10 #64 [ fetch-next c:put ] times vt:reset nl ; 11 12 :~render block:buffer ~title #15 &~line times drop ; 13 14 :man s:get/token man:locate set load ~render ; 15 :man:list ~render ; ---------------------------------------------------------------- 0 (man) (exits?,_new,_edit) 1 2 :man:exists? (s-f) man:locate n:-zero? ; 3 :glossary:exists? (s-f) glossary:locate n:-zero? ; 4 5 :man:new (-) 6 'start man:locate set load 7 [ next @Block block:empty? ] until @Block @Editor call ; 8 9 :man:edit (s-) 10 [ s:keep dup man:exists? 11 [ man:locate @Editor call ] 12 [ drop man:new ] choose ] gc ; 13 14 15 ---------------------------------------------------------------- 0 (man) (new,_with_prompt) 1 2 :man:new/prompt (-) 3 'start man:locate set load 4 [ next @Block block:empty? ] until 5 @Block set load #0 e:erase/line 6 &~Query 'New_page_name: ti:prompt 7 #0 @~Query s:to-lower 'man:_ s:prepend e:replace save 8 @Block @Editor call ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (man) (browser) 1 2 :~man:prompt (s-s) &~Query swap ti:prompt @~Query s:keep ; 3 4 :man:* 5 [ 'Page_name: ~man:prompt dup man:exists? 6 [ man:locate set load ] 7 [ drop man:new ] choose ] gc ; 8 9 :man:+ 10 [ 'Word_name: ~man:prompt dup glossary:exists? 11 [ glossary:locate set load ] 12 [ drop man:new ] choose ] gc ; 13 14 :man:1 'start man:locate set load ; 15 :man:8 @Block @Editor call ; ---------------------------------------------------------------- 0 (man) (browser) (key-bindings) 1 2 :man:actions (-) 3 &man:1 $1 ti:set-action 4 &man:8 $8 ti:set-action 5 &man:* $* ti:set-action 6 &man:+ $+ ti:set-action 7 &man:new/prompt $3 ti:set-action 8 [ #63 ti:help ] $? ti:set-action 9 &ti:done $0 ti:set-action 10 &prev $[ ti:set-action 11 &next $] ti:set-action 12 ; 13 14 15 ---------------------------------------------------------------- 0 (man) (browser) 1 2 :man:hints 3 'Start #1 ti:add-hint 4 'Edit #8 ti:add-hint 5 'New #3 ti:add-hint 6 'Quit #0 ti:add-hint 7 'manual ti:set-title ; 8 9 :man:display (-) vt:clear vt:home man:list ; 10 11 :man:browser 12 'start man:locate set load 13 [ &man:actions &man:hints &man:display ] ti:application ; 14 15 &man:browser \manual ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 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 (describe) (glossary-lookups) 1 2 :describe:word (s-) @Block roll 3 [ s:prepend s:keep @Blocks 4 [ I set load block:buffer n:dec over 5 dup s:length &swap dip s:left &s:hash bi@ eq? 6 &list* if 7 ] indexed-times drop ] gc !Block load ; 8 9 :describe (') s:get/token 'Glossary:_ describe:word ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man shortcuts ================================================== 1 2 * enter *, then the man page name to jump to that page. 3 this will start the editor if a page does not exist. 4 5 1 jump to *Start in the wiki 6 3 start the editor on a new page 7 8 edit the current page 8 9 0 quit the man browser 10 11 ? bring up this help screen 12 13 14 15 ---------------------------------------------------------------- 0 Termina : A Vocabulary for Terminal Applications =============== 1 2 There are two parts to Termina. The first is a set of words for 3 interacting with a DEC compatible terminal. The second builds on 4 these to provide a scaffold for building textual, keyboard 5 centric programs. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Termina : Notes on Memory Usage 1 2 To store the hot key pointers and hints text, Termina makes use 3 of part of the memory in sys:buffers/reserved. If using a non- 4 standard image, you may need to update the addresses in the 5 Termina source code. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (terminal-config) 1 2 . Variables used for some positioning calculations. I suggest 3 . setting these in your startup blocks. 4 5 #80 'ti:width var-n 6 #24 'ti:height var-n 7 #-1 'vt:EnableColors var-n 8 9 :vt:colored &vt:EnableColors v:on ; 10 :vt:mono &vt:EnableColors v:off ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (support;_cursor_movement;_clear_screen) 1 2 . Helper words 3 :vt:esc (-) #27 c:put ; 4 :vt:csi (-) vt:esc $[ c:put ; 5 6 . Words for moving the cursor 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 :vt:set/color (n-) @vt:EnableColors 3 [ vt:csi n:put $m c:put ] &drop choose ; 4 5 :fg:black #30 vt:set/color ; :bg:black #40 vt:set/color ; 6 :fg:red #31 vt:set/color ; :bg:red #41 vt:set/color ; 7 :fg:green #32 vt:set/color ; :bg:green #42 vt:set/color ; 8 :fg:yellow #33 vt:set/color ; :bg:yellow #43 vt:set/color ; 9 :fg:blue #34 vt:set/color ; :bg:blue #44 vt:set/color ; 10 :fg:magenta #35 vt:set/color ; :bg:magenta #45 vt:set/color ; 11 :fg:cyan #36 vt:set/color ; :bg:cyan #46 vt:set/color ; 12 :fg:white #37 vt:set/color ; :bg:white #47 vt:set/color ; 13 14 15 ---------------------------------------------------------------- 0 (termina) (key-to-action-mapping) 1 2 &sys:buffers/reserved #256 n:add \ti:Actions #128 !ti:Actions 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 &ti:Actions #130 n:add \ti:Hints :empty (-s) '____________ ; 3 :constrain (s-s) dup s:length #12 gt? [ #12 s:left ] if ; 4 :pad (s-s) #32 empty n:inc #12 fill 5 empty &n:inc bi@ over n:dec fetch copy empty ; 6 :start (n-a) #13 n:mul &ti:Hints n:add ; 7 :display (-) I n:inc dup #10 eq? [ drop #0 ] if 8 dup n:put sp start s:put sp ; 9 :clean (-) '_ s:temp constrain pad I start #13 copy ; 10 ---reveal--- 11 :ti:add-hint (sn-) 12 #13 n:mul &ti:Hints n:add [ constrain pad ] dip #13 copy ; 13 :ti:reset-hints (-) #10 &clean indexed-times ; 14 :ti:hints #10 [ display I #4 eq? &nl if ] indexed-times ; 15 }} ---------------------------------------------------------------- 0 (termina) (display) 1 2 'ti:Title d:create #24 allot 3 :ti:set-title &ti:Title s:copy ; 4 5 :ti:display/none ; 6 &ti:display/none 'ti:Display var-n 7 :ti:set-display (a-) !ti:Display ; 8 :ti:reset-display (-) &ti:display/none ti:set-display ; 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 @ti:Title n:-zero? 14 [ @ti:height #3 n:sub #0 vt:row,col 15 '--[_ s:put &ti:Title s:put '_] s:put nl nl ] if nl ; ---------------------------------------------------------------- 0 (termina) (nested-applications-support) 1 2 'ti:ptrs d:create #0 comma #5 allot 3 :ti:add-program (a-) &ti:ptrs v:inc &ti:ptrs @ti:ptrs a:store ; 4 :ti:current (-a) &ti:ptrs @ti:ptrs a:fetch ; 5 :ti:more? (-f) @ti:ptrs n:-zero? ; 6 :ti:remove &ti:ptrs v:dec ; 7 8 :ti:load (-) 9 ti:current call #0 !ti:Title 10 !ti:Display ti:reset-hints call ti:reset-actions call ; 11 12 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/run (-) 7 [ #0 !ti:Done ti:display ti:input ti:done? ] until 8 ti:remove ti:more? [ ti:load #0 !ti:Done ] if ; 9 10 :ti:application (q-) 11 ti:add-program ti:load ti:application/run ; 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (prompt) 1 2 . This implements a pop-up prompt frame for use with Termina 3 . programs. 4 . 5 6 #7 'FrameRow var-n 7 #5 'FrameCol var-n 8 9 &bg:white '~PopupBG var-n 10 &fg:black '~TextColor var-n 11 &fg:blue '~InputColor var-n 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (prompt) 1 2 :~bar (rc-) vt:row,col @~PopupBG call @~TextColor call 3 #64 [ $- c:put ] times vt:reset ; 4 :~mid (rc-) vt:row,col @~PopupBG call @~TextColor call 5 $| c:put #62 &sp times $| c:put vt:reset ; 6 7 :~frame (-) 8 @FrameRow @FrameCol ~bar 9 @FrameRow n:inc @FrameCol ~mid 10 @FrameRow #2 n:add @FrameCol ~mid 11 @FrameRow #3 n:add @FrameCol ~mid 12 @FrameRow #4 n:add @FrameCol ~bar ; 13 14 15 ---------------------------------------------------------------- 0 (termina) (prompt) 1 2 :~prompt (as"-) 3 @FrameRow #2 n:add @FrameCol #2 n:add vt:row,col 4 @~PopupBG call @~TextColor call s:put sp @~InputColor call 5 s:get/line swap store vt:reset ; 6 7 :ti:prompt (as-) 8 ~frame ~prompt ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (termina) (ti:help) 1 2 {{ 3 'ti:Help var 'ti:Help/Prior var 4 :ti:help/actions &ti:done $0 ti:set-action ; 5 :ti:help/hints 'Quit #0 ti:add-hint 'help ti:set-title ; 6 :ti:help/display 7 vt:clear vt:home 8 @ti:Help set load list* ; 9 ---reveal--- 10 :ti:help (n-) 11 @Block !ti:Help/Prior !ti:Help 12 [ &ti:help/actions &ti:help/hints &ti:help/display ] 13 ti:application @ti:Help/Prior set load ; 14 }} 15 ---------------------------------------------------------------- 0 catalogue : block browser ====================================== 1 2 The catalogue is a program for exploring the blocks. It divides 3 blocks into pages of 16 blocks, and allows flipping through the 4 pages, listing the titles to provide some insight into what each 5 block contains. 6 7 Shortcut keys are provided to jump directly to the page holding 8 a specific block (4), or leaping to the page with the first 9 block matching a specified title (9). It also includes a quick 10 viewer for blocks, support for renaming blocks (changing the 11 title line), and loading the blocks into the Tuhi editor. 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (catalogue) (block-viewer) 1 2 :~hints 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Quit #0 ti:add-hint 6 'block_viewer ti:set-title ; 7 8 :~actions 9 &prev $1 ti:set-action 10 &next $2 ti:set-action 11 &ti:done $0 ti:set-action ; 12 13 :~display clear list# ; 14 15 :block-viewer [ &~actions &~hints &~display ] ti:application ; ---------------------------------------------------------------- 0 (catalogue) (variables,_actions) 1 2 #0 'Page var-n 3 &edit 'Editor var-n 4 '~Query var 5 6 :constrain @Page #0 @Blocks #16 n:div n:dec n:limit !Page ; 7 :action (n-) ti:done @Page #16 n:mul n:add @Editor call ; 8 9 :catalogue:rename 10 &~Query 'Block_ID_(a-p): ti:prompt @~Query #0 s:fetch 11 $a n:sub @Page #16 n:mul n:add set load 12 &~Query 'New_title: ti:prompt 13 #0 e:erase/line #0 @~Query e:replace save ; 14 15 ---------------------------------------------------------------- 0 (catalogue) (actions,_continued) 1 2 :catalogue:jump &~Query 'Block_Number: ti:prompt 3 @~Query s:to-n #16 n:div !Page constrain ; 4 5 :catalogue:leap 6 [ &~Query 'First_part_of_block_title: ti:prompt 7 @~Query s:keep #0 set load 8 [ block:buffer n:dec over s:begins-with? next 9 @Block @Blocks n:dec eq? or ] until drop prev ] gc 10 @Block #16 n:div !Page constrain ; 11 12 :catalogue:list 13 &~Query 'Block_ID_(a-p): ti:prompt @~Query #0 s:fetch 14 $a n:sub @Page #16 n:mul n:add set load block-viewer ; 15 ---------------------------------------------------------------- 0 (catalogue) (key-bindings) 1 2 :catalogue:actions/a-i 3 [ #0 action ] $a ti:set-action 4 [ #1 action ] $b ti:set-action 5 [ #2 action ] $c ti:set-action 6 [ #3 action ] $d ti:set-action 7 [ #4 action ] $e ti:set-action 8 [ #5 action ] $f ti:set-action 9 [ #6 action ] $g ti:set-action 10 [ #7 action ] $h ti:set-action 11 [ #8 action ] $i ti:set-action ; 12 13 14 15 ---------------------------------------------------------------- 0 (catalogue) (key-bindings) 1 2 :catalogue:actions/j-p 3 [ #9 action ] $j ti:set-action 4 [ #10 action ] $k ti:set-action 5 [ #11 action ] $l ti:set-action 6 [ #12 action ] $m ti:set-action 7 [ #13 action ] $n ti:set-action 8 [ #14 action ] $o ti:set-action 9 [ #15 action ] $p ti:set-action ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (catalogue) (key-bindings) 1 2 :catalogue:actions 3 catalogue:actions/a-i 4 catalogue:actions/j-p 5 &ti:done $0 ti:set-action 6 [ &Page v:dec constrain ] $1 ti:set-action 7 [ &Page v:inc constrain ] $2 ti:set-action 8 &catalogue:list $3 ti:set-action 9 &catalogue:jump $4 ti:set-action 10 &catalogue:rename $8 ti:set-action 11 &catalogue:leap $9 ti:set-action 12 [ #95 ti:help ] $? ti:set-action 13 ; 14 15 ---------------------------------------------------------------- 0 (catalogue) (hints) 1 2 :catalogue:hints 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Display #3 ti:add-hint 6 'Rename #8 ti:add-hint 7 'Quit #0 ti:add-hint 8 'Jump #4 ti:add-hint 9 'Leap #9 ti:add-hint 10 'catalogue ti:set-title ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (catalogue) (display) 1 2 {{ 3 :sep '_|_ s:put ; 4 :key I $a n:add c:put ; 5 :entry @Page #16 n:mul I n:add ; 6 :title entry set load 7 block:buffer n:dec #64 over store s:put ; 8 :num entry n:put nl ; 9 ---reveal--- 10 :catalogue:display 11 vt:clear vt:home 12 #16 [ key sep title sep num ] indexed-times ; 13 }} 14 15 ---------------------------------------------------------------- 0 (catalogue) (top-level) 1 2 :catalogue (-) 3 [ &catalogue:actions &catalogue:hints &catalogue:display ] 4 ti:application ; 5 6 &catalogue \catalog 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 catalogue shortcuts ============================================ 1 2 1 Display previous page of blocks 3 2 Display next page of blocks 4 3 Display a block. Enter this, then the block letter. 5 8 Rename a block. Press this, the block letter, then enter 6 the new name. End with enter. 7 4 Leap to a new page. Enter this, then the block number. 8 9 Leap to a new page. Enter this, then the first part of the 9 block title. 10 5 Run the code in a block. Enter this, then the block letter. 11 0 Quit the catalogue and return to the listener. 12 ? Displays this help screen 13 14 Enter a block letter (a-p) to load it in the editor. 15 ---------------------------------------------------------------- 0 tuhi : termina block editor ==================================== 1 2 This is designed to be similar in spirit to the basic editor in 3 Konilo, but makes use of the (termina) words to present a hotkey 4 driven interface for editing. 5 6 Tuhi has two display modes: 7 8 - plain text shown as a single color 9 - source code shown with syntax highlighting 10 11 Syntax mode will be used if the block starts with a "(" and 12 `tuhi:cfg/syntax` is set to true (non-zero). In other cases 13 the plain text mode is used. 14 15 ---------------------------------------------------------------- 0 (tuhi) (configuration) 1 2 &fg:cyan 'tuhi:cfg/colors,line# var-n 3 &bg:black 'tuhi:cfg/colors,bg var-n 4 &fg:green 'tuhi:cfg/colors,fg var-n 5 #-1 'tuhi:cfg/syntax var-n 6 #0 'tuhi:cfg/status var-n 7 #-1 'tuhi:cfg/bar var-n 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (list:syntax) (default-colors) 1 2 :~colon bg:black fg:red ; (: 3 :~immed bg:black fg:yellow ; (word:_[_]_; 4 :~number bg:black fg:cyan ; (# 5 :~char bg:black fg:blue ; ($ 6 :~string bg:black fg:white ; (' 7 :~pointer bg:black fg:magenta ; (& 8 :~comment bg:blue fg:white ; (( 9 :~var bg:black fg:magenta ; (@_or_! 10 :~normal bg:black fg:green ; 11 12 '~SigilColors d:create #9 comma 13 &~colon comma &~number comma &~char comma 14 &~string comma &~pointer comma &~comment comma 15 &~var comma &~var comma &~immed comma ---------------------------------------------------------------- 0 (tuhi) (list:syntax) (helpers) 1 2 ':#$'&(@! s:keep \~Sigils 3 '~last var 4 :~sigil? (c-cf) &~Sigils over s:contains? ; 5 6 :~color-sigil (c-c) 7 &~Sigils over s:index/c &~SigilColors swap a:fetch call ; 8 9 :~immed? (c-cf) 10 dup [ $[ eq? ] [ $] eq? ] [ $; eq? ] tri or or 11 @~last #32 eq? and ; 12 13 :~space? (c-cf) dup #32 eq? ; 14 :~prepare (n-an) #64 n:mul block:buffer n:add #64 #32 !~last ; 15 :~comment? (an-anf) over fetch $. eq? ; ---------------------------------------------------------------- 0 (tuhi) (list:syntax) (display) 1 2 :e:line/syntax (n-) 3 ~prepare ~comment? 4 [ ~comment [ fetch-next c:put ] times ] 5 [ [ fetch-next 6 ~sigil? [ @~last #32 eq? &~color-sigil if ] if 7 ~space? [ @~last #32 -eq? &~normal if ] if 8 ~immed? &~immed if 9 dup !~last c:put ] times ] 10 choose vt:reset @tuhi:cfg/bar [ sp $| c:put ] if nl drop ; 11 12 :~line# I dup #10 lt? &sp if n:put sp ; 13 :list:syntax (-) &tuhi:cfg/bar v:off 14 #16 [ ~line# I e:line/syntax ] indexed-times 15 &tuhi:cfg/bar v:on ; ---------------------------------------------------------------- 0 (tuhi) (display) 1 {{ 2 :status @tuhi:cfg/status &sys:info if ; 3 :line# @tuhi:cfg/colors,line# call I $a n:add c:put ; 4 :sep vt:reset '_|_ s:put ; 5 :text @tuhi:cfg/syntax block:buffer fetch $( eq? and 6 [ I e:line/syntax ] 7 [ @tuhi:cfg/colors,bg @tuhi:cfg/colors,fg 8 &call bi@ I e:to-line #64 [ fetch-next c:put ] 9 times drop vt:reset sp $| c:put nl ] choose ; 10 :reset @tuhi:cfg/syntax [ bg:black fg:white ] if ; 11 ---reveal--- 12 :tuhi:display (-) vt:clear vt:home 13 #16 [ line# sep text reset ] indexed-times status 14 'tuhi_# @Block n:to-s s:append ti:set-title ; 15 }} ---------------------------------------------------------------- 0 (tuhi) (key-actions) 1 2 (lines) 3 :tuhi:a #1 #5 vt:row,col 0 ; :tuhi:b #2 #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:4 12 &~Query 'Block_number: ti:prompt @~Query s:to-n !Block load ; 13 :tuhi:9 14 &~Query 'First_part_of_block_title: ti:prompt 15 @~Query block:first-matching !Block load ; ---------------------------------------------------------------- 0 (tuhi) (key-actions) 1 2 :tuhi:[ c:get $a n:sub e:unindent ; 3 :tuhi:] c:get $a n:sub e:indent ; 4 5 :tuhi:C c:get $a n:sub e:copy ; 6 :tuhi:V c:get $a n:sub e:paste ; 7 :tuhi:X c:get $a n:sub e:cut ; 8 9 :tuhi:? #111 ti:help ; 10 :tuhi:R @Block [ block:name needs ] dip !Block load ; 11 :tuhi:Q @tuhi:cfg/status not !tuhi:cfg/status ; 12 :tuhi:N new ; 13 :tuhi:+ &tuhi:cfg/syntax v:on ; 14 :tuhi:- &tuhi:cfg/syntax v:off ; 15 ---------------------------------------------------------------- 0 (tuhi) (key-actions) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (tuhi) (setup-key-actions-part-1) 1 2 :tuhi:actions/1 (-) 3 &prev $1 ti:set-action &next $2 ti:set-action 4 &tuhi:4 $4 ti:set-action 5 &run $5 ti:set-action &save $6 ti:set-action 6 &load $7 ti:set-action 7 &tuhi:9 $9 ti:set-action &ti:done $0 ti:set-action 8 &tuhi:a $a ti:set-action &tuhi:b $b ti:set-action 9 &tuhi:c $c ti:set-action &tuhi:d $d ti:set-action 10 &tuhi:e $e ti:set-action &tuhi:f $f ti:set-action 11 &tuhi:g $g ti:set-action &tuhi:h $h ti:set-action 12 &tuhi:i $i ti:set-action &tuhi:j $j ti:set-action 13 &tuhi:k $k ti:set-action &tuhi:l $l ti:set-action 14 &tuhi:m $m ti:set-action &tuhi:n $n ti:set-action 15 &tuhi:o $o ti:set-action &tuhi:p $p ti:set-action ; ---------------------------------------------------------------- 0 (tuhi) (setup-key-actions-part-2) 1 2 :tuhi:actions/2 (-) 3 &tuhi:[ $[ ti:set-action &tuhi:] $] ti:set-action 4 &tuhi:C $C ti:set-action &tuhi:V $V ti:set-action 5 &tuhi:X $X ti:set-action &tuhi:Q $Q ti:set-action 6 &tuhi:? $? ti:set-action 7 &tuhi:N $N ti:set-action 8 &tuhi:+ $+ ti:set-action &tuhi:- $- ti:set-action 9 &tuhi:R $R ti:set-action 10 ; 11 12 13 14 15 :tuhi:actions (-) tuhi:actions/1 tuhi:actions/2 ; ---------------------------------------------------------------- 0 (tuhi) (hints,_main_loop) 1 2 :tuhi:hints (-) 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Jump #4 ti:add-hint 6 'Run #5 ti:add-hint 7 'Save #6 ti:add-hint 8 'Load #7 ti:add-hint 9 'Leap #9 ti:add-hint 10 'Quit #0 ti:add-hint 11 'tuhi ti:set-title ; 12 13 :tuhi (-) 14 [ &tuhi:actions &tuhi:hints &tuhi:display ] ti:application ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 tuhi shortcuts ================================================= 1 2 Editing ======================================================== 3 a - p line entry [ un-indent line 4 N erase block contents ] indent line 5 X cut 6 C copy 7 V paste 8 R run all blocks in the current set 9 10 Display ======================================================== 11 Q toggle status line 12 ? display this help screen 13 + enable syntax highlighting 14 - disable syntax highlighting 15 ---------------------------------------------------------------- 0 rem : visual block editor ====================================== 1 2 rem is a block editor. It builds on the basic editor and tuhi, 3 but presents a more visual editing model. In rem you move a 4 cursor around the block, and enter code at the point where the 5 cursor appears. Edits do not erase the entire line. 6 7 qwertyuiop ',.pyfgcrl -------#-- Movement is performed by 8 asdfghjkl; aoeuidhtns ------###- the ijkl or chtk keys, to 9 zxcvbnm,./ ;qjkxbmwvz ---------- support qwerty & dvorak 10 11 a -> enter code N -> erase block contents 12 R -> run blocks in set < -> unindent 13 r -> run current block > -> indent 14 15 rem will display the block number as part of the title text. ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem) (display) 1 2 'Col var 'Row var 3 4 :~cursor @Row n:inc @Col #4 n:add dup-pair 5 vt:row,col bg:red fg:white $* c:put vt:row,col 6 vt:reset ; 7 8 :~redraw vt:home block:buffer 9 fetch $( eq? &list:syntax &list# choose ; 10 11 :rem:display ~redraw ~cursor 12 'rem_# @Block n:to-s s:append ti:set-title ; 13 14 15 ---------------------------------------------------------------- 0 (rem) (hints) 1 2 :rem:hints 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Enter #5 ti:add-hint 6 'Save #6 ti:add-hint 7 'Load #7 ti:add-hint 8 'Quit #0 ti:add-hint 9 'Jump #4 ti:add-hint 10 'Leap #9 ti:add-hint ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (rem) (editing,movement) 1 2 :~constrain @Row #0 #15 n:limit !Row 3 @Col #0 #63 n:limit !Col ; 4 5 :~up &Row v:dec ~constrain ; 6 :~dn &Row v:inc ~constrain ; 7 :~lf &Col v:dec ~constrain ; 8 :~rt &Col v:inc ~constrain ; 9 10 :~enter @Row @Col ~cursor bg:blue fg:white s:get/line 11 e:replace-at vt:reset clear ; 12 13 14 15 ---------------------------------------------------------------- 0 (rem) (keymap) 1 2 :~edit 3 &~enter $5 ti:set-action &~enter $a ti:set-action 4 [ @Row e:indent ] $> ti:set-action 5 [ @Row e:unindent ] $< ti:set-action 6 [ @Row e:cut ] $X ti:set-action 7 [ @Row e:copy ] $C ti:set-action 8 [ @Row e:paste ] $V ti:set-action 9 &tuhi:N $N ti:set-action 10 &tuhi:R $R ti:set-action 11 &tuhi:r $r ti:set-action 12 &save $6 ti:set-action 13 &load $7 ti:set-action 14 &ti:done $0 ti:set-action 15 [ #127 ti:help ] $? ti:set-action ; ---------------------------------------------------------------- 0 (rem) (keymap) 1 2 :~cursor-nav 3 &~up $i ti:set-action &~lf $j ti:set-action 4 &~dn $k ti:set-action &~rt $l ti:set-action 5 &~up $c ti:set-action &~lf $h ti:set-action 6 &~dn $t ti:set-action &~rt $n ti:set-action ; 7 8 :~block-nav 9 &prev $1 ti:set-action 10 &next $2 ti:set-action 11 &tuhi:9 $9 ti:set-action (leap) 12 &tuhi:4 $4 ti:set-action (jump) ; 13 14 :rem:actions 15 ~cursor-nav ~block-nav ~edit ; ---------------------------------------------------------------- 0 (rem) (top-level) 1 2 :rem 3 clear [ &rem:actions &rem:hints &rem:display ] 4 ti:application ; 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 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 ============================================================ 1 2 +---------------+--------+--------+ 3 | Action | Qwerty | Dvorak | 4 +===============+========+========+ 5 | Up | i | c | 6 | Down | k | t | 7 | Left | j | h | 8 | Right | l | s | 9 +---------------+--------+--------+----------------+---+ 10 | Indent Line | > | Run Block | r | 11 | Unindent Line | < | Run Set | R | 12 | Cut Line | X | Erase Contents | N | 13 | Copy Line | C | Enter Text | a | 14 | Paste Line | V | | | 15 +---------------+-----------------+----------------+---+ ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 WISP: Writing in Small Pieces 1 2 This is WISP, a log of my daily development efforts and things 3 happening in life. The basic idea is that I'll (try to) write a 4 block each day. 5 6 Since Konilo is intended to be m primary personal computing 7 environment for many years to come, I've started the WISP blocks 8 at a point that'll leave room for about 50 years of entries. I 9 can't guarantee that I'll use all of these: in 50 years from now 10 (2023) I'll be turning 90. 11 12 The next set of blocks is reserved for words relating to WISP. 13 Actual log entries follow in the next page and beyond. 14 15 ---------------------------------------------------------------- 0 WISP: Configuration 1 2 WISP has a couple of words that need editing if you wish to 3 use it. In the (wisp) block, you will need to edit `title`, 4 `to-end`, and `blocks`. 5 6 In `title`, change the block number to the number of your 7 title block. 8 9 In `to-end` and `blocks`, change the block number to the 10 first block in the WISP entry area of your block store. 11 12 I use a larger than standard block store (65,536 blocks), 13 with my title at 47,279 and the first data block at 47,280. 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wisp) 1 2 #3072 'wisp:Data var-n 3 4 :~sep (-) #64 [ $- c:put ] times nl ; 5 :~title (-) @wisp:Data set load list* ~sep ; 6 7 :~empty? (-f) @Block block:empty? ; 8 :~to-end (-n) @wisp:Data n:inc set 9 [ ~empty? dup [ next ] -if ] until @Block prev ; 10 :~blocks (n-n) @wisp:Data n:inc n:sub ; 11 :~display (-) list* ~sep ; 12 13 :wisp:list (-) ~title ~to-end ~blocks [ ~display prev ] times ; 14 :wisp:new (-) ~to-end edit ; 15 :wisp:latest (-) ~to-end n:dec edit ; ---------------------------------------------------------------- 0 (wisp) (actions) 1 2 :wisp:actions 3 [ prev &Block @wisp:Data @Blocks v:limit ] $1 ti:set-action 4 [ next &Block @wisp:Data @Blocks v:limit ] $2 ti:set-action 5 [ ~to-end drop ] $3 ti:set-action 6 [ wisp:new tuhi ] $4 ti:set-action 7 [ tuhi ] $8 ti:set-action 8 &ti:done $0 ti:set-action 9 ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wisp) (display,_hints,_top_level) 1 2 :wisp:display 3 vt:clear vt:home 4 fg:red #0 e:line vt:reset fg:cyan 5 #15 [ I n:inc e:line ] indexed-times vt:reset ; 6 7 :wisp:hints 8 'Previous #1 ti:add-hint 'Next #2 ti:add-hint 9 'Latest #3 ti:add-hint 'New #4 ti:add-hint 10 'Edit #8 ti:add-hint 11 'Quit #0 ti:add-hint 'wisp ti:set-title ; 12 13 :wisp (-) @wisp:Data !Block load 14 [ &wisp:actions &wisp:hints &wisp:display ] ti:application ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:wisp) 1 2 '(wisp) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 wiki =========================================================== 1 2 Wiki is my zettlekestan. It's a set of blocks, each serving as a 3 card with some information. These are linked by title. Links are 4 represented by words prefixed with a *. 5 6 There is an interactive browser that can be started with 7 `wiki:browse`. For use at the listener, enter `wiki title` to 8 see the page named `title`. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wiki) (configuration,_helper_words) 1 2 :wiki:START (-n) #16,384 ; 3 :wiki:MAX-BLOCKS (-) #10,000 ; 4 5 #-1 'wiki:Termina var-n (set_to_0_to_disable_color) 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wiki) (locate-blocks) 1 2 {{ 3 :target (s-s) 4 s:temp 'wiki:_ s:prepend '_ s:append s:to-lower s:keep ; 5 :title (-s) 6 I set load block:buffer n:dec #64 over store (s:to-lower ; 7 :match? (ss-sf) over s:begins-with? ; 8 ---reveal--- 9 :wiki:locate (s-n) 10 [ target #0 swap 11 @Blocks [ title match? [ [ I n:max ] dip ] if ] 12 indexed-times drop ] gc ; 13 }} 14 15 ---------------------------------------------------------------- 0 (wiki) (display-block,_find_and_display_block) 1 2 :~display-char (c-) 3 @wiki:Termina [ 4 dup $* eq? &fg:red if 5 dup #32 eq? &vt:reset if ] if c:put ; 6 :~reset @wiki:Termina &vt:reset if ; 7 :~line #64 [ fetch-next ~display-char ] times ~reset nl ; 8 :~title @wiki:Termina [ fg:white bg:blue ] if 9 #64 [ fetch-next c:put ] times ~reset nl ; 10 :~render block:buffer ~title #15 &~line times drop ; 11 12 :wiki s:get/token wiki:locate set load ~render ; 13 :wiki:list ~render ; 14 15 ---------------------------------------------------------------- 0 (wiki) (list-all-blocks) 1 2 {{ 3 :title block:buffer n:dec #64 over store ; 4 :get I set load ; 5 :page? title 'wiki:_ s:begins-with? ; 6 :name title #6 #58 s:middle ; 7 ---reveal--- 8 :wiki:all 9 @wiki:Termina &fg:red if 10 @Blocks [ get page? [ name s:put nl ] if ] indexed-times 11 @wiki:Termina &vt:reset if '---_end_of_pages s:put nl ; 12 }} 13 14 15 ---------------------------------------------------------------- 0 (wiki) (exits?,_new,_edit) 1 2 :wiki:exists? (s-f) wiki:locate n:-zero? ; 3 4 :wiki:new (-) 5 'start wiki:locate set load 6 [ next @Block block:empty? ] until @Block @Editor call ; 7 8 :wiki:edit (s-) 9 [ s:keep dup wiki:exists? 10 [ wiki:locate @Editor call ] 11 [ drop wiki:new ] choose ] gc ; 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wiki) (browser) 1 2 :wiki:* 3 [ s:get/token s:keep dup wiki:exists? 4 [ wiki:locate set load ] 5 [ drop wiki:new ] choose ] gc ; 6 7 :wiki:1 'start wiki:locate set load ; 8 :wiki:8 @Block @Editor call ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wiki) (browser) (key-bindings) 1 2 :wiki:actions (-) 3 &wiki:1 $1 ti:set-action 4 &wiki:8 $8 ti:set-action 5 &wiki:* $* ti:set-action 6 &wiki:new $3 ti:set-action 7 [ #191 ti:help ] $? ti:set-action 8 &ti:done $0 ti:set-action ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (wiki) (browser) 1 2 :wiki:hints 3 'Start #1 ti:add-hint 4 'Edit #8 ti:add-hint 5 'New #3 ti:add-hint 6 'Quit #0 ti:add-hint ; 7 8 :wiki:display (-) vt:clear vt:home wiki:list ; 9 10 :wiki:browse 11 'start wiki:locate set load 12 [ &wiki:actions &wiki:hints &wiki:display ] ti:application ; 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:wiki) 1 2 '(wiki) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 wiki shortcuts ================================================= 1 2 * enter *, then the wiki page name to jump to that page. 3 this will start the editor if a page does not exist. 4 5 1 jump to *Start in the wiki 6 3 start the editor on a new page 7 8 edit the current page 8 9 0 quit the wiki browser 10 11 ? bring up this help screen 12 13 14 15 ---------------------------------------------------------------- 0 (kohure) (data,_configuration) 1 2 #3 'kohure:Cells/Line var-n 3 'kohure:At var 4 5 :kohure:height (-n) @ti:height #4 n:sub ; 6 7 :~page-size (-n) kohure:height @kohure:Cells/Line n:mul ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (kohure) (supporting_words) 1 2 {{ 3 :check (a-f) 4 b:unpack 5 #-1 swap #0 #29 n:between? and 6 swap #0 #29 n:between? and 7 swap #0 #29 n:between? and 8 swap #0 #29 n:between? and ; 9 ---reveal--- 10 :bundle:valid? (n-nf) dup check ; 11 }} 12 13 14 15 ---------------------------------------------------------------- 0 (kohure) (supporting_words) 1 2 {{ 3 :names (-s) 4 '..lidudrswpupojucacccjreeqneltgtfestadsumudianorxoslsrcpcyio 5 ; 6 :inst->name (n-s) #2 n:mul names swap #2 s:middle ; 7 :name (n-s) 8 dup #0 #29 n:between? [ inst->name ] [ drop '** ] choose ; 9 ---reveal--- 10 :bundle:name (n-s) 11 bundle:valid? 12 [ b:unpack 'abcd 'dcba reorder 13 ' #4 [ swap name s:append ] times ] 14 [ drop '******** ] choose ; 15 }} ---------------------------------------------------------------- 0 (kohure) (display) 1 2 {{ 3 :pad (sn-s) [ '_ s:prepend ] times ; &fetch-next \fn 4 :addr (n-ns) dup n:to-s dup s:length #5 swap n:sub pad ; 5 :valu (n-s) n:to-s dup s:length #11 swap n:sub pad ; 6 :char (n-) dup #32 #126 n:between? [ drop $. ] -if c:put ; 7 :name (a-a) fetch-next bundle:name s:put sp ; 8 :reset (a-an) @kohure:Cells/Line n:sub @kohure:Cells/Line ; 9 :line (a-a) 10 addr s:put sp sp @kohure:Cells/Line &name times reset 11 [ fn valu s:put sp ] times reset [ fn char ] times nl ; 12 ---reveal--- 13 :kohure:display (-) vt:clear vt:home 14 @kohure:At kohure:height &line times drop ; 15 }} ---------------------------------------------------------------- 0 (kohure) (actions) 1 2 :~jump ("-) s:get/token s:to-n !kohure:At ; 3 4 :~leap ("-) 5 s:get/token s:temp dup d:exists? 6 [ d:lookup d:address fetch ] 7 [ drop #0 ] choose !kohure:At ; 8 9 :~pali ("-) 10 [ n:get s:get/token s:temp i here n:dec fetch swap store ] 11 gc ; 12 13 :~raw ("-) 14 n:get n:get swap store ; 15 ---------------------------------------------------------------- 0 (kohure) (keyboard-handler) 1 2 :kohure:actions 3 &ti:done $0 ti:set-action 4 [ ~page-size &kohure:At v:dec-by ] $1 ti:set-action 5 [ ~page-size &kohure:At v:inc-by ] $2 ti:set-action 6 &~jump $4 ti:set-action 7 &~leap $9 ti:set-action 8 &~pali $3 ti:set-action 9 &~raw $8 ti:set-action 10 [ #159 ti:help ] $? ti:set-action 11 ; 12 13 14 15 ---------------------------------------------------------------- 0 (kohure) (hints,_top_level) 1 2 :kohure:hints 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Jump #4 ti:add-hint 6 'Leap #9 ti:add-hint 7 'Quit #0 ti:add-hint 8 'Assemble #3 ti:add-hint 9 'Value #8 ti:add-hint 10 ; 11 12 :kohure 13 [ &kohure:actions &kohure:hints &kohure:display ] 14 ti:application ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:kohure) 1 2 '(kohure) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kohure ========================================================= 1 2 This is a small program to browse or edit the memory, displaying 3 each cell as an instruction bundle, a raw value, and an ASCII 4 value. 5 6 For entry (4, 8), enter the address, a space, then the value. 7 8 ? display this help screen 9 1 go to the prior page of addresses 10 2 go to the next page of addresses 11 3 assemble an instruction bundle and store in an address 12 4 enter an address, display will switch to said address 13 8 enter a raw value to store in an address 14 9 enter a word name, display will switch to its start 15 0 quit kohure ---------------------------------------------------------------- 0 Gopher, Gemini, and HTTP ======================================= 1 2 3 4 5 6 7 8 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 (blocks.html) (generate-blocks.html-index) 1 2 :desc I set load block:buffer n:dec #64 over store s:put ; 3 :link ' &s:put tri@ ; 4 :close '
s:put nl ; 5 :entry I n:put ':_ s:put link desc close ; 6 :generate @Blocks &entry indexed-times ; 7 8 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 Pig : A Game of Chance 1 2 Pig is a simple dice game in which players take turns rolling 3 a single dice as many times as they desired, adding the value 4 of each roll to a running total. If they roll a 1, their turn 5 ends and the gained score is lost. 6 7 The following blocks implement this game for use at the basic 8 listener and as a Termina program. 9 10 Loading: 11 12 * game:pig 13 14 To play, run `game:pig` (for the basic version) or `pig` (for 15 the Termina version). ---------------------------------------------------------------- 0 (game:pig) (a-game-of-chance) (requires:_dusk:rng,_dusk:dice) 1 2 . +----------+--------------------------------+ 3 . | Variable | Holds | 4 . +----------+--------------------------------+ 5 . | Score.a | Player 1 Score | 6 . | Score.b | Player 2 Score | 7 . | Acc | Accumulator for current round | 8 . | Active | Current player ID (0 or 1) | 9 . | Roll | Current die roll | 10 . | Done | Is game done? | 11 . +----------+--------------------------------+ 12 13 'Score.a var 'Score.b var 'Acc var 14 'Active var 'Roll var 'Done var 15 ---------------------------------------------------------------- 0 (game:pig) (a-game-of-chance) (requires:_dusk:rng,_dusk:dice) 1 2 :winner (-n) @Score.a @Score.b lt? [ #2 ] [ #1 ] choose ; 3 :display:win 'Player_ s:put winner n:put '_wins! s:put nl ; 4 :score (n-n) [ @Score.b ] [ @Score.a ] choose ; 5 :total (n-) [ 'Player_ s:put n:inc n:put ':__ s:put ] 6 [ score n:put nl ] bi ; 7 :totals #0 total #1 total nl ; 8 :rolled 'Rolled_ s:put @Roll n:put nl nl totals ; 9 :player 'Player_ s:put @Active n:inc n:put ; 10 :has ':_has_ s:put @Acc n:put ; 11 :total '__total:_ s:put @Acc @Active score n:add n:put ; 12 :menu 'roll(1) 'halt(2) 'restart(3) [ s:put tab ] tri@ 13 'quit(0) s:put nl ; 14 :display clear rolled player has total nl nl menu ; 15 ---------------------------------------------------------------- 0 (game:pig) (a-game-of-chance) (requires:_dusk:rng,_dusk:dice) 1 2 :pig:restart (-) 3 &Score.a &Score.b &Acc &v:off tri@ 4 &Done &Roll &Active &v:off tri@ ; 5 6 :switch 7 @Active dup #1 xor !Active 8 [ @Score.b @Acc n:add !Score.b ] 9 [ @Score.a @Acc n:add !Score.a ] choose #0 !Acc ; 10 11 :decide 12 dup #1 eq? 13 [ drop-pair #0 !Acc switch #0 ] [ n:add ] choose ; 14 15 :turn @Acc dice:roll dup !Roll decide !Acc ; ---------------------------------------------------------------- 0 (game:pig) (a-game-of-chance) (requires:_dusk:rng,_dusk:dice) 1 2 :done? 3 @Active 4 [ @Score.b @Acc n:add @Score.a ] 5 [ @Score.a @Acc n:add @Score.b ] choose 6 [ #100 gteq? ] bi@ or [ &Done v:on ] if @Done ; 7 8 :game:pig pig:restart 9 [ display c:get 10 dup $1 eq? &turn if 11 dup $2 eq? &switch if 12 dup $3 eq? &pig:restart if 13 dup $0 eq? [ #1 !Done ] if 14 drop done? ] until display:win ; 15 ---------------------------------------------------------------- 0 (game:pig) (a-game-of-chance) (requires:_dusk:rng,_dusk:dice) 1 2 :pig:hints 3 'Roll #1 ti:add-hint 'Halt #2 ti:add-hint 4 'Restart #3 ti:add-hint 'Quit #0 ti:add-hint ; 5 6 :pig:actions 7 &turn $1 ti:set-action 8 &switch $2 ti:set-action 9 &pig:restart $3 ti:set-action 10 &ti:done $0 ti:set-action ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (game:pig) (a-game-of-chance) (requires:_dusk:rng,_dusk:dice) 1 2 :~at #1 #30 vt:row,col ; 3 :~dice &dice:Relative v:on @Roll dice:draw ; 4 5 :pig:display clear rolled player has total ~at ~dice done? 6 [ clear display:win c:get drop pig:restart ] if ; 7 8 9 10 11 12 13 14 :pig [ &pig:actions &pig:hints &pig:display ] ti:application ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:game:pig) 1 2 '(dusk:rng) needs 3 '(dusk:dice) needs 4 '(game:pig) needs 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Conway's Game of Life 1 2 From wikipedia: 3 4 Life is a cellular automaton devised by John Conway in 1970. 5 The universe of the game of life is an infinite, 2D grid of 6 square cells, each of which can be in one of two states, alive 7 or dead. Each cell interacts with its eight neighbors. At each 8 step, the following transitions occur: 9 10 - A live cell w/2 or fewer neighbors dies by underpopulation 11 - A live cell w/2 or 3 neighbors survives 12 - A live cell w/more than 3 neighbors dies by overpopulation 13 - A dead cell with exactly 3 neighbors becomes alive 14 15 These rules are applied across the grid, for each generation. ---------------------------------------------------------------- 0 (game: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 (game: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 (game: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 (game: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 (game: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 (game: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 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:game:conways-life) 1 2 '(game:conways-life) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (game:roulette-simulator) 1 2 . Based on code by Ian Martin Ajzenszmidt in the 3 . Facebook Forth2020 Forth Programming Language Group 4 5 :WHEEL-SLOTS (-n) #37 ; 6 :GREEN (-n) #0 ; 7 8 :spin-wheel (-n) WHEEL-SLOTS n:random-mod ; 9 10 :red? (n-f) 11 dup GREEN eq? [ drop FALSE ] [ #10 n:mod n:odd? ] choose ; 12 13 :even? (n-flag) 14 dup GREEN eq? [ drop FALSE ] [ #2 n:mod n:zero? ] choose ; 15 ---------------------------------------------------------------- 0 (game:roulette-simulator) 1 2 :.green (n-) 'Result:_GREEN_0 s:put nl drop ; 3 :.red (-) 'Red s:put nl ; 4 :.black (-) 'Black s:put nl ; 5 :.even (-) 'Even s:put nl ; 6 :.odd (-) 'Odd s:put nl ; 7 8 :display-result (n-) 9 'Debug:_Stack_before_display-result:_ s:put .s nl 10 dup GREEN eq? 11 [ .green ] 12 [ 'Result:_ s:put dup n:put nl 13 dup red? &.red &.black choose 14 even? &.even &.odd choose ] choose 15 'Debug:_Stack_after_display-result:_ s:put .s nl ; ---------------------------------------------------------------- 0 (game:roulette-simulator) 1 2 :play-roulette (-) 3 spin-wheel display-result ; 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (taotaka) (data_structures,_categories) 1 2 '~titles d:create #144 comma #144 allot 3 '~addrs d:create #144 comma #144 allot 4 '~page var 5 6 . resets the menu to empty 7 8 :taotaka:initialize (-) (reset_the_menu_to_empty) 9 #0 &~titles n:inc #144 fill [ ] &~addrs n:inc #144 fill ; 10 11 taotaka:initialize 12 13 14 15 ---------------------------------------------------------------- 0 (taotaka) (data_accessors) 1 2 :taotaka:add (asn-) 3 @~page #16 n:mul n:add [ s:keep &~titles ] dip 4 &a:store sip &~addrs swap a:store ; 5 6 :taotaka:get/address (n-a) 7 @~page #16 n:mul n:add &~addrs swap a:fetch ; 8 9 :taotaka:get/title (n-s) 10 @~page #16 n:mul n:add &~titles swap a:fetch 11 dup n:zero? [ drop '_ ] if ; 12 13 14 15 ---------------------------------------------------------------- 0 (taotaka) (display) 1 2 {{ 3 :title (-) I taotaka:get/title s:put ; 4 :line# (-) I $a n:add c:put sp $| c:put sp ; 5 ---reveal--- 6 :taotaka:display (-) 7 vt:clear vt:home #16 [ line# title nl ] indexed-times ; 8 }} 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (taotaka) (key-actions) 1 2 :taotaka:run (n-) 3 taotaka:get/address call ; 4 5 :taotaka:a #0 taotaka:run ; :taotaka:b #1 taotaka:run ; 6 :taotaka:c #2 taotaka:run ; :taotaka:d #3 taotaka:run ; 7 :taotaka:e #4 taotaka:run ; :taotaka:f #5 taotaka:run ; 8 :taotaka:g #6 taotaka:run ; :taotaka:h #7 taotaka:run ; 9 :taotaka:i #8 taotaka:run ; :taotaka:j #9 taotaka:run ; 10 :taotaka:k #10 taotaka:run ; :taotaka:l #11 taotaka:run ; 11 :taotaka:m #12 taotaka:run ; :taotaka:n #13 taotaka:run ; 12 :taotaka:o #14 taotaka:run ; :taotaka:p #15 taotaka:run ; 13 14 15 ---------------------------------------------------------------- 0 (taotaka) (key-actions) 1 2 :taotaka:actions 3 &taotaka:a $a ti:set-action &taotaka:b $b ti:set-action 4 &taotaka:c $c ti:set-action &taotaka:d $d ti:set-action 5 &taotaka:e $e ti:set-action &taotaka:f $f ti:set-action 6 &taotaka:g $g ti:set-action &taotaka:h $h ti:set-action 7 &taotaka:i $i ti:set-action &taotaka:j $j ti:set-action 8 &taotaka:k $k ti:set-action &taotaka:l $l ti:set-action 9 &taotaka:m $m ti:set-action &taotaka:n $n ti:set-action 10 &taotaka:o $o ti:set-action &taotaka:p $p ti:set-action 11 [ #0 !~page ] $1 ti:set-action [ #1 !~page ] $2 ti:set-action 12 [ #2 !~page ] $3 ti:set-action [ #3 !~page ] $4 ti:set-action 13 [ #4 !~page ] $5 ti:set-action [ #5 !~page ] $6 ti:set-action 14 [ #6 !~page ] $7 ti:set-action [ #7 !~page ] $8 ti:set-action 15 [ #8 !~page ] $9 ti:set-action &ti:done $0 ti:set-action ; ---------------------------------------------------------------- 0 (taotaka) (top-level) 1 2 :taotaka:hints (-) 3 'Programs #1 ti:add-hint 4 'Fun_&_Games #2 ti:add-hint 5 'Quit #0 ti:add-hint 6 'Settings #9 ti:add-hint 7 ; 8 9 10 11 12 13 :taotaka (-) 14 [ &taotaka:actions &taotaka:hints &taotaka:display ] 15 ti:application ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (taotaka) (populate-categories) 1 2 #0 !~page 3 4 [ ] 'Programs_=========================== #0 taotaka:add 5 &catalogue 'Catalogue_____explore_the_blocks #2 taotaka:add 6 &tuhi 'Tuhi__________block_editor #3 taotaka:add 7 [ '(kohure) 'kohure invoke ] 'Kohure #4 taotaka:add 8 [ '(listener) 'listener invoke ] 'Listener #5 taotaka:add 9 10 [ ] 'Writing_&_Information_============== #7 taotaka:add 11 [ '(wiki) 'wiki:browse invoke ] 'Wiki #9 taotaka:add 12 [ '(wisp) 'wisp invoke ] 'WISP #10 taotaka:add 13 [ '(man) 'manual invoke ] 'Manual #11 taotaka:add 14 15 ---------------------------------------------------------------- 0 (taotaka) (populate-categories) 1 2 #1 !~page 3 4 [ ] 'Fun_&_Games_========================= #0 taotaka:add 5 [ '(jmf:mandelbrot) 'jmf:mandelbrot invoke ] 6 'JMF's_Mandelbrot #2 taotaka:add 7 8 9 10 11 12 13 14 15 #0 !~page ---------------------------------------------------------------- 0 (taotaka) (populate-categories) 1 2 #8 !~page 3 4 [ ] 'Settings_============================ #0 taotaka:add 5 6 &vt:colored 'Terminal:_Colored #2 taotaka:add 7 &vt:mono 'Terminal:_Monochrome #3 taotaka:add 8 9 10 11 12 13 14 15 #0 !~page ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:taotaka) 1 2 '(taotaka) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (kowae) (a-program-launcher) 1 2 {{ 3 'x var 'y var 'h var 'w var 4 :color (-) bg:black fg:red ; 5 :*** (n-) color [ $# c:put ] times ; 6 :*-* (n-) color $# c:put vt:reset &sp times color $# c:put ; 7 :top (-) @x @y vt:row,col @w *** ; 8 :bot (-) @x @h n:add n:dec @y vt:row,col @w *** ; 9 :mid (-) @x I n:add n:inc @y vt:row,col @w #2 n:sub *-* ; 10 ---reveal--- 11 :kowae:box (xyhw-) !w !h !y !x 12 top @h #2 n:sub &mid indexed-times bot ; 13 }} 14 15 ---------------------------------------------------------------- 0 (kowae) (a-program-launcher) 1 2 {{ 3 :draw (xy-) #5 #20 kowae:box vt:reset ; 4 :label (xyc-) fg:green &vt:row,col dip c:put vt:reset ; 5 ---reveal--- 6 :kowae:boxes (-) 7 #1 #4 draw #1 #28 draw #1 #52 draw 8 #7 #4 draw #7 #28 draw #7 #52 draw 9 #13 #4 draw #13 #28 draw #13 #52 draw 10 11 #4 #22 $7 label #10 #22 $4 label #16 #22 $1 label 12 #4 #46 $8 label #10 #46 $5 label #16 #46 $2 label 13 #4 #70 $9 label #10 #70 $6 label #16 #70 $3 label ; 14 }} 15 ---------------------------------------------------------------- 0 (kowae) (a-program-launcher) (menu-item-text) 1 2 :kowae:labels (-) 3 fg:cyan 4 #3 #5 vt:row,col fg:white '____Catalogue_____ s:put (right) 5 #9 #5 vt:row,col fg:white '______Kohure______ s:put 6 #15 #5 vt:row,col fg:white '_____Listener_____ s:put 7 8 #3 #29 vt:row,col fg:white '__________________ s:put (mid) 9 #9 #29 vt:row,col fg:white '__________________ s:put 10 #15 #29 vt:row,col fg:white '__________________ s:put 11 12 #3 #53 vt:row,col fg:white '_______Tuhi_______ s:put (left) 13 #9 #53 vt:row,col fg:white '_______WISP_______ s:put 14 #15 #53 vt:row,col fg:white '_______Wiki_______ s:put 15 ; ---------------------------------------------------------------- 0 (kowae) (a-program-launcher) 1 2 :kowae:display (-) 3 vt:clear vt:home 4 kowae:boxes kowae:labels vt:reset 5 #20 #1 vt:row,col ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (kowae) (a-program-launcher) (key-bindings) 1 2 'kowae:Programs d:create #9 comma #9 allot 3 4 :kowae:add-program (qn-) n:dec &kowae:Programs swap a:store ; 5 6 &tuhi #9 kowae:add-program 7 [ ] #8 kowae:add-program 8 &catalogue #7 kowae:add-program 9 [ '(wisp) 'wisp invoke ] #6 kowae:add-program 10 [ ] #5 kowae:add-program 11 [ '(kohure) 'kohure invoke ] #4 kowae:add-program 12 [ '(wiki) 'wiki:browse invoke ] #3 kowae:add-program 13 [ ] #2 kowae:add-program 14 [ '(listener) 'listener invoke ] #1 kowae:add-program 15 ---------------------------------------------------------------- 0 (kowae) (a-program-launcher) 1 2 :kowae:valid? (c-cf) dup $0 $9 n:between? ; 3 :kowae:run (c-) 4 $0 n:sub n:dec &kowae:Programs swap a:fetch call ; 5 6 :kowae (-) 7 [ clear kowae:display c:get kowae:valid? 8 &kowae:run &drop choose ] forever ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:kowae) 1 2 '(kowae) needs 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 '(jmf:mandelbrot) needs 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (jmf:mandelbrot) (data,_scaling_support) 1 2 'x var 'y var 'iter var 'posx var 'posy var 3 4 #128 'max-iter var-n 5 #1 'zoom var-n 6 7 :ascii-equiv (n-c) 8 #9 n:mul @max-iter n:div '_.:-=+*#%@ swap s:fetch ; 9 10 :f* n:mul #10000 n:div ; 11 12 13 14 15 ---------------------------------------------------------------- 0 (jmf:mandelbrot) (calculating-values-for-pasition) 1 2 code: a 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 . :a #2 @x n:mul @y f* n:add swap @x dup f* @y dup f* 14 . n:sub n:add !x !y @x @y f* @y dup f* n:add #40,000 lteq? 15 . @iter @max-iter lt? and ; ---------------------------------------------------------------- 0 (jmf:mandelbrot) (drawing-loop) 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 (jmf:mandelbrot) (zoom,_positioning_view) 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 12 13 14 15 ---------------------------------------------------------------- 0 (jmf:mandelbrot) (termina_interface:_hints,_actions) 1 2 :mandelbrot:hints 3 'Zoom_In #1 ti:add-hint 'Zoom_Out #2 ti:add-hint 4 'Up #3 ti:add-hint 'Down #4 ti:add-hint 5 'Left #5 ti:add-hint 'Right #6 ti:add-hint 6 'Res_Up #7 ti:add-hint 'Res_Down #8 ti:add-hint 7 'Quit #0 ti:add-hint ; 8 9 :mandelbrot:actions 10 &zoom+ $1 ti:set-action &zoom- $2 ti:set-action 11 &up $3 ti:set-action &down $4 ti:set-action 12 &left $5 ti:set-action &right $6 ti:set-action 13 &res+ $7 ti:set-action &res- $8 ti:set-action 14 &ti:done $0 ti:set-action ; 15 ---------------------------------------------------------------- 0 (jmf:mandelbrot) (termina_interface:_display) 1 2 :mandelbrot:display 3 vt:clear vt:home 4 @ti:height #4 n:sub [ 5 @ti:width [ 6 I #438 n:mul #25000 n:sub @zoom n:div @posx n:add 7 J #800 n:mul #10000 n:sub @zoom n:div @posy n:add 8 mb:value ascii-equiv c:put 9 ] indexed-times nl 10 ] indexed-times ; 11 12 :jmf:mandelbrot 13 [ &mandelbrot:actions &mandelbrot:hints &mandelbrot:display ] 14 ti:application ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:jmf:mandelbrot) 1 2 '(jmf:mandelbrot) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (kaute) 1 2 'ss:Sheet var 3 4 :ss:rows (-n) @ss:Sheet fetch ; 5 :ss:cols (-n) @ss:Sheet n:inc fetch ; 6 :ss:load (a-) !ss:Sheet ; 7 :ss:size (-n) ss:rows ss:cols n:mul ; 8 :ss:new (rc-a) here !ss:Sheet swap comma comma 9 ss:size #2 n:mul [ #0 comma ] times 10 @ss:Sheet ; 11 :ss:create (rcs-) d:create ss:new drop ; 12 :ss:offset (rc-n) swap ss:cols n:mul n:add ; 13 :ss:data (rc-a) ss:offset @ss:Sheet n:add #2 n:add ; 14 :ss:types (rc-a) ss:data ss:size n:add ; 15 ---------------------------------------------------------------- 0 (kaute) 1 2 :ss:store-n (nrc-) dup-pair [ [ ss:data store ] dip ] dip 3 ss:types #0 swap store ; 4 :ss:store-s (src-) dup-pair 5 [ [ ss:data &s:keep dip store ] dip ] dip 6 ss:types #1 swap store ; 7 :ss:store-a (nrc-) dup-pair [ [ ss:data store ] dip ] dip 8 ss:types #2 swap store ; 9 10 :ss:fetch (arc-vt) ss:data &fetch sip ss:size n:add fetch ; 11 12 :ss:action (rc-nt) ss:fetch #2 eq? 13 [ call ] [ drop #0 #0 ] choose ; 14 15 ---------------------------------------------------------------- 0 (kaute) 1 2 :~name (vr-vrs) over I n:to-s s:append ; 3 :~define (r-r) &dtc compile:call 4 &internal:lit comma 5 dup comma 6 &internal:lit comma 7 I comma 8 #0 comma ; 9 10 11 :ss:make-fields (rcv-) 12 '_ [ #0 s:store ] sip roll 13 [ ~name d:create ~define ] indexed-times drop-pair ; 14 15 ---------------------------------------------------------------- 0 (kaute) 1 2 #0 #5 $A ss:make-fields #1 #5 $B ss:make-fields 3 #2 #5 $C ss:make-fields #3 #5 $D ss:make-fields 4 #4 #5 $E ss:make-fields #5 #5 $F ss:make-fields 5 #6 #5 $G ss:make-fields #7 #5 $H ss:make-fields 6 #8 #5 $I ss:make-fields #9 #5 $J ss:make-fields 7 #10 #5 $K ss:make-fields #11 #5 $L ss:make-fields 8 #12 #5 $M ss:make-fields #13 #5 $N ss:make-fields 9 #14 #5 $O ss:make-fields 10 11 . Quick fetches to guarantee return type validity 12 13 :ss:fetch-n (rc-n) ss:fetch n:-zero? [ drop #0 ] if ; 14 :ss:fetch-s (rc-s) ss:fetch #1 -eq? [ drop '_ ] if ; 15 :ss:fetch-a (rc-a) ss:fetch #2 -eq? [ drop [ ] ] if ; ---------------------------------------------------------------- 0 (kaute) 1 2 :ss:NUMBER #0 ; 3 :ss:STRING #1 ; 4 :ss:ACTION #2 ; 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kaute : a headless spreadsheet : overview 1 2 The kaute vocabulary provides support for creating and working 3 with data stored in a spreadsheet format. It primarily provides 4 functionality, not presentation. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kaute : a headless spreadsheet : data structure 1 2 In memory, a sheet is structured as: 3 4 rows 5 columns 6 ... ( rows cells * ) ... data 7 ... ( rows cells * ) ... types 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kaute : a headless spreadsheet : data types 1 2 # Types 3 4 Kaute currently supports three types of data in a cell: 5 6 - numbers 7 - pointers to strings 8 - pointers to actions 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kaute : a headless spreadsheet : actions 1 2 # Actions 3 4 Action cells are written as quotes, which return a value & type 5 pair. An example might look like: 6 7 [ A1 ss:fetch-n A2 ss:fetch-n n:mul ss:NUMBER ] 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kaute : a headless spreadsheet : strings 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 kaute : a headless spreadsheet : numbers 1 2 Most cells contain numbers. These are just standard numeric 3 values, and can be in any format that fits in a cell. I mostly 4 use simple integers, but do sometimes make use of scaled values. 5 6 It might be of interest to expand this, to separate out the use 7 of integers, scaled values, and dusk's fixed & floating point 8 values. I'm not going to work on this for now (May 2024). 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:kaute) 1 2 '(kaute) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (a-mini-spreadsheet) 1 2 . ripanga is a mini spreadsheet implemented using the (kaute) 3 . vocabulary. It's limited to a single 15 row by 5 column sheet. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (display) 1 2 :n:put/padded (n-) 3 n:to-s [ s:length #12 swap n:sub &sp times ] [ s:put ] bi ; 4 5 :s:put/padded (s-) 6 dup s:length #12 gt? [ #12 s:left ] if dup s:put 7 s:length #12 swap n:sub &sp times ; 8 9 :~bar 10 sp sp #5 11 [ '----- s:put I n:put '------__ s:put ] indexed-times nl ; 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (display) 1 2 :number? (t-f) n:zero? ; 3 4 :~display-cell (nt-) 5 number? 6 [ fg:white n:put/padded ] 7 [ fg:cyan s:put/padded ] choose vt:reset sp sp ; 8 9 :action? (t-f) dup #2 eq? ; 10 11 :~cell (nt-) action? [ drop call ] if ~display-cell ; 12 13 :~row (n-) 14 fg:red dup $A n:add c:put vt:reset sp 15 #5 [ dup I ss:fetch ~cell ] indexed-times drop nl ; ---------------------------------------------------------------- 0 (ripanga) (display) 1 2 :ss:put (a-) 3 ss:load fg:red ~bar 4 #15 [ I ~row ] indexed-times ; 5 6 :highlight-cell (rc-) 7 [ #2 n:add ] dip #14 n:mul #3 n:add dup-pair vt:row,col 8 bg:blue fg:white '____________ s:put vt:row,col ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (entry) 1 2 :enter-number (rc"-) 3 dup-pair highlight-cell n:get 4 roll ss:store-n ; 5 6 7 :enter-string (rc"-) 8 dup-pair highlight-cell s:get/line 9 roll ss:store-s ; 10 11 12 :enter-action (rc"-) 13 ; 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 ripanga.txt 1 2 Ripanga is a sort of mini-spreadsheet. It has two parts: a small 3 vocabulary for creating, updating, and display of the sheet, and 4 a termina based front end for interactive use. 5 6 The data is limited to 15 rows, with 5 columns per row. 7 8 Parts: ripanga core, ripanga interface, ripanga formulas 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:ripanga) 1 2 '(kaute) needs 3 '(ripanga) needs 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (hints) 1 2 :ss:hints 3 'Quit #0 ti:add-hint 4 'ripanga ti:set-title 5 'New_Sheet #1 ti:add-hint 6 'Load_Sheet #6 ti:add-hint 7 'Enter_Num #3 ti:add-hint 8 'Enter_String #8 ti:add-hint 9 10 11 12 13 14 15 ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (actions) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (actions) 1 2 :ss:actions 3 &ti:done $0 ti:set-action 4 [ &~Query 'Sheet_Name: ti:prompt @~Query d:lookup d:address 5 fetch ss:load ] $6 ti:set-action 6 [ &~Query 'Sheet_Name: ti:prompt @~Query d:create 7 #15 #5 ss:new drop ] $1 ti:set-action 8 9 [ c:get c:to-upper $A n:sub c:get $0 n:sub enter-number ] 10 $3 ti:set-action 11 12 [ c:get c:to-upper $A n:sub c:get $0 n:sub enter-string ] 13 $8 ti:set-action 14 15 ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (top-level) 1 2 3 4 :ripanga (-) 5 [ &ss:actions &ss:hints 6 [ vt:reset clear @ss:Sheet ss:put ] ] ti:application ; 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ripanga) (test-data) 1 2 #15 #5 'Foo ss:create 3 4 'Counts A0 ss:store-s 5 'Eggs B0 ss:store-s #61 B1 ss:store-n 6 'Cauliflower C0 ss:store-s #3 C1 ss:store-n 7 'Broccoli D0 ss:store-s #1 D1 ss:store-n 8 'Sweet_Potato E0 ss:store-s #7 E1 ss:store-n 9 [ #4 [ I n:inc #1 ss:fetch-n ] indexed-times 10 n:add n:add n:add ss:NUMBER ] A1 ss:store-a 11 12 13 14 15 ---------------------------------------------------------------- 0 (dict) (dictionary-lookups) 1 2 :dict:voa ('-) s:get/token 'dict/voa_ describe:word ; 3 :dict:tokipona ('-) s:get/token 'dict/tokipona_ describe:word ; 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:dict) 1 2 '(dict) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (veltas:weak) 1 2 . Got an idea for a word you can run after a colon def 'WEAK' 3 . that removes the definition if it's a redefinition 4 . 5 . Can write specialised/optimised definitions for a platform and 6 . then the WEAK cross-platform definition later 7 8 :d:lookup-hash (n-d) &d:lookup #2 n:add call ; 9 10 :~get @Dictionary d:hash fetch ; 11 :~scan fetch !Dictionary d:lookup-hash ; 12 :~remove [ @Dictionary dup fetch !Dictionary !Free ] if ; 13 :weak (-) 14 ~get @Dictionary &~scan sip !Dictionary n:-zero? ~remove ; 15 ---------------------------------------------------------------- 0 (veltas:braces) 1 2 'Braces d:create here comma #64 allot 3 4 :>braces (depth-) 5 &Braces v:inc @Braces store ; 6 7 :braces> (-depth) 8 @Braces fetch &Braces v:dec ; 9 10 :{ (-) depth/data >braces ; 11 :} (-) depth/data braces> n:inc -eq? 12 [ 'Unbalanced_expression! s:put nl ] if ; 13 14 . a port of the vocabulary veltas wrote about in his blog. See 15 . https://veltas.co.uk/blog/forth-expr.htm ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (vms14:sentence-generator) 1 2 :sigil:" s:keep ; &sigil:" $" sigil:set 3 :make-array (...n-a) here [ dup comma &comma times ] dip ; 4 :one-of (an-s) n:random-mod a:fetch ; 5 6 "hit "took "saw "liked #4 make-array \Verbs 7 "man "ball "woman "table #4 make-array \Nouns 8 "the "a #2 make-array \Articles 9 10 :verb &Verbs #4 one-of ; 11 :noun &Nouns #4 one-of ; 12 :article &Articles #2 one-of ; 13 :noun-phrase article s:put sp noun s:put sp ; 14 :verb-phrase verb s:put sp noun-phrase ; 15 :sentence noun-phrase verb-phrase ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (kipingram:me) 1 2 . Kip has a `me` word for jumping to the start of a word. This 3 . implements it for Konilo. 4 5 . Requires: (immediate) 6 7 :me &Dictionary fetch d:address fetch &internal:lit comma 8 comma &jump comma ; immediate 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 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:unsigned) (experiments-in-unsigned-numbers) 1 2 :u:patch (n-n) 3 dup n:negative? 4 [ #2147483647 n:add n:inc swap #-2147483648 n:sub n:add ] if ; 5 6 :u:add (nn-n) n:add u:patch ; 7 :u:sub (nn-n) n:sub u:patch ; 8 :u:mul (nn-n) n:mul u:patch ; 9 :u:div (nn-n) 10 dup n:zero? [ drop-pair n:MAX ] [ n:div u:patch ] choose ; 11 :u:mod (nn-n) 12 dup n:zero? [ drop-pair n:MAX ] [ n:mod u:patch ] choose ; 13 14 15 ---------------------------------------------------------------- 0 (crc:unsigned) (experiments-in-unsigned-numbers) 1 2 :u:eq? (nn-f) or not ; 3 :u:-eq? (nn-f) u:eq? not ; 4 :u:lt? (nn-f) over or and n:negative? ; 5 :u:gt? (nn-f) tuck or and n:negative? ; 6 7 8 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:double) (experimental-double-cell-numbers) 1 2 '~res var 3 4 :dn:h@ (D-n) fetch ; 5 :dn:l@ (D-n) n:inc fetch ; 6 :dn:h! (nD-) store ; 7 :dn:l! (nD-) n:inc store ; 8 9 :dn:new (-D) here #0 dup comma comma ; 10 11 :dn:lows (DD-nn) [ dn:l@ ] bi@ ; 12 :dn:highs (DD-nn) [ dn:h@ ] bi@ ; 13 14 :dn:make (nn-D) here [ swap comma comma ] dip ; 15 :dn:put fetch-next n:put sp fetch n:put nl ; ---------------------------------------------------------------- 0 (crc:double) (experimental-double-cell-numbers) 1 2 :dn:add (DD-D) 3 dn:new !~res 4 dup-pair dn:lows n:add @~res dn:l! 5 over @~res dn:lows gt? n:abs [ dn:highs n:add ] dip n:add 6 @~res dn:h! 7 @~res ; 8 9 :dn:sub (DD-D) 10 dn:new !~res 11 dup-pair dn:lows n:sub @~res dn:l! 12 over @~res dn:lows lt? n:abs [ dn:highs n:sub ] dip n:sub 13 @~res dn:h! 14 @~res ; 15 ---------------------------------------------------------------- 0 (crc:double) (experimental-double-cell-numbers) 1 2 :dn:mul (DD-D) 3 dn:new !~res 4 dup-pair dn:lows n:mul @~res dn:l! 5 @~res dn:l@ n:negative? n:abs 6 [ dup-pair 7 [ dn:h@ ] [ dn:l@ ] bi* n:mul 8 [ [ dn:l@ ] [ dn:h@ ] bi* n:mul ] dip n:add 9 ] dip n:add 10 @~res dn:h! 11 @~res ; 12 13 14 15 ---------------------------------------------------------------- 0 (crc:double) (experimental-double-cell-numbers) 1 2 :dn:div (DD-D) 3 dn:new !~res 4 dup-pair dn:lows n:div @~res dn:l! 5 dup-pair 6 [ dn:h@ ] [ dn:l@ ] bi* n:div #1 shift-left 7 [ [ dn:l@ ] [ dn:h@ ] bi* n:mod #31 shift-right ] dip n:add 8 @~res dn:h! 9 @~res ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc: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 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:rng/test-distribution) 1 2 'Alpha d:create #26 comma #26 allot 3 4 :rnd/c #26 n:random-mod &Alpha n:add n:inc v:inc ; 5 6 #2,600,000 &rnd/c times 7 8 #0 &Alpha [ over $A n:add c:put sp n:put nl n:inc ] a:for-each 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:rng/test) 1 2 . Dependencies: (std) (termina) 3 4 :color #8 n:random-mod #30 n:add vt:set/color ; 5 :sym color #127 #33 n:sub n:random-mod #32 n:add c:put ; 6 7 clear #1,000,000 8 [ #25 n:random-mod 9 #80 n:random-mod vt:row,col sym 10 #25 #1 vt:row,col I n:put ] indexed-times 11 12 . This will fill the screen with a random selection of colorful 13 . characters. It's set to run 1 million iterations. 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc/discard) 1 2 . This implements an _ sigil that discards the value returned by 3 . a word. It's useful for things that return a status you might 4 . not actually need. 5 6 :sigil:_ interpret 'drop interpret ; 7 &sigil:_ $_ sigil:set 8 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:pi-approximations) 1 2 . Thinking a bit about pi on March 14 (pi day), here are a few 3 . approximations of pi using the (fixed-point) vocabulary. 4 5 #10,000 !f:scale 6 7 #22 #7 f:div f:put nl 8 #355 #113 f:div f:put nl 9 #103,993 #33,102 f:div f:put nl 10 #104,348 #33,215 f:div f:put nl 11 12 13 14 15 ---------------------------------------------------------------- 0 (read/data) 1 2 'DataSource var 3 4 :~gather ("-f) 5 s:get/token dup 'end s:eq? dup 6 &nip [ [ s:to-n comma ] dip ] choose ; 7 8 :data:add ("-) [ @DataSource !Free &~gather until ] gc ; 9 :data:read (-n) @DataSource fetch &DataSource v:inc ; 10 11 . This adds something similar to "READ" and "DATA" in BASIC 12 . to Konilo. Set `DataSource` to the address of your data, 13 . then use `data:add .... end` to add data. Use `data:read` 14 . to read the data back. 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (nested-:) (support-for-definitions-with-multiple-entry-points) 1 2 code: skip-nested 'popoliad i #5 d 'pupure.. i 3 :nested-: (s-) compiling? [ &skip-nested comma ] if sigil:: ; 4 &nested-: $: sigil:set 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 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/assembly-test) 1 2 label: n:test 3 'dulisw.. i 4 #45 d 5 'musu.... i 6 label: n:square 7 'dumure.. i 8 9 . The above is equal in functionality to: 10 . 11 . :n:square dup n:mul ; 12 . :n:test dup #45 swap n:mul n:sub n:square ; 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (titles:in-range) 1 2 :~current (-nn) @Blocks @BaseBlock ; 3 :~restore (nn-) !BaseBlock !Blocks ; 4 5 :~set-range (nn-nn) 6 ~current 'abcd 'cdab reorder 7 over n:sub n:inc !Blocks !BaseBlock ; 8 9 :~entry (a-) drop 10 @BaseBlock @Block n:add n:put sp block:title s:put nl ; 11 12 :titles:in-range 13 ~set-range [ I block:empty? &drop &~entry choose ] 14 block:for-each ~restore ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (bos) 1 2 . BOS is a "block operating system". It's intended to provide a 3 . number of little utilities for working with the Konilo blocks. 4 . 5 . It is intended that this will eventually replace (nonix) with 6 . something less like Unix. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (bos) 1 2 . BOS follows my personal approach to blocks. In this the first 3 . line is the block title. This will have the block name as the 4 . first element, with optional text following. For code, these a 5 . setup as "(name) (comments)", and for data, they are done as 6 . "name comments". 7 . 8 . It's best to keep names short. I find that a max of 20 seems 9 . sufficient to provide unique names to the blocks but still be 10 . easy to type in. 11 . 12 . Multiple blocks with the same name are considered a block set. 13 . This might be similar to a file in more traditional operating 14 . systems. 15 ---------------------------------------------------------------- 0 (bos) (directory-listing) 1 2 . I am using a two column display. These pad the columns and 3 . add new lines as needed. 4 5 #1 '~NL var-n 6 :~nl @~NL #2 eq? [ nl #0 !~NL ] if &~NL v:inc ; 7 :~pad #32 block:name s:length n:sub &sp times ; 8 9 :bos:display block:name s:put ~pad ~nl ; 10 11 . Block sets for programs have names starting with a ( 12 13 :bos:program? block:name #0 s:fetch $( eq? ; 14 15 ---------------------------------------------------------------- 0 (bos) (directory-listing) 1 2 . Display a program listing. This is a top-level combinator; 3 . pass in a quote to do the actual display operation. 4 5 :bos:dir (q-) 6 [ block:set:init #1 !NL 7 [ drop block:set:known? 8 [ block:set:add dup call ] -if ] 9 block:for-each drop nl ] gc ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (bos) (directory-listing) 1 2 . Display all sets. 3 4 :dir:sets 5 [ bos:display ] bos:dir ; 6 7 :dir:programs 8 [ bos:program? &bos:display if ] bos:dir ; 9 10 :dir:text 11 [ bos:program? &bos:display -if ] bos:dir ; 12 13 :dir:t 14 [ block:name '.txt s:ends-with? &bos:display if ] bos:dir ; 15 ---------------------------------------------------------------- 0 (bos) (find-blocks-for-set) 1 2 :~match? (sa-sf) drop block:name over s:eq? ; 3 :~record (f-) [ @Block comma ] if ; 4 :~finish (as-a) drop here n:dec over n:sub over store a:temp ; 5 6 :bos:blocks-for (s-a) 7 [ s:keep here swap #0 comma 8 [ ~match? ~record ] block:for-each ~finish ] gc ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:bos) 1 2 '(bos) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc/hash-blocks) (calculate-hashes) 1 2 . This creates a `Hashes` array with a hash for each page of 3 . blocks. For my block set of 65,536 blocks, this will need a 4 . bit over 4,096 cells. 5 6 'Hashes var 7 'Acc var 8 9 :hash-blocks (-) #0 set load @Blocks #16 n:div 10 [ #0 !Acc $. c:put 11 #16 [ block:buffer n:dec a:hash &Acc v:inc-by next ] times 12 @Acc @Hashes I a:store ] indexed-times ; 13 14 15 ---------------------------------------------------------------- 0 (crc/hash-blocks) (save-hash-set) 1 2 . This takes a block hash set and saves it under a specified 3 . name. 4 5 :save-hashes (s-) d:create @Blocks #16 n:div dup comma allot 6 @Dictionary d:address fetch !Hashes 7 hash-blocks ; 8 9 :select-hashes (a-) !Hashes ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc/hash-blocks) (display-hash-set) 1 2 :.hashes (-) @Hashes [ n:put sp ] a:for-each nl ; 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 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/hash-blocks 1 2 This is a set of blocks that add words to track which blocks are 3 modified. It operates on pages of 16 blocks. 4 5 'original save-hashes 6 ... edit code, etc ... 7 'modified save-hashes 8 &original &modified find-altered (-a) 9 a:dump 10 11 12 13 14 15 ---------------------------------------------------------------- 0 abe ============================================================ 1 '|| 2 .... || ... .... Arks Block Editor 3 '' .|| ||' || .|...|| ==================================== 4 .|' || || | || - 3,840 Characters per block 5 '|..'|' '|...' '|...' - Arranged as a 61x64 grid 6 7 Standard blocks in Konilo are a grid of 16x64 grid (1,024 char). 8 If using plain ASCII we can achieve a much greater density by 9 packing four characters per memory cell. For compatibility with 10 existing tools, the first 64 cells are not byte packed. 11 12 abe blocks can be identified by the (bb) type tag at the end of 13 their title line. 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (abe) (core) 1 2 :abe:to-line (n-b) 3 n:dec #64 n:mul block:buffer #64 n:add #4 n:mul n:add ; 4 5 :abe:line (n-) 6 abe:to-line #64 [ dup b:fetch c:put n:inc ] times drop nl ; 7 8 :abe:blank (n-) 9 abe:to-line #64 [ #32 over b:store n:inc ] times drop ; 10 11 :abe:insert (n"-) 12 dup abe:blank 13 abe:to-line 14 s:get/line [ over b:store n:inc ] s:for-each drop ; 15 ---------------------------------------------------------------- 0 (abe) (core) 1 2 :abe:new (-) 3 #60 [ I n:inc abe:blank ] indexed-times ; 4 5 :abe:replace-at (rc"-) 6 &abe:to-line dip n:add 7 s:get/line [ over b:store n:inc ] s:for-each drop ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (abe) (core) (evaluate-block) 1 2 '~Src var '~At var 3 4 :~grab (b-c) b:fetch dup n:zero? [ drop #32 ] if &~At v:inc ; 5 :~done? (-f) @~At #3,840 eq? ; 6 :~get (-c) ~done? [ #0 #0 &c:get store-next store #32 ] 7 [ @~Src @~At n:add ~grab ] choose ; 8 :~valid? (s-sf) dup s:length n:-zero? ; 9 :~process (s-) ~valid? &interpret &drop choose ; 10 11 :abe:run (-) 12 #1793 &c:get store &~get &c:get n:inc store 13 block:buffer #64 n:add b:to-byte-address !~Src #0 !~At 14 [ s:get/token ~process ~done? ] until ; 15 ---------------------------------------------------------------- 0 (abe) (display) 1 2 :~line# (n-) fg:red dup #10 lt? &sp if n:put sp vt:reset ; 3 4 :abe:list (-) 5 #0 ~line# #0 e:line 6 #60 [ I n:inc dup ~line# abe:line ] indexed-times ; 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (abe) (display) 1 2 'Window var 3 'Col var 4 #1 'Row var-n 5 6 :~cursor @Row n:inc @Col #4 n:add dup-pair 7 vt:row,col bg:red fg:white $* c:put vt:row,col 8 vt:reset ; 9 10 :~line I n:inc @Window n:add dup ~line# abe:line ; 11 :~title #0 ~line# fg:white bg:blue #0 e:line vt:reset ; 12 13 :abe:list/windowed (-) 14 ~title #15 &~line indexed-times ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (abe) (cursor_movement,_window_position) 1 2 :~constrain &Row #1 #15 v:limit 3 &Col #0 #63 v:limit 4 &Window #0 #45 v:limit ; 5 6 :~up &Row v:dec ~constrain ; 7 :~dn &Row v:inc ~constrain ; 8 :~lf &Col v:dec ~constrain ; 9 :~rt &Col v:inc ~constrain ; 10 :~su #15 &Window v:dec-by ~constrain ; 11 :~sd #15 &Window v:inc-by ~constrain ; 12 13 14 15 ---------------------------------------------------------------- 0 (abe) (text-entry) 1 2 :~enter ~cursor bg:blue fg:white 3 @Row @Window n:add @Col abe:replace-at 4 vt:reset clear ; 5 6 7 :~title #1 #4 vt:row,col 0 8 '(bb) n:inc block:buffer #60 n:add #4 copy ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (abe) (hints) 1 2 :abe:hints (-) 3 'Prev #1 ti:add-hint 4 'Next #2 ti:add-hint 5 'Scroll_Up #3 ti:add-hint 6 'Save #6 ti:add-hint 7 'Load #7 ti:add-hint 8 'Scroll_Down #8 ti:add-hint 9 'Quit #0 ti:add-hint 10 'arks_editor ti:set-title ; 11 12 13 14 :~help [ #2894 ti:help ] $? ti:set-action ; 15 ---------------------------------------------------------------- 0 (abe) (keymap) 1 2 :abe:actions (-) 3 &prev $1 ti:set-action &next $2 ti:set-action 4 &save $6 ti:set-action &load $7 ti:set-action 5 &ti:done $0 ti:set-action &abe:run $r ti:set-action 6 &~enter $a ti:set-action &abe:new $N ti:set-action 7 &~up $i ti:set-action &~lf $j ti:set-action 8 &~dn $k ti:set-action &~rt $l ti:set-action 9 &~up $c ti:set-action &~lf $h ti:set-action 10 &~dn $t ti:set-action &~rt $n ti:set-action 11 &~su $C ti:set-action &~sd $T ti:set-action 12 &~su $I ti:set-action &~sd $K ti:set-action 13 &~su $3 ti:set-action &~sd $8 ti:set-action 14 [ @Row abe:blank ] $B ti:set-action 15 &~title $; ti:set-action ~help ; ---------------------------------------------------------------- 0 (abe) (top-level) 1 2 :abe:display (-) clear abe:list/windowed ~cursor ; 3 4 :abe (-) 5 [ &abe:actions &abe:hints &abe:display ] ti:application ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 ==[ abe help ]==============+=================================== 1 | 2 Key Action | Tips: 3 --- ----------------------+ 4 i c cursor up | - Before editing a new block, 5 k t cursor down | hit "N" to prepare it, then 6 j h cursor left | ";" to set the title. 7 l n cursor right | 8 I C page up | 9 K T page down | 10 a enter text | 11 ; enter title | 12 B erase current line | 13 N erase block | 14 r run block as code | 15 | ---------------------------------------------------------------- 0 (LOAD:abe) 1 2 '(abe) needs 3 #513 set load 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (xentrac/wander) 1 2 . configure your screen size 3 4 :WIDTH #70 ; 5 :HEIGHT #23 ; 6 7 . a prng 8 9 #1 'Seed var-n 10 :minstd (-rand) 11 n:random n:abs ; 12 13 14 15 ---------------------------------------------------------------- 0 (xentrac/wander) 1 2 . setup the game board 3 4 :size (-n) WIDTH HEIGHT n:mul ; 5 'Board d:create size allot 6 7 :seed-board (n-) 8 [ $. minstd size n:mod &Board n:add store ] times ; 9 n:random !Seed #32 &Board size fill #512 seed-board 10 11 . words to display the game board 12 :type (sn-) [ fetch-next c:put ] times drop ; 13 :board (-) 14 &Board HEIGHT [ dup WIDTH type nl WIDTH n:add ] times ; 15 :pos (xy-addr) WIDTH n:mul n:add &Board n:add ; ---------------------------------------------------------------- 0 (xentrac/wander) 1 2 . player display 3 4 #40 'dude-x var-n 5 #12 'dude-y var-n 6 7 :set-dude (c-) @dude-x @dude-y pos store ; 8 :draw-dude $@ set-dude ; 9 :erase-dude #32 set-dude ; 10 11 draw-dude 12 13 14 15 ---------------------------------------------------------------- 0 (xentrac/wander) 1 2 . player movement 3 4 :moved-dude (DxDy-xy) 5 @dude-y n:add #0 n:max HEIGHT n:dec n:min swap 6 @dude-x n:add #0 n:max WIDTH n:dec n:min swap ; 7 8 :try-move (DxDy-) 9 moved-dude dup-pair 10 pos fetch #32 eq? 11 [ erase-dude !dude-y !dude-x draw-dude ] &drop-pair choose ; 12 13 14 15 ---------------------------------------------------------------- 0 (xentrac/wander) 1 2 . movement actions 3 4 :act (c-) 5 dup $h eq? [ [ #-1 #0 try-move ] dip ] if 6 dup $l eq? [ [ #1 #0 try-move ] dip ] if 7 dup $j eq? [ [ #0 #1 try-move ] dip ] if 8 dup $k eq? [ [ #0 #-1 try-move ] dip ] if 9 $q eq? [ drop #0 ] if #1 ; 10 11 . main game 12 13 :wander 14 #1 [ #0 #0 vt:home board '[hjklq] s:put c:get act ] while ; 15 :play page wander ; ---------------------------------------------------------------- 0 (LOAD:wander) 1 2 '(xentrac/wander) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Language Extensions & Vocabularies ============================= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (immediate) 1 2 . Konilo 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 (-) @Dictionary d:address dup fetch n:negate swap 7 store ; 8 9 . Using this is easy: write a normal word, then add `immediate` 10 . after the `;`. 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 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) (dependencies:) (immediate) 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 (does) 1 2 :does @Dictionary d:address [ fetch swap curry ] sip store ; 3 4 . This adds a word, `does`, which is similar in spirit to the 5 . `does>` in traditional Forth. An example: 6 7 . :constant (n"-) 8 . s:get/token d:create comma [ fetch process-data ] does ; 9 10 . #100 constant VALUE 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (sigil:") 1 2 {{ 3 :more '_ s:append s:get/token s:append dup s:last $" -eq? ; 4 ---reveal--- 5 :sigil:" 6 s:temp dup s:last $" eq? [ &more while ] -if s:chop 7 compiling? &s:keep if ; 8 }} 9 10 &sigil:" $" sigil:set 11 12 . This implement a " sigil for strings. The string can have 13 . embedded spaces, and both starts and ends with a " 14 . Examples: "Hello, World!" "This" "testing strings" 15 ---------------------------------------------------------------- 0 (LOAD:natural-strings) 1 2 '(sigil:") needs 3 4 5 6 7 8 9 10 11 12 13 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 1 2 3 4 5 6 7 8 9 10 11 12 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 ; 15 :s:const (ss-) &s:keep dip const ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (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 (s:dedup) 1 2 'init s:keep fll:create 's:dedup.data var-n '~1 var '~2 var 3 4 :~s:register (s-) 5 s:keep @s:dedup.data swap &fll:append/value sip ; 6 :s:unique? (s-f) 7 !~1 #0 !~2 8 @s:dedup.data [ @~1 s:eq? @~2 or !~2 ] fll:for-each @~2 ; 9 :~s:find (s-s) 10 !~1 #0 !~2 11 @s:dedup.data [ dup @~1 s:eq? [ !~2 ] &drop choose ] 12 fll:for-each @~2 ; 13 :s:dedup (s-s) 14 dup s:unique? &~s:find &~s:register choose ; 15 ---------------------------------------------------------------- 0 (LOAD:s:dedup) 1 2 '(ll) needs 3 '(s:dedup) needs 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (enum) 1 2 :enum| (n"-) 3 [ s:get/token s:temp dup '| s:eq? 4 [ drop-pair #-1 ] 5 [ d:create dup @Dictionary d:address store n:inc #0 ] 6 choose ] until ; 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (vars) (experiments-in-declaring-variables) 1 2 :vars (n"-) [ s:get/token var ] times ; 3 4 . `vars` takes a count and creates that many variables (with 5 . names parsed from the input stream) 6 7 :vars| ("-) 8 [ s:get/token s:temp dup '| s:eq? 9 [ drop #-1 ] [ var #0 ] choose ] until ; 10 11 . `vars|` parses the input stream. It creates variables for 12 . each provided token, ending when a token of | is found. 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (array|) (an-experiment-in-making-arrays) 1 2 :array| ("-a) 3 here #0 comma 4 [ s:get/token s:temp dup '| s:eq? 5 [ drop #-1 ] [ s:to-n comma #0 ] choose ] until 6 here over n:sub n:dec over store ; 7 8 . `array|` creates a new numeric array. It parses for numbers, 9 . ending when a | token is encountered. The array is stored at 10 . `here`. 11 12 . For serious use, this should probably be changed to `gc` and 13 . store the array in a temporary buffer. 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 (sigil:`) (run-a-word-immediately) 1 2 :sigil:` (s-?) 3 d:lookup d:address fetch call ; 4 5 &sigil:` $` sigil:set 6 7 . This adds a ` sigil. It can run words immediately. This can 8 . have some issues if the word in question allocates memory or 9 . alters some aspects of the system state. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (quad) 1 2 :quad (xqqqq-) 3 'abcde 'abacadae reorder 4 push push push push push push 5 call pop pop call pop pop call 6 pop pop call ; 7 8 :quad* (abcdqqqq-) 9 'abcdefgh 'aebfcgdh reorder 10 push push push push push push 11 call pop pop call pop pop call 12 pop pop call ; 13 14 :quad@ (abcdq-) 15 'abcde 'abcdeeee reorder quad* ; ---------------------------------------------------------------- 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 (dusk:rng) 1 2 'seeda var 'seedb var 'seedc var 3 4 :set-seeds (abc-) !seedc !seedb !seeda ; 5 :get-seeds (-abc) @seeda @seedb @seedc ; 6 7 :advance-seeds (-) 8 @seeda #2 shift-left @seedb and @c xor @seeda n:add !seeda 9 @seeda @seedb n:add @seedc n:add @seedb xor !seedb 10 @seedc @seedb n:sub #5 shift-right @seeda xor !seedc ; 11 12 :rng (-n) 13 advance-seeds @seeda @seedb n:sub @seedc xor #8 shift-right ; 14 15 #-12982641 #-4851317 #4285 set-seeds ---------------------------------------------------------------- 0 (dusk:dice) (words-for-dice-games) 1 2 . Variables: 3 . 4 . dice:Relative : when TRUE, use Termina to draw a dice relative 5 . to the current cursor location. When FALSE, 6 . draw it using the normal line ending 7 . 8 . dice:Sides : holds the number of sides in the dice (6 max 9 . if using `dice:draw`) 10 11 #6 'dice:Sides var-n 12 #0 'dice:Relative var-n 13 14 :dice:roll (-n) rng n:abs @dice:Sides n:mod n:inc ; 15 ---------------------------------------------------------------- 0 (dusk:dice) (words-for-dice-games) 1 2 :~put (s-) 3 s:put @dice:Relative [ #1 vt:down #7 vt:left ] &nl choose ; 4 5 :e0 '+-----+ ~put ; :s0 '|_#_#_| ~put ; :s1 '|__#__| ~put ; 6 :s2 '|_#___| ~put ; :s3 '|___#_| ~put ; :s4 '|_____| ~put ; 7 8 :d0 s4 s4 s4 ; :d1 s4 s1 s4 ; :d2 s3 s4 s2 ; :d3 s3 s1 s2 ; 9 :d4 s0 s4 s0 ; :d5 s0 s1 s0 ; :d6 s0 s0 s0 ; 10 11 'faces d:create #7 comma 12 &d0 comma &d1 comma &d2 comma 13 &d3 comma &d4 comma &d5 comma &d6 comma 14 15 :dice:draw (n-) &faces swap a:fetch e0 call e0 ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (short) (for-16-bit-numbers) 1 2 :short:MAX #32767 ; 3 :short:MIN #-32768 ; 4 5 :short:wrap (n-n) 6 dup short:MAX gt? 7 [ short:MAX n:inc n:sub short:MIN n:add ] 8 [ dup short:MIN lt? 9 [ short:MIN n:sub n:dec short:MAX n:add ] if ] choose ; 10 11 :short:add (nn-n) n:add short:wrap ; 12 :short:sub (nn-n) n:sub short:wrap ; 13 :short:mul (nn-n) n:mul short:wrap ; 14 :short:div (nn-n) n:div short:wrap ; 15 :short:mod (nn-n) n:mod short:wrap ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (%-sigil) (description) 1 2 . This adds a % sigil for numbers. Unlike #, this sigil allows 3 . specification of the base to use. 4 5 . The token should have a form like: 6 7 . [base:][digits] 8 9 . Some examples: 10 11 . %2:10110010 (binary) 12 . %16:dead (hexadecimal) 13 . %8:1765 (octal) 14 15 ---------------------------------------------------------------- 0 (%-sigil) 1 #10 'Base var-n 2 3 :~VALUES '0123456789abcdefghijklmnopqrstuvwxyz ; 4 :~base? dup $: eq? ; 5 :~neg? dup $- eq? ; 6 :~neg [ [ #-1 n:mul ] dip ] dip drop ; 7 :~change drop @Base n:div !Base #0 ; 8 :~value ~VALUES swap a:index n:add @Base n:mul ; 9 :~number ~base? &~change &~value choose ; 10 :~process (nc-n) ~neg? &~neg &~number choose ; 11 :~iter (s-n) 12 [ #1 #0 ] dip [ ~process ] s:for-each @Base n:div n:mul ; 13 :s:to-n/extended (s-n) &Base &~iter v:preserve ; 14 :sigil:% (s-n) s:to-n/extended process-data ; 15 &sigil:% $% sigil:set ---------------------------------------------------------------- 0 (LOAD:%) 1 2 '(%-sigil) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (listener) 1 2 {{ 3 'Done var 4 :bye? dup 'bye s:eq? ; 5 :exit (n-) drop #-1 !Done ; 6 ---reveal--- 7 :listener (-) 8 'Hi!_Enter_`bye`_when_done. s:put nl 9 #0 !Done [ s:get/token bye? 10 &exit &interpret choose @Done ] until ; 11 }} 12 13 . This implements a tiny nested Forth listener for Konilo. It's 14 . intended to allow some interactive use for sessions started 15 . under the kowae launcher. ---------------------------------------------------------------- 0 (opt:n) (n:bit-length,_n:digits) 1 2 :~done? (n-nf) dup #0 lteq? ; 3 4 :n:bit-length (n-n) 5 n:abs dup #0 swap 6 [ &n:inc dip #1 shift-right ~done? ] until drop swap 7 n:zero? [ drop #0 ] if ; 8 9 :n:digits (n-n) 10 n:abs dup #0 swap 11 [ &n:inc dip #10 n:div ~done? ] until drop swap drop ; 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (opt:s) (s:rjust,_s:ljust) 1 2 :s:rjust (scn-s) 3 [ n:inc here swap &fill sip 4 here swap &s:copy dip 5 here store 6 here s:temp ] gc ; 7 8 :s:ljust (scn-s) 9 [ dup comma [ dup comma ] times drop 10 dup s:length n:negate allot &comma s:for-each 11 ] gc here s:temp ; 12 13 :s:pad/left (sn-s) #32 swap s:ljust ; 14 :s:pad/right (sn-s) #32 swap s:rjust ; 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (rng) 1 2 #-8262825 '~A var-n 3 #2861367 '~B var-n 4 5 :rng:set-seeds (ab-) !~B !~A ; 6 :rng:random (-n) 7 @~A dup #18 shift-left xor !~A 8 @~B dup #13 shift-left xor !~B 9 @~A dup #14 shift-right xor n:inc !~A 10 @~B dup #19 shift-right xor n:dec !~B 11 @~A @~B n:mul #-279279 n:add ; 12 13 :~swap-to-lt dup-pair gt? &swap if ; 14 :~get-range (ab:n) n:sub n:abs n:inc ; 15 ---------------------------------------------------------------- 0 (math) (rng) 1 2 :rng:randint (lu-n) 3 ~swap-to-lt over ~get-range 4 rng:random swap n:mod n:abs n:add ; 5 6 :rng:choice (a-v) 7 dup a:length n:dec #0 swap rng:randint a:fetch ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (fixed_point) 1 2 #65536 'Scale var-n 3 #100000 '~depth var-n 4 #5 '~ram var-n 5 #2048 '~scale-a var-n 6 #32 '~scale-b var-n 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (fixed_point) 1 2 :~split-scale 3 @Scale dup @~ram shift-right dup !~scale-a 4 n:sub !~scale-b ; 5 6 :fp:set-scale (s-) 7 n:abs !Scale 8 #1 #0 !~ram !~depth 9 [ 10 @~depth #10 n:mul dup !~depth 11 &~ram v:inc @Scale gteq? 12 ] until ~split-scale ; 13 14 15 ---------------------------------------------------------------- 0 (math) (fixed_point) 1 2 :fp:rescale (fs-f) 3 n:mul @Scale n:div ; 4 :fp:add 5 n:add ; 6 :fp:sub 7 n:sub ; 8 :fp:mul 9 n:mul @Scale n:div ; 10 :fp:div 11 n:div @Scale n:mul ; 12 :fp:mod 13 dup-pair n:div @Scale n:mul push n:sub pop swap n:sub ; 14 15 ---------------------------------------------------------------- 0 (math) (fixed_point) 1 2 :~split (s-nn) 3 [ dup $. s:index/c s:left ] 4 [ dup $. s:index/c over s:length swap n:sub s:right ] bi 5 &s:to-n bi@ ; 6 7 :~scale (nn-?) 8 [ @Scale n:mul ] dip 9 n:to-s $0 @~ram s:ljust @~ram s:left s:to-n 10 @~scale-a n:mul @~depth n:div @~scale-b n:mul 11 n:add n:inc ; 12 13 :s:to-fp ~split ~scale ; 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (sin,cos,tan) 1 2 'cos var 3 'sin var 4 '~ccos var 5 '~csin var 6 'multi var 7 8 :~cleave (abc:d) n:mul n:div #2 shift-right n:mul #8 shift-right 9 :~shifty #6 shift-right @multi rot dup ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (sin,cos,tan) 1 2 :n:radians (n:f) #1144 n:mul ; 3 :f:radians (n:f) #1144 n:mul #16 shift-right ; 4 5 :~get-multi 6 [ #6 shift-right ] [ #6 shift-right ] bi n:mul 7 #4 shift-right n:negate ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (sin,cos,tan) 1 2 :sincos (f:ff) 3 #65536 #65536 !cos !~ccos 4 dup #411775 n:mod dup !sin !~csin 5 ~get-multi !multi 6 #2 #13 [ 7 dup @~ccos ~shifty n:dec ~cleave !~ccos 8 @cos @~ccos n:add !cos 9 dup @~csin ~shifty n:inc ~cleave !~csin 10 @sin @~csin n:add !sin 11 #2 n:add 12 ] times drop @sin @cos ; 13 14 15 ---------------------------------------------------------------- 0 (math) (sin,cos,tan) 1 2 :sin (f:f) 3 dup #411775 n:mod dup !sin !~csin 4 ~get-multi !multi 5 #2 #13 [ 6 dup @~csin ~shifty n:inc ~cleave !~csin 7 @sin @~csin n:add !sin 8 #2 n:add 9 ] times drop @sin ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (math) (sin,cos,tan) 1 2 :cos (f:f) 3 #65536 #65536 !cos !~ccos 4 ~get-multi !multi 5 #2 #13 [ 6 dup @~ccos ~shifty n:dec ~cleave !~ccos 7 @cos @~ccos n:add !cos 8 #2 n:add 9 ] times drop @cos ; 10 11 :tan (f:f) 12 sincos swap #8 shift-left swap n:div #8 shift-left ; 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (assert) 1 2 :~store (...n-a) 3 here [ dup comma &comma times ] dip a:reverse ; 4 :capture (p-a) 5 depth/data &call dip depth/data swap n:sub ~store ; 6 :matched? (qq-f) &capture bi@ a:eq? ; 7 8 :assert (qqs-) 9 [ s:keep &matched? dip s:put tab 10 [ 'passed ] [ 'failed ] choose s:put nl ] gc ; 11 12 . [ #2 ] [ #1 #1 n:add ] 'n:add assert 13 . [ #2 ] [ #3 #1 n:add ] 'n:add assert 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (numbers-without-#) 1 2 :~process (s-n) s:prepend s:to-n ~process-data ; 3 :sigil:1 (s-n) '1 ~process ; &sigil:1 $1 sigil:set 4 :sigil:2 (s-n) '2 ~process ; &sigil:2 $2 sigil:set 5 :sigil:3 (s-n) '3 ~process ; &sigil:3 $3 sigil:set 6 :sigil:4 (s-n) '4 ~process ; &sigil:4 $4 sigil:set 7 :sigil:5 (s-n) '5 ~process ; &sigil:5 $5 sigil:set 8 :sigil:6 (s-n) '6 ~process ; &sigil:6 $6 sigil:set 9 :sigil:7 (s-n) '7 ~process ; &sigil:7 $7 sigil:set 10 :sigil:8 (s-n) '8 ~process ; &sigil:8 $8 sigil:set 11 :sigil:9 (s-n) '9 ~process ; &sigil:9 $9 sigil:set 12 :sigil:0 (s-n) '0 ~process ; &sigil:0 $0 sigil:set 13 14 . Allows use of numbers without a # sigil. If using this, do 15 . not give words names starting with a digit. For neg, 0-value ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (value) 1 2 'Action var 3 4 :value 5 d:create here #0 comma 6 [ @Action &store &fetch choose &Action v:off ] curry 7 @Dictionary d:address store ; 8 9 :to &Action v:on ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (prior) (invoke-the-previous-definition-for-a-word) 1 2 . Thi provides a way to run an earlier definition with the 3 . same name as one you are currently writing. 4 5 . You will need to run this first: '(immediate) needs 6 7 :hide-current @Dictionary fetch !Dictionary ; 8 :handle-word s:get/token interpret ; 9 :prior &Dictionary [ hide-current handle-word ] v:preserve ; 10 immediate 11 12 . An Example: 13 . :a 'a s:put ; 14 . :b 'b s:put ; 15 . :a prior a b nl ; ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 ilo + graphics extensions 1 2 ilo/g is an ilo with support for simple monochrome graphics. 3 4 This provides a monochrome, bitmap display with support for 5 the (termina) vocabulary. The extensions here provide a word 6 for drawing pixels, and later other shapes. 7 8 To load: 9 10 * crc:drawing 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:drawing) (interface-to-framebuffer) 1 2 :pixel (xyc-) #33 io ; 3 :get-pixel (xy-c) #34 io ; 4 5 :mouse (-xyb) #35 io ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:drawing) (simple-lines) 1 2 #1 'Color var-n 3 :set-color (n-) !Color ; 4 5 :hline (xyw-) 6 [ dup-pair @Color pixel &n:inc dip ] times drop-pair ; 7 8 :vline (xyh-) 9 [ dup-pair @Color pixel n:inc ] times drop-pair ; 10 11 :dline\ (xyl-) 12 [ dup-pair @Color pixel &n:inc bi@ ] times drop-pair ; 13 14 :dline/ (xyl-) 15 [ dup-pair @Color pixel &n:dec &n:inc bi* ] times drop-pair ; ---------------------------------------------------------------- 0 (crc:drawing) (rect) 1 2 'X var 'Y var 'H var 'W var 3 4 :rect (xyhw-) !W !H !Y !X 5 @X @Y @W hline @X @Y @H n:add @W hline 6 @X @Y @H vline @X @W n:add @Y @H vline 7 ; 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:drawing) (circles) 1 2 'XC var 'YC var 'X var 'Y var 3 4 :octant (xc,yc,x,y) 5 !Y !X !YC !XC 6 @XC @X n:add @YC @Y n:add @Color pixel 7 @XC @X n:sub @YC @Y n:add @Color pixel 8 @XC @X n:add @YC @Y n:sub @Color pixel 9 @XC @X n:sub @YC @Y n:sub @Color pixel 10 @XC @Y n:add @YC @X n:add @Color pixel 11 @XC @Y n:sub @YC @X n:add @Color pixel 12 @XC @Y n:add @YC @X n:sub @Color pixel 13 @XC @Y n:sub @YC @X n:sub @Color pixel ; 14 15 ---------------------------------------------------------------- 0 (crc:drawing) (circles) 1 2 'XC var 'YC var 'X var 'Y var 'D var 'R var 3 4 :circle (xyr-) 5 !R !YC !XC #0 !X @R [ !Y ] [ !D ] bi 6 @XC @YC @X @Y octant 7 [ &X v:inc 8 @D n:strictly-positive? 9 [ &Y v:dec @X @Y n:sub @R n:mul #2 n:mul @D n:add !D ] 10 [ #2 @R n:mul @X n:mul @D n:add !D ] choose 11 @XC @YC @X @Y octant 12 @Y @X gteq? ] while ; 13 14 15 ---------------------------------------------------------------- 0 (crc:drawing) (line) 1 2 'X var 'Y var 'DX var 'DY var 'SX var 'SY var 'ROT var 3 'T var 'S var 'A var 'E var 'B var 4 'X1 var 'Y1 var 'X2 var 'Y2 var 5 6 :~setup (xy,xy-) 7 !Y2 !X2 !Y1 !X1 @X1 !X @Y1 !Y 8 @X2 @X1 n:sub n:abs !DX @Y2 @Y1 n:sub n:abs !DY 9 @X2 @X1 n:sub n:sign !SX 10 @Y2 @Y1 n:sub n:sign !SY 11 @DY @DX gt? n:abs !ROT 12 @ROT [ @DX !T @DY !S ] [ @DY !T @DX !S ] choose 13 @T #1 shift-left !A @A @S n:sub !E 14 @T @S n:sub #1 shift-left !B ; 15 ---------------------------------------------------------------- 0 (crc:drawing) (line) 1 2 :line (x1,y1,x2,y2-) 3 ~setup @X @Y @Color pixel 4 @S [ 5 @E n:positive? [ @B ] [ @A ] choose @E n:add !E 6 @E n:positive? @ROT or [ @SY ] [ #0 ] choose @Y n:add !Y 7 @E n:positive? @ROT not or [ @SX ] [ #0 ] choose @X n:add !X 8 @X @Y @Color pixel 9 ] times ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:drawing) (triangle) 1 2 :triangle (x1,y1,x2,y2,x3,y3-) 3 'abcdef 'abcdefabcd reorder line 4 'abcdef 'abcdefefcd reorder line 5 'abcdef 'abef reorder line ; 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (crc:turtle) 1 2 'X var 'Y var 'C var 'D var 'R var 3 4 :t:raise #0 !C ; 5 :t:lower #1 !C ; 6 7 :t:left [ &X v:dec ] !D ; 8 :t:right [ &X v:inc ] !D ; 9 :t:up [ &Y v:dec ] !D ; 10 :t:down [ &Y v:inc ] !D ; 11 :t:at (xy-) !Y !X ; 12 :t:forward (n-) [ @X @Y @C pixel @D call ] times ; 13 14 #320 #240 t:at t:lower t:right 15 ---------------------------------------------------------------- 0 (crc:turtle) 1 2 :t:down-right [ &Y v:inc &X v:inc ] !D ; 3 :t:down-left [ &Y v:inc &X v:dec ] !D ; 4 :t:up-left [ &Y v:dec &X v:dec ] !D ; 5 :t:up-right [ &Y v:dec &X v:inc ] !D ; 6 7 'Rotations d:create #8 comma 8 &t:right comma &t:down-right comma &t:down comma 9 &t:down-left comma &t:left comma &t:up-left comma 10 &t:up comma &t:up-right comma 11 12 :t:rotate 13 &R v:inc @R #8 eq? [ #0 !R ] if &Rotations @R a:fetch call ; 14 15 ---------------------------------------------------------------- 0 (LOAD:crc:turtle) 1 2 '(crc:turtle) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ilo/x) 1 2 #20 [ #0 #0 #300 #300 I #10 n:mul n:sub line ] indexed-times 3 #20 [ #639 #0 #300 #300 I #10 n:mul n:sub line ] indexed-times 4 5 #300 #240 #100 circle 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ilo/x) 1 2 #300 'X var-n #200 'Y var-n #50 'R var-n 3 :test 4 [ c:get #0 set-color 5 @X @Y @R circle 6 dup $c eq? [ &X v:dec ] if 7 dup $t eq? [ &X v:inc ] if 8 dup $h eq? [ &Y v:dec ] if 9 dup $n eq? [ &Y v:inc ] if 10 dup $. eq? [ restart ] if 11 dup $p eq? [ &R v:inc ] if 12 dup $y eq? [ &R v:dec ] if 13 drop #1 set-color @X @Y @R circle ] forever 14 ; 15 ---------------------------------------------------------------- 0 (LOAD:crc:drawing) 1 2 '(crc:drawing) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 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) (i/o_extensions) 1 2 . These blocks add words for interacting with the i/o on the 3 . Teensy 4.1. The Teensy interface is routed through an ilo 4 . device # 100. 5 6 :teensy:io (...n-) #100 io ; 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) (i/o_pins) 1 2 . 00 - 09: i/o pins 3 4 :pin:mode (nm-) #0 teensy:io ; 5 :pin:high (n-) #1 teensy:io ; 6 :pin:low (n-) #2 teensy:io ; 7 :pin:read (n-m) #3 teensy:io ; 8 :pin:write (np-) #4 teensy:io ; 9 :pin:set-resolution (np-) #5 teensy:io ; 10 :pin:tone (np-) #6 teensy:io ; 11 :pin:notone (p-) #7 teensy:io ; 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) (timer) 1 2 . 10 - 19: timer 3 4 :delay/ms (n-) #10 teensy:io ; 5 :delay/us (n-) #11 teensy:io ; 6 :delay/ns (n-) #12 teensy:io ; 7 :timer:millis (-n) #13 teensy:io ; 8 :timer:micros (-n) #14 teensy:io ; 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) (RTC) 1 2 . 20 - 29: RTC 3 . 4 . The Teensy has a real time clock. The words here allow you to 5 . make use of this. 6 7 :rtc:hour (-n) #20 teensy:io ; 8 :rtc:minute (-n) #21 teensy:io ; 9 :rtc:second (-n) #22 teensy:io ; 10 :rtc:day (-n) #23 teensy:io ; 11 :rtc:month (-n) #24 teensy:io ; 12 :rtc:year (-n) #25 teensy:io ; 13 :rtc:set (hmsdmy-) #26 teensy:io ; 14 :rtc:adjust (n-) #27 teensy:io ; 15 ---------------------------------------------------------------- 0 (teensy4.1) (reserved) 1 2 . 30 - 39: 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) (reserved) 1 2 . 40 - 49: 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) (reserved) 1 2 . 50 - 59: 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (teensy4.1) (reserved) 1 2 . 60 - 69: 3 4 5 6 7 8 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) (blink_test) 1 2 &pin:high \pin:on 3 &pin:low \pin:off 4 5 :LED #13 ; 6 7 :teensy:blink (n-) 8 [ LED pin:on #500 delay/ms 9 LED pin:off #500 delay/ms ] times ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:teensy4.1) 1 2 '(teensy4.1) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ilo:x86) (port_io,_physical_memory) 1 2 :pio:inb (n-c) #0 #100 io ; 3 :pio:inw (n-n) #1 #100 io ; 4 :pio:outb (vn-) #2 #100 io ; 5 :pio:outw (vn-) #3 #100 io ; 6 7 :mem:fetch-byte (a-c) #0 #101 io ; 8 :mem:store-byte (ca-) #1 #101 io ; 9 :mem:fetch (a-n) #2 #101 io ; 10 :mem:store (na-) #3 #101 io ; 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (ilo:x86) (cmos,_rtc) 1 2 :CMOS:ADDRESS #112 ; 3 :CMOS:DATA #113 ; 4 5 :rtc:query CMOS:ADDRESS pio:outb CMOS:DATA pio:inb ; 6 :rtc:second #0 rtc:query ; 7 :rtc:minute #2 rtc:query ; 8 :rtc:hour #4 rtc:query ; 9 :rtc:day #7 rtc:query ; 10 :rtc:month #8 rtc:query ; 11 :rtc:year #9 rtc:query ; 12 13 :.time rtc:hour n:put $: c:put rtc:minute n:put nl ; 14 15 ---------------------------------------------------------------- 0 (ilo:x86) (serial) 1 2 :serial:COM1 #1016 ; :serial:COM2 #760 ; 3 :serial:COM3 #1000 ; :serial:COM4 #744 ; 4 serial:COM1 'serial:Port var-n 5 6 :serial:recv? @serial:Port #5 n:add pio:inb #1 and n:-zero? ; 7 :serial:empty? @serial:Port #5 n:add pio:inb #32 and n:-zero? ; 8 :serial:read (-c) 9 [ serial:recv? [ @serial:Port pio:inb #-1 ] [ #0 ] choose 10 until ; 11 :serial:write (c-) 12 [ serial:empty? [ @serial:Port pio:outb #-1 ] [ #0 ] choose ] 13 until ; 14 :serial:send (s-) [ serial:write ] s:for-each ; 15 ---------------------------------------------------------------- 0 (ilo:x86) (serial) 1 2 :serial:init 3 #0 @serial:Port #1 n:add pio:outb 4 #128 @serial:Port #3 n:add pio:outb 5 #3 @serial:Port pio:outb 6 #0 @serial:Port #1 n:add pio:outb 7 #3 @serial:Port #3 n:add pio:outb 8 #199 @serial:Port #2 n:add pio:outb 9 #11 @serial:Port #4 n:add pio:outb ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 (LOAD:x86) 1 2 '(ilo:x86) needs 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Glossary: ) 1 2 Data Stack: - 3 Address Stack: - 4 5 Ending for comments or visual grouping. Provided as an aid 6 for readability purposes. 7 8 Example: 9 10 (Remove_whitespace: [ #32 eq? ] s:filter ) 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: * 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse ahead for a load block name. Convert this into a form 6 of "(LOAD:name)", then pass this to +needs to locate and run. 7 8 It will construct a quotation from the contents of the load 9 block, then run this. See *AsteriskLoader in the manual for 10 more detail on this. 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ---reveal--- 1 2 Data Stack: - 3 Address Stack: - 4 5 Within lexical scoped area, switch to global scope area. 6 See *LexicalScope in the manual for more details on this. 7 It is used with +{{ and +}} 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: -eq? 1 2 Data Stack: nn-f 3 Address Stack: - 4 5 Compare two numeric values for inequality. Returns true if 6 the values are not equal, or false if they are equal. 7 8 Example: 9 10 #100 #200 -eq? [ 'Not_equal! s:put ] if 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: -if 1 2 Data Stack: fq- 3 Address Stack: - 4 5 Execute the provided *quotation if the passed flag is false. 6 If the flag is true, it just discards the pointer. 7 8 Example: 9 10 #100 #200 eq? [ 'Values_do_not_match s:put ] -if 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: . 1 2 Data Stack: "- 3 Address Stack: - 4 5 Used in a block, this will read and discard the next 62 6 characters. It's used to add full line comments. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: .s 1 2 Data Stack: - 3 Address Stack: - 4 5 Display the values on the data stack. This only shows the 6 values as numbers. The values are displayed from left to 7 right, with the rightmost value being the top of the stack. 8 9 Example: 10 11 #12 #33 #-15 .s 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: 0 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 0 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 1 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 1 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 10 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 10 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 11 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 11 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 12 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 12 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 13 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 13 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 14 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 14 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 15 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 15 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 2 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 2 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 3 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 3 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 4 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 4 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 5 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 5 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 6 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 6 in the current block with the 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 7 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 7 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 8 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 8 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: 9 1 2 Data Stack: "- 3 Address Stack: - 4 5 A part of the *BasicEditor, this parses until the end of the 6 line, then replaces line 9 in the current block with the 7 parsed text. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: ; 1 2 Data Stack: - 3 Address Stack: - 4 5 Ends compilation of a colon definition started with +sigil:: 6 This will lay down the termination value and set +Compiler 7 to false. 8 9 ; is one of the three immediate words in Konilo. 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: ?jump 1 2 Data Stack: fq- 3 Address Stack: - 4 5 Primarily intended for internal use, this will conditionally 6 branch to the provided address if the flag is true. If false, 7 it just discards the pointer. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: BaseBlock 1 2 Data Stack: - 3 Address Stack: - 4 5 This is a variable that stores a block number (typically zero) 6 which is added to the block numbers used by +block:load and 7 +block:save 8 9 When used with +Blocks it can partition a large set of blocks 10 into smaller sets. 11 12 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: Block 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable tracks the current block for the *BasicEditor. 6 It's generally set by +edit or +set 7 8 9 10 11 12 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: Blocks 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds the total number of blocks available in 6 your system. 7 8 You can use this with +BaseBlock to restrict access to a 9 subset of the complete block store. 10 11 12 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: Compiler 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds the current compiler state. It's set to 6 true when the compiler is active, and false otherwise. In most 7 cases this doesn't need to be manually altered; +sigil:: +; 8 +[ and +] update it as needed. 9 10 If writing extensions that need to lay down data or custom 11 code, you may need to check this to choosthe correct path for 12 your words. 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: Dictionary 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a pointer to the most recent dictionary 6 header. 7 8 9 10 11 12 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: FALSE 1 2 Data Stack: -f 3 Address Stack: - 4 5 Return a false flag. This will always return 0. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: Free 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a pointer to the next free memory address. 6 7 It is altered by a variety of words, including +comma +allot 8 and +gc . You can read the contents by running +here . 9 10 11 12 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: I 1 2 Data Stack: -n 3 Address Stack: - 4 5 For a loop created with +indexed-times, this will return the 6 current loop index. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: J 1 2 Data Stack: -n 3 Address Stack: - 4 5 For a nested loop created with +indexed-times, this will return 6 the loop index of the parent loop. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: K 1 2 Data Stack: -n 3 Address Stack: - 4 5 For a nested loop created with +indexed-times, this will return 6 the loop index of the grandparent loop. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: Sigils 1 2 Data Stack: - 3 Address Stack: - 4 5 This is a table in memory that stores pointers to each of the 6 defined sigil handlers. In most cases you should use the sigil: 7 vocabulary to access these. 8 9 10 11 12 13 14 Type: data 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: TRUE 1 2 Data Stack: -f 3 Address Stack: - 4 5 Return a true flag. While all non-zero values can be viewed as 6 true, the flag returned by this will always be -1. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: [ 1 2 Data Stack: - 3 Address Stack: - 4 5 Begin a *quotation. Sets +Compiler to true. 6 7 [ is one of the three immediate words in Konilo. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: ] 1 2 Data Stack: -q 3 Address Stack: - 4 5 End a *quotation. Sets +Compiler to false. 6 7 ] is one of the three immediate words in Konilo. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:-eq? 1 2 Data Stack: ab-f 3 Address Stack: - 4 5 Compare two arrays for inequality. If the differ, this will 6 return a true flag. If they are identical, it returns false. 7 8 Note that this compares them strictly by value. If the values 9 are pointers (e.g., to strings), it only compares the pointers 10 and not the values pointed to. 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:append 1 2 Data Stack: ab-a 3 Address Stack: - 4 5 Create a new array from the contents of array a followed by 6 the contents of array b. This is similar to +a:prepend 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:behead 1 2 Data Stack: a-a 3 Address Stack: - 4 5 Remove the first item from an array, returning a new array. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:chop 1 2 Data Stack: a-a 3 Address Stack: - 4 5 Remove the last item from an array, returning a new array. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:contains? 1 2 Data Stack: an-f 3 Address Stack: - 4 5 Check to see if an array contains a provided value. If found, 6 returns true. False is returned if the value is not found. 7 8 The comparisons are strictly numeric; for pointers, only the 9 actual addresses are compared. 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:copy 1 2 Data Stack: ap- 3 Address Stack: - 4 5 Copy the array to memory at the provided pointer. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:dup 1 2 Data Stack: a-a 3 Address Stack: - 4 5 Make a copy of an array. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:eq? 1 2 Data Stack: ab-f 3 Address Stack: - 4 5 Compare two arrays for equality. Returns a true flag if they 6 are identical, or false if they are not. 7 8 Note that this compares them strictly by value. If the values 9 are pointers (e.g., to strings), it only compares the pointers 10 and not the values pointed to. 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:fetch 1 2 Data Stack: an-v 3 Address Stack: - 4 5 Fetch a value from an array. Provide a pointer to the array and 6 the index into the array. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:filter 1 2 Data Stack: aq-a 3 Address Stack: - 4 5 Runs the provided quotation against each value in the array. 6 The quotation consumes the value and returns a flag. If true, 7 the value is copied into a new array. If false, the value is 8 is discarded. 9 10 Example: 11 12 'Hello_World! [ c:vowel? ] s:filter 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:first 1 2 Data Stack: a-n 3 Address Stack: - 4 5 Return the first value in the array. 6 7 Example: 8 9 'Hello a:first (returns_$H) 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:for-each 1 2 Data Stack: aq- 3 Address Stack: - 4 5 Runs the provided quotation against each value in the array. 6 The quotation will receive each value and can then consume or 7 transform it as desired. 8 9 Example: 10 11 'Hello_Dusk [ c:put ] a:for-each 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:hash 1 2 Data Stack: a-n 3 Address Stack: - 4 5 Return a hash for the values in the array. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:index 1 2 Data Stack: an-n 3 Address Stack: - 4 5 Return the index of the first occurrence of value n in the 6 array. This will return invalid data if the value is not in 7 the array. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:indices 1 2 Data Stack: an-a 3 Address Stack: - 4 5 Create a new array with the index of each occurrence of a 6 value in the array. The value in this array will be invalid 7 if the value is not contained in the array. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:last 1 2 Data Stack: a-n 3 Address Stack: - 4 5 Return the last value in the provided array. 6 7 Example: 8 9 'Hello a:last (returns_$o) 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:left 1 2 Data Stack: an-a 3 Address Stack: - 4 5 Given an array and a length, create a new array with the 6 specified number of values. The values are taken from the 7 left (or starting) side of the array. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:length 1 2 Data Stack: a-n 3 Address Stack: - 4 5 Return the number of values in the array. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:make 1 2 Data Stack: ...n-a 3 Address Stack: - 4 5 Using values from the stack, create a new array with n values. 6 The array will be created at +here 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:make/temp 1 2 Data Stack: ...n-a 3 Address Stack: - 4 5 Using values from the stack, create a new array with n values. 6 The array will be created in the temporary array area. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:map 1 2 Data Stack: aq-a 3 Address Stack: - 4 5 Execute the quote once for each value in the array. The value 6 is pushed to the stack before the quotation is called. The 7 quote must return a new value. The new values will be stored 8 in a new array. 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:middle 1 2 Data Stack: afn-a 3 Address Stack: - 4 5 Given an array, a starting index (f) and a length (n), return 6 a new array with the values taken from the indicated subset. 7 8 Example: 9 10 '0123456789 #2 #3 a:middle (returns_'234) 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:new 1 2 Data Stack: ns- 3 Address Stack: - 4 5 Create a new named array (name is s) with a provided size (n). 6 The array will not have values set, but should be manually 7 initialized before use. 8 9 Example: 10 11 #100 'HundredItems a:new 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: a:prepend 1 2 Data Stack: ab-a 3 Address Stack: - 4 5 Given two arrays, construct a new array with the contents of 6 array b followed by the contents of array a. This is similar 7 to +a:append 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:reduce 1 2 Data Stack: anq-n 3 Address Stack: - 4 5 Takes an array, a starting value, and a quote. This will run 6 the quote against each item in the array; the quote should 7 consume two values and return one 8 9 Example: 10 11 #1 #2 #3 #4 #4 a:make/temp 12 #0 [ n:add ] a:reduce (sum_the_values_in_the_array) 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:reverse 1 2 Data Stack: a-a 3 Address Stack: - 4 5 Given an array, return a new array with the values in the 6 opposite order. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:right 1 2 Data Stack: an-a 3 Address Stack: - 4 5 Given an array and a length, create a new array with the 6 specified number of values. The values are taken from the 7 right (or ending) side of the array. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:store 1 2 Data Stack: van- 3 Address Stack: - 4 5 Store value v into array at the specified index. 6 7 Example: 8 9 $e 'Hillo #1 a:store 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:temp 1 2 Data Stack: a-a 3 Address Stack: - 4 5 Make a copy of the provided array in the temporary array 6 space. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: a:th 1 2 Data Stack: an-p 3 Address Stack: - 4 5 Given an array and an index, return a pointer to the memory 6 location the pair point to. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: allot 1 2 Data Stack: n- 3 Address Stack: - 4 5 Allocate n cells of memory, starting at +here . You can also 6 pass a negative value to free memory, again starting at +here 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: and 1 2 Data Stack: nn-n 3 Address Stack: - 4 5 Perform a bitwise AND between two values. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: assemble:opcode 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Given a string containing an ilo instruction bundle, decode 6 the instructions and construct the value for a cell containing 7 them. 8 9 This is normally use internally, as part of the runtime pali 10 assembler. 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: b:fetch 1 2 Data Stack: a-b 3 Address Stack: - 4 5 Given a byte address a, fetch the byte value stored. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: b:pack 1 2 Data Stack: bbbb-n 3 Address Stack: - 4 5 Given four byte values, pack them into a single cell. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: b:store 1 2 Data Stack: ba- 3 Address Stack: - 4 5 Store byte b into memory at byte address a. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: b:to-byte-address 1 2 Data Stack: a-a 3 Address Stack: - 4 5 Given a byte address, return the actual memory address that 6 contains it. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: b:unpack 1 2 Data Stack: n-bbbb 3 Address Stack: - 4 5 Given a value, break into into four byte values. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:black 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to black. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:blue 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to blue. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:cyan 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to cyan. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:green 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to green. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:magenta 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to 6 magenta. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:red 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to red. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:white 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to white. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bg:yellow 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the background color to yellow. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bi 1 2 Data Stack: nqq-? 3 Address Stack: - 4 5 Remove the second quote from the stack and run the first. 6 Place a copy of the value (n) on the stack and run the second 7 quote. 8 9 Example: 10 11 #10 [ n:inc ] [ n:dec ] bi (returns_#11_#9) 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: bi* 1 2 Data Stack: nmqq-? 3 Address Stack: - 4 5 Move m and the second quote off the stack. Run the first quote. 6 Then place m back on the stack and run the second quote. 7 8 Example: 9 10 #10 #20 [ n:inc ] [ n:dec ] bi* 11 (returns_#11_#19) 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: bi@ 1 2 Data Stack: nmq- 3 Address Stack: - 4 5 Remove m from the stack and run quotation. Place m back on the 6 stack and run the quotation again. 7 8 Example: 9 10 #10 #20 [ n:inc ] bi@ 11 (returns_#11_#21) 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: bit:clear 1 2 Data Stack: ni-n 3 Address Stack: - 4 5 Clear bit i in number n. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bit:get 1 2 Data Stack: ni-n 3 Address Stack: - 4 5 Return the value of bit i in number n. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bit:set 1 2 Data Stack: ni-n 3 Address Stack: - 4 5 Set bit i in number n to 1. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:Sets 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable points to an array of blocks in a set. It's 6 used internally by some of the block: words in the (std) 7 library. 8 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:buffer 1 2 Data Stack: -a 3 Address Stack: - 4 5 Return the address of the first cell in the system block 6 buffer. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: block:empty? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Load the specified block. If the block is empty (all values are 6 spaces), return a true flag. If not, returns false. 7 8 Example: 9 10 #10 [ I n:put tab I block:empty? n:put nl ] indexed-times 11 (Check_blocks_0-9_to_see_if_used_or_empty) 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:first-matching 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Scan the blocks. Compare the first part of each title line to 6 the provided string. Return the block number of the first 7 match. If no match is found, returns the value of +Blocks 8 9 Example. 10 11 '(tuhi) blocks:first-matching n:put nl 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:for-each 1 2 Data Stack: q- 3 Address Stack: - 4 5 Run quote once for each block in the system. The block will be 6 loaded into the +block:buffer before running the quotation, and 7 a pointer to the start of the block data will be pushed on the 8 stack prior to running the quote. 9 10 Example: 11 12 :titles [ (p-) drop block:title s:put nl ] block:for-each ; 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:load 1 2 Data Stack: np- 3 Address Stack: - 4 5 Load block n into memory at the provided address. 6 7 Example: 8 9 #1 block:buffer block:load 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: block:name 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return the name (first token in the title line) of the currently 6 loaded block. 7 8 Example: 9 10 #5 set load block:name s:put nl 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:save 1 2 Data Stack: np- 3 Address Stack: - 4 5 Write the contents of memory at the provided address to block n. 6 7 Example: 8 9 #3 block:buffer block:save 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: block:set:add 1 2 Data Stack: - 3 Address Stack: - 4 5 Add the name (first token in the title) of the currently loaded 6 block to the current block set. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:set:init 1 2 Data Stack: - 3 Address Stack: - 4 5 Initialize space for a new block set. Also sets +block:Set to 6 point to it. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:set:known? 1 2 Data Stack: -f 3 Address Stack: - 4 5 Return true if the current block name (first token in title) is 6 already in the current block set. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: block:title 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a pointer to a string containing the title line of the 6 currently loaded block.s 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:add 1 2 Data Stack: n- 3 Address Stack: - 4 5 Add a value to the current buffer. 6 7 Example: 8 9 $H buffer:add 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:empty 1 2 Data Stack: - 3 Address Stack: - 4 5 Reset the current buffer to an empty state. 6 7 Example: 8 9 buffer:empty 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:end 1 2 Data Stack: -a 3 Address Stack: - 4 5 Return the last address in the current buffer. This will be one 6 cell after the last stored value. 7 8 Example: 9 10 buffer:end n:put 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:get 1 2 Data Stack: -n 3 Address Stack: - 4 5 Remove the last value from the buffer, leaving it on the stack. 6 7 Example: 8 9 buffer:get n:put 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:set 1 2 Data Stack: a- 3 Address Stack: - 4 5 Set the provided address as the start of the buffer to use. 6 This will perform a +buffer:empty on the provided address. 7 8 Example: 9 10 'Foo d:create #100 allot 11 &Foo buffer:set 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:size 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the number of values in the current buffer. 6 7 Example: 8 9 buffer:size n:put 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: buffer:start 1 2 Data Stack: -a 3 Address Stack: - 4 5 Return the address of the start of the buffer. 6 7 Example: 8 9 buffer:start n:put 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: bye 1 2 Data Stack: - 3 Address Stack: - 4 5 Shut down Konilo. The exact action will be dependent on your 6 ilo system. On most, this will exit and return control to the 7 host. 8 9 Example: 10 11 bye 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:-consonant? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is not a 6 consonant, or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-digit? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII characters, return true if the character is not a 6 numeric digit, or false otherwise. 7 8 +s:DIGITS is used to track what is considered a digit. The set 9 defaults to 09 and A-F, covering ranges through hexadecimal. 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-letter? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is not a letter, 6 or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-lowercase? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is not lowercase 6 or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-uppercase? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is not uppercase 6 or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-visible? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII characters, return true if the character lacks a 6 visual representation or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-vowel? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is not a vowel 6 or false if it is. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:-whitespace? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII characters, return true if the character is not white 6 space or false if it is. 7 8 The whitespace characters are tracked in +s:WHITESPACE and 9 include horizontal tab, carriage return, line feed, and space 10 by default. 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:consonant? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is a consonant, 6 or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:digit? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII characters, return true if the character is a numeric 6 digit, or false otherwise. 7 8 +s:DIGITS is used to track what is considered a digit. The set 9 defaults to 09 and A-F, covering ranges through hexadecimal. 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:get 1 2 Data Stack: "-c 3 Address Stack: - 4 5 Read a character from the keyboard. 6 7 This word is setup as a hook to allow it to be replaced and 8 restored. This is used by +s:evaluate to redirect input to use 9 the provided string rather than the keyboard. 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:letter? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is a letter, or 6 false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:lowercase? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is lowercase, or 6 false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:put 1 2 Data Stack: c- 3 Address Stack: - 4 5 Display a charater. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:to-lower 1 2 Data Stack: c-c 3 Address Stack: - 4 5 For ASCII letters, return the lowercase form of the character. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:to-s 1 2 Data Stack: c-s 3 Address Stack: - 4 5 Given a character, create a temporary string with that character 6 as the only value. 7 8 Example: 9 10 'Hello $! c:to-s s:append 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:to-upper 1 2 Data Stack: c-c 3 Address Stack: - 4 5 For ASCII characters, convert the letter to its uppercase form. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:toggle-case 1 2 Data Stack: c-c 3 Address Stack: - 4 5 For ASCII letters, switch the case of a character. Lowercase 6 becomes uppercase, and vice versa. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:uppercase? 1 2 Data Stack: c-c 3 Address Stack: - 4 5 For ASCII letters, return true if the character is uppercase 6 or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: c:visible? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII characters, return true if the character has a visual 6 representation or false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:vowel? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII letters, return true if the character is a vowel or 6 false if not. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: c:whitespace? 1 2 Data Stack: c-f 3 Address Stack: - 4 5 For ASCII characters, return true if the character is white 6 space or false if it is not. 7 8 The whitespace characters are tracked in +s:WHITESPACE and 9 include horizontal tab, carriage return, line feed, and space 10 by default. 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: call 1 2 Data Stack: p- 3 Address Stack: - 4 5 Call a word or quotation. Provide a pointer to the starting 6 address. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: cat 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse for a block number. Load this block, then display it with 6 +list* 7 8 This is part of (nonix) 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: catalog 1 2 Data Stack: - 3 Address Stack: - 4 5 Start the catalogue browser. This is an alias for +catalogue 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: catalogue 1 2 Data Stack: - 3 Address Stack: - 4 5 Start the catalogue browser. This is a tool using the (termina) 6 scaffold to provide a visual interface for navigating your 7 blocks. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: choose 1 2 Data Stack: fpp- 3 Address Stack: - 4 5 +choose takes a flag and two pointers. The first pointer will be 6 called if the flag is true, the second will be called if the 7 flag is false. 8 9 Example: 10 11 n:even? [ 'Yes,_its_even ] [ 'No,_its_odd ] choose s:put 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: clear 1 2 Data Stack: - 3 Address Stack: - 4 5 Clear the display. This assumes a character addressed display 6 with DEC escape sequence support. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: code: 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse for a name, and use +d:create to add it to the dictionary. 6 This is intended for use with the runtime assembler, for writing 7 words in assembly. 8 9 Example: 10 11 code: x10 'limure.. i #10 d 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: comma 1 2 Data Stack: n- 3 Address Stack: - 4 5 Store a value into memory at +here and increment +Free 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: compare 1 2 Data Stack: pon-f 3 Address Stack: - 4 5 Compare n cells of memory, starting at address p to the 6 corresponding cells starting at address o. Return true if 7 all values match, or false if there are any variations. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: compile:call 1 2 Data Stack: p- 3 Address Stack: - 4 5 Mainly intended for internal use, this compiles ilo instructions 6 for a lica.... bundle. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: compile:jump 1 2 Data Stack: p- 3 Address Stack: - 4 5 Mainly intended for internal use, this compiles ilo instructions 6 for a liju.... bundle. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: compile:lit 1 2 Data Stack: n- 3 Address Stack: - 4 5 Mainly intended for internal use, this compiles ilo instructions 6 for a li...... bundle. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: compiling? 1 2 Data Stack: -f 3 Address Stack: - 4 5 Return true if the +Compiler is on, or false if it is not. It 6 is intended as a readability aid for code that needs awareness 7 of the compiler state. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: copy 1 2 Data Stack: pon- 3 Address Stack: - 4 5 Copy n cells of memory starting at address p to memory starting 6 at address o. Copies of overlapping memory areas are not 7 supported. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: cp 1 2 Data Stack: ""- 3 Address Stack: - 4 5 Parse for two block numbers. Copy the contents of the first 6 block into the second block. 7 8 This is part of (nonix) 9 10 Example: 11 12 cp 100 110 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: curry 1 2 Data Stack: nq-q 3 Address Stack: - 4 5 Create a new quotation. The quotation will be defined as if 6 it were of a form: [ n q ] 7 8 Example: 9 10 'Hello &s:put curry \say-hello 11 say-hello 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: d 1 2 Data Stack: n- 3 Address Stack: - 4 5 Part of the runtime assembler, this inlines a value to +here 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: d:address 1 2 Data Stack: d-p 3 Address Stack: - 4 5 Given a dictionary header, return the address of the field which 6 contains a pointer to the actual start of the word. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: d:create 1 2 Data Stack: s- 3 Address Stack: - 4 5 Create a new dictionary header. The provided string is hashed 6 and used for the word name; the +d:address field will be set to 7 the address immediately after the header. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: d:exists? 1 2 Data Stack: s-f 3 Address Stack: - 4 5 Given a string with a word name, search the dictionary for a 6 matching header. If located, return true. If not, return false. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: d:hash 1 2 Data Stack: d-p 3 Address Stack: - 4 5 Given a dictionary header, return the address where the hash of 6 the name is stored. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: d:link 1 2 Data Stack: d-a 3 Address Stack: - 4 5 Given a dictionary header, return the address where the link to 6 the previous entry is stored. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: d:lookup 1 2 Data Stack: s-d 3 Address Stack: - 4 5 Given a string with a word name, search the dictionary for it. 6 When found, return a pointer to the dictionary header. If not 7 found, this will return 0. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: depth/address 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the number of items on the address stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: depth/data 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the number of items on the data stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: depths 1 2 Data Stack: -nm 3 Address Stack: - 4 5 Return the number of items on the data stack (n) and address 6 stack (m). 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: describe 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse for a word name. Look for a matching glossary block and 6 display any that match. This will work for partials. 7 8 Examples: 9 10 describe nl 11 describe c: 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: describe:word 1 2 Data Stack: s- 3 Address Stack: - 4 5 Look for a glossary block with a title that starts with the 6 provided string. Display any that match. This will work with 7 partials. 8 9 Example: 10 11 'bye describe:word 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: dip 1 2 Data Stack: nq-n 3 Address Stack: - 4 5 Remove n from the stack and call the quotation. After execution, 6 put n back on the stack. A related word is +sip 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: drop 1 2 Data Stack: n- 3 Address Stack: - 4 5 Discard the top value on the data stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: drop-pair 1 2 Data Stack: nm- 3 Address Stack: - 4 5 Discard the top two values on the data stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: dtc 1 2 Data Stack: - 3 Address Stack: - 4 5 This begins a direct threaded code sequence. Most compiled code 6 in Konilo is DTC. They start with a stub which calls this, then 7 this handles walking through the list of addresses. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: dump 1 2 Data Stack: pn- 3 Address Stack: - 4 5 Taking a pointer and a length, this will display a memory dump 6 starting at the pointer address. The display shows the address 7 (in decimal), the individual bytes (in hex) and the raw cell 8 value (in decimal). 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: dup 1 2 Data Stack: n-nn 3 Address Stack: - 4 5 Make a copy of the top value on the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: dup-pair 1 2 Data Stack: nm-nmnm 3 Address Stack: - 4 5 Make a copy of the top two values on the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:Display 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a pointer to a word which displays the 6 current block. This defaults to pointing to +list 7 8 9 10 11 12 13 14 Type: variable 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:copy 1 2 Data Stack: n- 3 Address Stack: - 4 5 Copy the contents of a line in the block editor to a dedicated 6 buffer. This can be used with +e:paste to duplicate a line. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: e:cut 1 2 Data Stack: n- 3 Address Stack: - 4 5 Move the contents of a line in the block editor to a dedicated 6 buffer. This can be used with +e:paste to move a line. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: e:erase/line 1 2 Data Stack: n- 3 Address Stack: - 4 5 Erase the contents of a line in the block editonr. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:for-each-line 1 2 Data Stack: q- 3 Address Stack: - 4 5 For each line in the current block, push a pointer to a string 6 with the line contents to the stack, and call the provided 7 quotation. 8 9 Example: 10 11 :list* [ (s-) s:put nl ] e:for-each-line ; 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: e:indent 1 2 Data Stack: n- 3 Address Stack: - 4 5 Indent a line in the editor. This adds two spaces to the start 6 of the line. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: e:insert 1 2 Data Stack: n"- 3 Address Stack: - 4 5 Parse until the end of the line. Replace the contents of line 6 n with the parsed text. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:insert-at 1 2 Data Stack: nm"- 3 Address Stack: - 4 5 Parse until the end of the line. Insert the read text into the 6 specified line (n) starting at column (c). 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:line 1 2 Data Stack: n- 3 Address Stack: - 4 5 Display a line in the current block. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:paste 1 2 Data Stack: n- 3 Address Stack: - 4 5 Replace the contents of line n with the text in the dedicated 6 cut/copy buffer. Use this with +e:copy and +e:cut 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: e:replace 1 2 Data Stack: ns- 3 Address Stack: - 4 5 Replace the contents of line n with the text in string s. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:replace-at 1 2 Data Stack: nms- 3 Address Stack: - 4 5 Insert the text in s into line n, starting at column n. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:to-line 1 2 Data Stack: n-a 3 Address Stack: - 4 5 Given a line number, return the starting address for that 6 line in the block buffer. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: e:unindent 1 2 Data Stack: n- 3 Address Stack: - 4 5 Remove a level of indention from a line in the editor. Indention 6 levels are two spaces each. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: edit 1 2 Data Stack: n- 3 Address Stack: - 4 5 Load the specified block number and display it using the display 6 word +e:Display points to (normally +list ). 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: eq? 1 2 Data Stack: nm-f 3 Address Stack: - 4 5 Compare two values for equality. If equal, return a true flag. 6 If not equal, return a false flag. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: f:add 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Add m to n, leaving the result on the stack. 6 7 This is part of the fixed point vocabulary. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: f:div 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Divide n by m, leaving the result on the stack. 6 7 This is part of the fixed point vocabulary. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: f:mul 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Multiply n by m, leaving the result on the stack. 6 7 This is part of the fixed point vocabulary. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: f:put 1 2 Data Stack: n- 3 Address Stack: - 4 5 Display the fixed point number. 6 7 This is part of the fixed point vocabulary. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: f:scale 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a scale value used by the fixed point math 6 vocabulary. It defaults to #100. 7 8 This is part of the fixed point vocabulary. 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: f:sub 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Subtract m from n, leaving the result on the stack. 6 7 This is part of the fixed point vocabulary. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fetch 1 2 Data Stack: p-n 3 Address Stack: - 4 5 Fetch the value stored in the specified memory location. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: fetch-next 1 2 Data Stack: p-pn 3 Address Stack: - 4 5 Fetch the value stored in memory at p. Return the next address 6 (p + 1), and the fetched vale. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: fg:black 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to black. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:blue 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to blue. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:cyan 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to cyan. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:green 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to green. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:magenta 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to 6 magenta. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:red 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to red. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:white 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to white. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fg:yellow 1 2 Data Stack: - 3 Address Stack: - 4 5 A part of (termina), this sets the foreground color to yellow. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: fill 1 2 Data Stack: vpn- 3 Address Stack: - 4 5 Fill n cells of memory starting at address p with the specified 6 value. 7 8 Example: 9 10 (fill_the_block_buffer_with_Q) 11 $Q block:buffer #1024 fill 12 list 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: forever 1 2 Data Stack: q- 3 Address Stack: - 4 5 Run the provided quotation repeatedly, in an endless loop. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: gc 1 2 Data Stack: q- 3 Address Stack: - 4 5 Run the provided quotation. This saves the value of +Free 6 and restores in when the quotation returns. It's basically 7 a lightweight form of garbage collection. 8 9 Example: 10 11 here n:put nl [ #100 allot here n:put nl ] gc here n:put nl 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: glossary:exists? 1 2 Data Stack: s-f 3 Address Stack: - 4 5 Given a word name, return true if a glossary block exists for 6 it, or false otherwise. Glossary blocks have a title with the 7 form: "Glossary: name" 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: glossary:locate 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Given a word name, return the number of the block containing 6 the glossary data for it. If not found, this will return zero. 7 Glossary blocks have a title with the form: "Glossary: name" 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: gt? 1 2 Data Stack: nm-f 3 Address Stack: - 4 5 Return true if n is greater than m, or false otherwise. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: gteq? 1 2 Data Stack: nm-f 3 Address Stack: - 4 5 Return true if n is greater than or equal to m, or false 6 otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: here 1 2 Data Stack: -p 3 Address Stack: - 4 5 Return a pointer to the next free memory address. This is the 6 same as fetching from +Free 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: i 1 2 Data Stack: s- 3 Address Stack: - 4 5 Given a string containing an ilo instruction bundle, use 6 +assemble:opcode to assemble it and then +comma to store it 7 into memory at +here 8 9 Example: 10 11 code: n:square 'dumure.. i 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: if 1 2 Data Stack: fq- 3 Address Stack: - 4 5 Execute the provided *quotation if the passed flag is true. 6 If the flag is false, it just discards the pointer. 7 8 Example: 9 10 #100 #200 eq? [ 'Values_do_match s:put ] if 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: indexed-times 1 2 Data Stack: nq- 3 Address Stack: - 4 5 Execute the specified quote the specified number of times. This 6 is similar to +times but provides access to the loop index via 7 +I (as well as access to parent and grandparent index values 8 with +J and +K ) 9 10 Example: 11 12 #30 [ I n:put sp ] indexed-times 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: internal:lit 1 2 Data Stack: - 3 Address Stack: -n 4 5 This is an internal word used to push a value to the stack. I 6 a colon definition or quote, it will push the value in the 7 following memory location to the stack, skipping over the value 8 in the process. 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: internal:quote 1 2 Data Stack: -p 3 Address Stack: - 4 5 This is an internal word used to skip over embedded quotations 6 in colon definitions (or other quotes). After skipping the quote 7 it will push a pointer to the skipped quote to the stack. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: interpret 1 2 Data Stack: s- 3 Address Stack: - 4 5 Given a string with a single token, interpret the token. This 6 follows the standard flow: check for sigil, then try to find in 7 the dictionary, then report error if the other cases fail. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: invoke 1 2 Data Stack: ss- 3 Address Stack: - 4 5 Takes a word name and a block set name. If the word name is not 6 found in the dictionary, the block set is loaded. After this 7 the word is run. 8 9 Example 10 11 '(dusk:paint2) 'paint2 invoke 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: io 1 2 Data Stack: ...n- 3 Address Stack: - 4 5 Perform an i/o operation. This is mostly used internally by 6 other words. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: jump 1 2 Data Stack: a- 3 Address Stack: - 4 5 Jump to an address. This is mostly provided to aid in writing 6 new execution flow control combinators. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: l 1 2 Data Stack: - 3 Address Stack: - 4 5 An alias for +list . This will display the current block with 6 line numbers and column indicator rulers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: list 1 2 Data Stack: - 3 Address Stack: - 4 5 Display the current block. This will show the contents with line 6 numbers and column rulers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: list# 1 2 Data Stack: - 3 Address Stack: - 4 5 Display the current block. This will display with line numbers, 6 but not column rulers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: list* 1 2 Data Stack: - 3 Address Stack: - 4 5 Display the current block. This will only show the text in the 6 block, no line numbers or column rulers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: list:syntax 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of Tuhi. Display the current block. The block is shown 6 with line numbers, syntax highlighting (based on the Tuhi 7 configuration variables), and a right column rule. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: load 1 2 Data Stack: - 3 Address Stack: - 4 5 Load (or reload) the current block. The block number is taken 6 from +Block 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: locate 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse for the start of a block title. Search the blocks for any 6 that start with the provded text, and display the block number 7 and title line for matches. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: lt? 1 2 Data Stack: nm-f 3 Address Stack: - 4 5 Compare n and m. If n is less than m, return true. Otherwise, 6 return false. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: lteq? 1 2 Data Stack: nm-f 3 Address Stack: - 4 5 Compare n and m. If n is less than or equal to m, return true. 6 Otherwise returns false. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: man 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse for a manual page name. Lookup the page in the manual and 6 display it on the screen. This does not start the actual manual 7 browser; use +manual for that. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:START 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the block number for the first block in the manual. 6 This is used to help improve performance when looking up 7 entries. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:Termina 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable determines whether or not the manual display 6 will attempt to use color or not. It defaults to true. 7 8 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:edit 1 2 Data Stack: s- 3 Address Stack: - 4 5 Given a manual page name, load the correponding block and start 6 the +Editor on it. (By default, this will start Tuhi). 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:exists? 1 2 Data Stack: s-f 3 Address Stack: - 4 5 Return true if the requested page is found in the manual, or 6 false otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:list 1 2 Data Stack: - 3 Address Stack: - 4 5 Display the current block using the manual page viewer. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:locate 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Search the manual for a page with the given name. If found, 6 return the block number. If not, return zero. Manual pages 7 have a name of form: "man: name". The manual page names must 8 be lowercase. 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: man:new 1 2 Data Stack: - 3 Address Stack: - 4 5 Find the next unused block in the manual space, and start the 6 Tuhi editor on it. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: manual 1 2 Data Stack: - 3 Address Stack: - 4 5 Start the manual browser, on the *Start page. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: mv 1 2 Data Stack: ""- 3 Address Stack: - 4 5 Parse for a source block number and a destination block number. 6 Move the contents of the source block into the destination 7 block. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n 1 2 Data Stack: - 3 Address Stack: - 4 5 An alias for +next +list this will load the next block and then 6 display it. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:-zero? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Return true if n is not equal to zero, or false if it is. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:MAX 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the largest valid number. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:MIN 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the smallest valid number. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:abs 1 2 Data Stack: n-n 3 Address Stack: - 4 5 Return the absolute value of a number. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:add 1 2 Data Stack: nm-n 3 Address Stack: - 4 5 Add n to m, leaving the result on the stack. 6 7 Example: 8 9 #1200 #33 n:add 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:between? 1 2 Data Stack: nlu-f 3 Address Stack: - 4 5 Return true if n is between the lower (l) and upper (u) limits. 6 The bounds are inclusive. If not within the bounds, returns 7 false. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:dec 1 2 Data Stack: n-m 3 Address Stack: - 4 5 Decrement n by 1. 6 7 Example: 8 9 #1200 n:dec 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:div 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Divide n by m, giving the result. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:divmod 1 2 Data Stack: nm-xy 3 Address Stack: - 4 5 Divide n by m, returning the result (y) and remainder (x). 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:even? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Return true if n is even, or false if not. 6 7 Example: 8 9 :check (n-) 10 n:even? [ 'Yes,_it's_even! s:put nl ] if ; 11 12 #33 check #44 check 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:get 1 2 Data Stack: "-n 3 Address Stack: - 4 5 Parse ahead for a token and convert it to a number with +s:to-n 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:inc 1 2 Data Stack: n-m 3 Address Stack: - 4 5 Increment n by 1. 6 7 Example: 8 9 #72 n:inc 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:limit 1 2 Data Stack: nlu-n 3 Address Stack: - 4 5 Constrain n such that n will have a value between a lower (l) 6 and upper (u) limit, inclusive. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:max 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Return the greater of n or m. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:min 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Return the lesser of n or m. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:mod 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Divide n by m and return the remainder. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:mul 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Multiply n and m, leaving the result on the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:negate 1 2 Data Stack: n-n 3 Address Stack: - 4 5 Invert the sign of a number. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:negative? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Return true if the number is lessthan zero, or false otherwise. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:odd? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Return true if the number is odd, or false if not. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:positive? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Return true if the number is positive or false otherwise. This 6 considers zero to be part of the positive set of numbers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:put 1 2 Data Stack: n- 3 Address Stack: - 4 5 Convert n to a string using +n:to-s and display it. 6 7 This will use a little of the temporary string and array space. 8 9 Example: 10 11 #1234 n:put 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:random 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return a random number and update the internal seed. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:random-mod 1 2 Data Stack: n-m 3 Address Stack: - 4 5 Return a random number between 0 and (n - 1), and update the 6 internal seed. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:sign 1 2 Data Stack: n-m 3 Address Stack: - 4 5 Return the sign of a number. For positive numbers, this will be 6 1. For negative, it will be -1. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:sqrt 1 2 Data Stack: n-m 3 Address Stack: - 4 5 Return the (approximate) squarre root of a number. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:square 1 2 Data Stack: n-m 3 Address Stack: - 4 5 Return the square of a number. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:strictly-positive? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Return true if the number is greater than zero, or false if 6 equal to or less than zero. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: n:sub 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Subtract m from n, leaving the result on the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:to-s 1 2 Data Stack: n-s 3 Address Stack: - 4 5 Convert a provided number to a string. The string is stored in 6 the system's temporary string and array space. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: n:zero? 1 2 Data Stack: n-f 3 Address Stack: - 4 5 Compare a number to zero. Returns true if it is zero, or false 6 otherwise. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: needs 1 2 Data Stack: s- 3 Address Stack: - 4 5 Takes a string with a block name (the first token in a title 6 line is used for this). Scans through the blocks, running any 7 code in matching blocks. 8 9 Example: 10 11 '(graphica) needs 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: new 1 2 Data Stack: - 3 Address Stack: - 4 5 Erase the contents of the currently loaded block. This does not 6 update the block on disk. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: next 1 2 Data Stack: - 3 Address Stack: - 4 5 Switch to the next block by incrementing +Block and using +load 6 to read it into memory. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: nip 1 2 Data Stack: nm-m 3 Address Stack: - 4 5 Discard the second from top stack item. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: nl 1 2 Data Stack: - 3 Address Stack: - 4 5 Move the cursor to the start of the next line. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: not 1 2 Data Stack: n-n 3 Address Stack: - 4 5 Perform a logical NOT operation on a value. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: or 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Perform a bitwise OR between two values. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: over 1 2 Data Stack: xy-xyx 3 Address Stack: - 4 5 Put a copy of the second stack item on the top of the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: p 1 2 Data Stack: - 3 Address Stack: - 4 5 Switch to the previous block and display it. This is an alias 6 for +prev +list 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: pop 1 2 Data Stack: -n 3 Address Stack: n- 4 5 Move a value from the address stack to the data stack. This 6 must be balanced with a prior +push in the same definition. 7 8 I generally recommend using a quote and +dip or +sip over use 9 of +push and +pop 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: prelude 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of the +startup process, this loads and runs code in 6 blocks 1 and 2. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: prev 1 2 Data Stack: - 3 Address Stack: - 4 5 Switch to the previous block. This is done by decrementing 6 +Block and using +load to read it into memory. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: process-data 1 2 Data Stack: n-n OR (if compiling): n- 3 Address Stack: - 4 5 This is primarily used internally. 6 7 If compiling, this adds a call to +internal:lit and then uses 8 +comma to store the value in the current definition. If not, 9 it just leaves the value on the stack. 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: push 1 2 Data Stack: n- 3 Address Stack: -n 4 5 Move a value from the data stack to the address stack. The move 6 must be balanced by a corresponding +pop before the end of the 7 definition. 8 9 I generally recommend using a quote and +dip or +sip over use 10 of +push and +pop 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: r 1 2 Data Stack: a- 3 Address Stack: - 4 5 Part of the pali assembler. Takes an address for a function or 6 data item and uses +comma to store it to +here 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: reorder 1 2 Data Stack: ...ss-... 3 Address Stack: - 4 5 The ultimate stack shuffler. This takes two strings, which 6 represent values on the stack. The stack is restructured to 7 match these. 8 9 Example: 10 11 #1 #2 #3 'abc 'bacaccacab reorder 12 (stack_is_now:_#2_#1_#3_#1_#3_#3_#1_#3_#1_#2) 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: reset 1 2 Data Stack: ...- 3 Address Stack: - 4 5 Remove all values on the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: restart 1 2 Data Stack: - 3 Address Stack: - 4 5 Restart Konilo. Resets the stacks and reloads the ilo.rom. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: rm 1 2 Data Stack: "- 3 Address Stack: - 4 5 Parse for a block number. Load and erase the contents of this 6 block. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: roll 1 2 Data Stack: abc-cab 3 Address Stack: - 4 5 Move the top stack item down two spaces. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: rom:save 1 2 Data Stack: - 3 Address Stack: - 4 5 Write the current memory contents to ilo.rom. It is not required 6 for an ilo system to support this; on non-supported systems it 7 is treated as a non-operation. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: rot 1 2 Data Stack: abc-bca 3 Address Stack: - 4 5 Rotate the third stack item to the top of the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: run 1 2 Data Stack: - 3 Address Stack: - 4 5 Run any code in the current block. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s 1 2 Data Stack: s- 3 Address Stack: - 4 5 Part of the pali assembler. Inline the contents of a string to 6 +here 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:-eq? 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Compare two strings for inequality. If the differ, this will 6 return a true flag. If they are identical, it returns false. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:ASCII-LETTERS 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string of ASCII letters (English only) in upper 6 and lowercase. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:ASCII-LOWERCASE 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string of ASCII letters (English only), in lowercase. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:ASCII-UPPERCASE 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string of ASCII letters (English only), in uppercase. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:CONSONANTS 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string of characters considered consonants. (ASCII, 6 English only) 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:DIGITS 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string of characters considered valid as numeric 6 digits. This is 0-9 and A-F, covering bases up through 7 hexadecimal. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:PUNCTUATION 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string containing characters considered punctuation 6 (for ASCII) 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:VOWELS 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string containing the valid vowels (for ASCII, 6 in English). 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:WHITESPACE 1 2 Data Stack: -s 3 Address Stack: - 4 5 Return a string containing the characters considered valid 6 whitespace. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:append 1 2 Data Stack: ab-s 3 Address Stack: - 4 5 Create a new string from the contents of string a followed by 6 the contents of string b. This is similar to +s:prepend 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:begins-with? 1 2 Data Stack: ss-f 3 Address Stack: - 4 5 Return true if the first string begins with the second one. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:behead 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Remove the first character from the string, returning a new 6 string. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:chop 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Remove the last character from a string, returning a new 6 string. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:contains/s? 1 2 Data Stack: sm-f 3 Address Stack: - 4 5 Check to see if string s contains a substring m. Return true if 6 it does, or false if it does not. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:contains? 1 2 Data Stack: sc-f 3 Address Stack: - 4 5 Check to see if a string contains a specific character. Return 6 true if it does, or false if it does not. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:copy 1 2 Data Stack: sp- 3 Address Stack: - 4 5 Copy the string at s to memory starting at address p. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:dup 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Make a copy of a string. The copy is in the temporary space. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:ends-with? 1 2 Data Stack: sm-f 3 Address Stack: - 4 5 Return true if string s ends with string m. Return false f 6 it does not. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:eq? 1 2 Data Stack: sm-f 3 Address Stack: - 4 5 Compare two strings. If identical, return true. If not, return 6 false. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:evaluate 1 2 Data Stack: s-? 3 Address Stack: - 4 5 Redirect the keyboard input (via +c:get ) to read input from 6 the provided string instead. The data in the string will be 7 processed by the listener, with control returning to the 8 keyboard at the end of the string. 9 10 Important note: Use of +s:evaluate can not be nested. 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:fetch 1 2 Data Stack: sn-c 3 Address Stack: - 4 5 Fetch a character from a string. Provide the string and an index 6 into the string. 7 8 Example: 9 10 'Hello_Phish #6 s:fetch (obtain_the_$P) 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:filter 1 2 Data Stack: sq-s 3 Address Stack: - 4 5 Runs the provided quotation against each value in the string. 6 The quotation consumes the value and returns a flag. If true, 7 the value is copied into a new string. If false, the value is 8 is discarded. 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:first 1 2 Data Stack: s-c 3 Address Stack: - 4 5 Return the first character in the provided string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:for-each 1 2 Data Stack: - 3 Address Stack: - 4 5 Runs the provided quotation against each value in the array. 6 The quotation will receive each value and can then consume or 7 transform it as desired. 8 9 Example: 10 11 :s:put [ c:put ] s:for-each ; 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:get/line 1 2 Data Stack: "-s 3 Address Stack: - 4 5 Read text until the end of the line. Return a pointer to the 6 string. This string will be placed in the temporary buffers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:get/token 1 2 Data Stack: "-s 3 Address Stack: - 4 5 Read text until a whitespace is encountered. Return a pointer 6 to the string. 7 8 This does not move the string into the temporary buffers. Use 9 it with +s:temp if you are not going to consume the string 10 immediately after reading it. 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:hash 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Return the hash of the characters in the string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:index/c 1 2 Data Stack: sc-n 3 Address Stack: - 4 5 Search string for the first instance of a character. Return 6 the index of the located character. If the character is not 7 found, the returned value will be invalid. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:index/s 1 2 Data Stack: ss-n 3 Address Stack: - 4 5 Return the index of the first instance of the second string 6 in the first string. If not found, the resulting index will 7 be invalid. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:keep 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Copy a string to memory starting at +here 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:last 1 2 Data Stack: s-c 3 Address Stack: - 4 5 Return the last character in the string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:left 1 2 Data Stack: sn-s 3 Address Stack: - 4 5 Return a new string with the first n characters from the source 6 string. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:length 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Return the number of characters in the string. This does not 6 include the length cell of the string. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:map 1 2 Data Stack: sq-s 3 Address Stack: - 4 5 Execute the quote once for each character in the string. The 6 character is pushed to the stack before the quotation is 7 called. The quote must return a new value. The new values will 8 be stored in a new string. 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:middle 1 2 Data Stack: sfn-s 3 Address Stack: - 4 5 Given an string, a starting index (f) and a length (n), return 6 a new string with the values taken from the indicated subset. 7 8 Example: 9 10 '0123456789 #2 #3 s:middle (returns_'234) 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:prepend 1 2 Data Stack: ss-s 3 Address Stack: - 4 5 Create a new string with the characters from the second string, 6 followed by the characters in the first string. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:put 1 2 Data Stack: s- 3 Address Stack: - 4 5 Display a string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:reduce 1 2 Data Stack: anq-n 3 Address Stack: - 4 5 Takes an string, a starting value, and a quote. This will run 6 the quote against each character in the string; the quote should 7 consume two values and return one. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:reverse 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Return a new string with the characters from the original 6 string. The order of the characters will be reversed. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:rewrite 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Replace underscores in a string with spaces. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:right 1 2 Data Stack: sn-s 3 Address Stack: - 4 5 Return a new string, with the n characters from the right side 6 of the string. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:store 1 2 Data Stack: csn- 3 Address Stack: - 4 5 Store character (c) into the string (s) at index (n). 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:temp 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Make a copy of the string in the temporary string space. This 6 will return a pointer to the copy. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:th 1 2 Data Stack: sn-a 3 Address Stack: - 4 5 Given a string and an index, return the address the index refers 6 to. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:to-lower 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Create a new string, with the characters in the source string 6 converted to their lowercase forms. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:to-n 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Convert a string to a number. This only works in decimal, and 6 embedded . or , characters are ignored. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:to-upper 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Create a new string, with the characters in the source string 6 being converted to their uppercase forms. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: s:trim 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Remove both leading and trailing whitespace from a string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:trim-left 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Remove leading whitespace from a string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: s:trim-right 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Remove trailing whitespace from a string. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: save 1 2 Data Stack: - 3 Address Stack: - 4 5 Save the current +Block to disk. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: seed 1 2 Data Stack: - 3 Address Stack: - 4 5 This holds the next seed for +n:random and +n:random-mod 6 7 You should ideally update this before using the RNG. 8 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: set 1 2 Data Stack: n- 3 Address Stack: - 4 5 Set +Block to the desired block number. 6 7 Example: 8 9 #10 set 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: shift-left 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Shift n left by m bits. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:! 1 2 Data Stack: nm-o 3 Address Stack: - 4 5 Shift n right by m bits. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:# 1 2 Data Stack: ns- 3 Address Stack: - 4 5 Sigil. The token must be a word name. This will find the token 6 in the dictionary and obtain the address of the variable. It 7 will then check the +Compiler state. If compiling, this will 8 compile the address as a literal and then add a call to +store 9 If interpreting, it just runs +store 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:# 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Sigil. Passes the provided token to +s:to-n then passes the 6 number to +process-data 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:$ 1 2 Data Stack: s-c 3 Address Stack: - 4 5 Sigil. Fetch the first character from the provided token 6 and pass it to +process-data 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:& 1 2 Data Stack: s-p 3 Address Stack: - 4 5 Sigil. The provided token must be a word name. This will find 6 the name in the dictionary, and return a pointer to the starting 7 address (from the +d:address field). The returned address is 8 the passed to +process-data 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:' 1 2 Data Stack: s-s 3 Address Stack: - 4 5 Sigil. The provided token is a string. If the compiler is off, 6 it is passed to +s:temp (for storage in the temporary buffers). 7 If the compiler is on, it is passed to +s:keep to store in the 8 permanent memory. During compilation it also lays down the code 9 needed to skip over it during execution. 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:( 1 2 Data Stack: s- 3 Address Stack: - 4 5 Sigil. This is used for comments; it discards the provided data. 6 7 Example: 8 9 (This_is_a_comment) 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:: 1 2 Data Stack: s- 3 Address Stack: - 4 5 Sigil. Create a new word with the provided name, setup the stub 6 for a new +dtc definition, and turn the +Compiler on. 7 8 Example: 9 10 :foo [a-comment) ; 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:@ 1 2 Data Stack: s-n 3 Address Stack: - 4 5 Sigil. Lookup the provided name and fetch the stored value. 6 This is provided as a readability aid for working with 7 variables. 8 9 Example: 10 11 @Base (is_the_same_as) &Base fetch 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:\ 1 2 Data Stack: ps- 3 Address Stack: - 4 5 Sigil. Creates a new word with the provided nome and set the 6 word to point to the provided address. This can be used to 7 add aliases for existing words, or to name quotations. 8 9 Example: 10 11 &n:add \+ 12 [ dup n:mul ] \n:square 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:get 1 2 Data Stack: c-p 3 Address Stack: - 4 5 Return a pointer to the sigil handler for the provided sigil. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sigil:set 1 2 Data Stack: pc- 3 Address Stack: - 4 5 Assign the provided word as the sigil handler for character c. 6 Set the sigil to 0 to disable the handler for it. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sip 1 2 Data Stack: nq-n 3 Address Stack: - 4 5 Make a copy of n off the stack, and call the quotation. After 6 execution, put the copy of n back on the stack. A related word 7 is +dip 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sp 1 2 Data Stack: - 3 Address Stack: - 4 5 Display a space. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: startup 1 2 Data Stack: - 3 Address Stack: - 4 5 This word is called as part of the normal system initialization. 6 Konilo will search for the most recent word named +startup and 7 run it. You can define a new one, or use the default one. By 8 default, this loads and runs code in blocks 1 and 2. 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: store 1 2 Data Stack: np- 3 Address Stack: - 4 5 Store a value into memory at the specified pointer. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: store-next 1 2 Data Stack: np-p 3 Address Stack: - 4 5 Store a value into memory at the specified pointer. Increment 6 the pointer and return it on the stack. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: swap 1 2 Data Stack: xy-yx 3 Address Stack: - 4 5 Exchange the positions of the top two items on the stack. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:BUFFERS 1 2 Data Stack: -a 3 Address Stack: - 4 5 Return the address of the start of the system buffers in 6 memory. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: sys:EOM 1 2 Data Stack: -n 3 Address Stack: - 4 5 Return the last addressable memory cell. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: sys:buffers/block 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 the system block buffer 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/input 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 text input via +s:get/token and +s:get/line 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/loops 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 indexed loops. 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/needs 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 loading blocks via +needs 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/numeric-conversion 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 conversion of strings to numbers and back. 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/reserved 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 system use, but not formally assigned to a single purpose. 7 Some parts of the tools in the blocks use this. 8 9 Access this via the & sigil. 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/scope 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 lexical scoping. 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:buffers/strings+arrays 1 2 Data Stack: - 3 Address Stack: - 4 5 This is the starting address of the memory dedicated to 6 temporary strings and arrays. 7 8 Access this via the & sigil. 9 10 11 12 13 14 Type: constant 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: sys:info 1 2 Data Stack: - 3 Address Stack: - 4 5 Display some system information, including the current block, 6 number of blocks, stack depth, and memory usage. This is shown 7 by +list 8 9 If you define a new sys:info, it will be used instead of the 10 default one. 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: tab 1 2 Data Stack: - 3 Address Stack: - 4 5 Display a horizontal tab character. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: ti:add-hint 1 2 Data Stack: sn- 3 Address Stack: - 4 5 Add a hint (s) for hotkey number (n). The hint will be padded or 6 clipped to 12 characters. Hints can only be added for the values 7 0 through 9. 8 9 Part of (termina). 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:application 1 2 Data Stack: q- 3 Address Stack: - 4 5 Start a (termina) program. 6 7 The provided quote must provide three pointers: 8 9 - word to setup the key actions 10 - word to setup the hints 11 - a word for the display 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:done 1 2 Data Stack: - 3 Address Stack: - 4 5 This word is used to end a (termina) program. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:get-action 1 2 Data Stack: c-q 3 Address Stack: - 4 5 Given a character, return a pointer to the word or quotation 6 which handles it. 7 8 Part of (termina) 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:height 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina); this variable should be set to the 6 number of rows Termina should use. 7 8 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:help 1 2 Data Stack: n- 3 Address Stack: - 4 5 This is a single block viewer, written as a (termina) tool. 6 It is normally used with a binding to $? which presents a 7 help or quick reference screen for additional keys beyond 8 the hot key area at the bottom of the display. 9 10 Part of (termina) 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:reset-actions 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina). This will erase the contents of the Termina 6 application shortcuts table. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:reset-display 1 2 Data Stack: - 3 Address Stack: - 4 5 Reset the display code to an internal stub for a blank display. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:reset-hints 1 2 Data Stack: - 3 Address Stack: - 4 5 Reset the hints to an empty state. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:set-action 1 2 Data Stack: qc- 3 Address Stack: - 4 5 This adds an action (q) to a key (c). 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:set-display 1 2 Data Stack: q- 3 Address Stack: - 4 5 Set the display word for a (termina) program. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:set-title 1 2 Data Stack: s- 3 Address Stack: - 4 5 Set the title for a (termina) program. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: ti:width 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina), this variable should be set to the number 6 of columns Termina should use. 7 8 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: times 1 2 Data Stack: nq- 3 Address Stack: - 4 5 Run a quotation (or other word) the specified number of times. 6 Unlike +indexed-times this form does not expose the loop index. 7 8 Example: 9 10 #0 #10 [ dup n:put n:inc ] times drop 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: titles 1 2 Data Stack: - 3 Address Stack: - 4 5 Display the titles of non-empty blocks. Also displays the 6 block numbers. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: tri 1 2 Data Stack: xppp-? 3 Address Stack: - 4 5 This runs each quote against a copy of the value (x). In effect, 6 the same as "x p1 x p2 x p3". 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: tri* 1 2 Data Stack: xyzppp-? 3 Address Stack: - 4 5 This runs p1 against x, p2 against y, and p3 against z. Equal to 6 doing "x p1 y p2 z p3". 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: tri@ 1 2 Data Stack: xzyp-? 3 Address Stack: - 4 5 This runs the provided quote against each of the values in turn. 6 Equal to doing "x p y p z p" 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: tuck 1 2 Data Stack: nm-mnm 3 Address Stack: - 4 5 Put a copy of the top stack item under the second item. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: tuhi 1 2 Data Stack: - 3 Address Stack: - 4 5 Start the Tuhi block editor. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: tuhi:cfg/colors,bg 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a pointer to the word which sets the 6 background color when using the syntax highlighting view. 7 8 By default this is set to +bg:black 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: tuhi:cfg/colors,fg 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a pointer to the word which sets the default 6 text color when using the syntax highlighting view. 7 8 By default this is set to +fg:green 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: tuhi:cfg/colors,line# 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable holds a pointer to the word which sets the line 6 number color when using the syntax highlighting view. 7 8 By default this is set to +fg:cyan 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: tuhi:cfg/status 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable is used to tell Tuhi whether or not to show a 6 status line. It is off (false) by default. Set to true (-1) 7 to enable this. 8 9 If using this, ensure your terminal has sufficient height to 10 show the line. 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: tuhi:cfg/syntax 1 2 Data Stack: - 3 Address Stack: - 4 5 This variable toggles whether or not the Tuhi editor uses the 6 syntax highlighting view. Set to true to enable this, or false 7 to disable. (In Tuhi, this can be toggled with the + and - keys) 8 9 10 11 12 13 14 Type: variable 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: unroll 1 2 Data Stack: cba-abc 3 Address Stack: - 4 5 Exchange the position of the top and third stack item. This is 6 provided as the inverse of +roll 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: until 1 2 Data Stack: q- 3 Address Stack: - 4 5 Run quotation in a loop. The quote must return a flag at the end 6 of each iteration. If false, the loop continues. If true, it 7 ends. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: use 1 2 Data Stack: n- 3 Address Stack: - 4 5 Load block n and +run the code in it. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: using 1 2 Data Stack: nm- 3 Address Stack: - 4 5 Run +use against blocks n through m. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: v:dec 1 2 Data Stack: a- 3 Address Stack: - 4 5 Decrement the value in a variable by 1. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: v:dec-by 1 2 Data Stack: na- 3 Address Stack: - 4 5 Decrement the value in a variable by the specified amount. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: v:inc 1 2 Data Stack: a- 3 Address Stack: - 4 5 Increment the value in a variable by 1. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: v:inc-by 1 2 Data Stack: na- 3 Address Stack: - 4 5 Increment the value in a variable by the specified amount. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: v:limit 1 2 Data Stack: plu- 3 Address Stack: - 4 5 Fetch the value stored at p, then constrain it to fall within 6 the provided lower and upper limits. Then store the updated 7 value back to p. 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: v:off 1 2 Data Stack: a- 3 Address Stack: - 4 5 Given a pointer to a variable, set the value to 0. 6 7 Example: 8 9 &MyVariable v:off 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: v:on 1 2 Data Stack: a- 3 Address Stack: - 4 5 Given a pointer to a variable, set the value to -1. 6 7 Example: 8 9 &MyVariable v:on 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: v:preserve 1 2 Data Stack: pq- 3 Address Stack: - 4 5 Fetch the value stored in the pointer p and remove p from the 6 stack. Run quotation q. Then store the previously read value 7 back into memory address p. 8 9 Example: 10 11 :gc (q-) &Free swap v:preserve ; 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: v:update 1 2 Data Stack: aq- 3 Address Stack: - 4 5 This combinator takes a variable pointer and a quotation. It 6 fetches the value stored in the variable, then calls the quote. 7 The quote must consume the provided value and return a new 8 value. After execution, the returned value is store in the 9 variable. 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: var 1 2 Data Stack: s- 3 Address Stack: - 4 5 Create a new variable with the provided name. The initial 6 value will be set to 0. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: var-n 1 2 Data Stack: ns- 3 Address Stack: - 4 5 Create a new variable with the provided name and set the 6 initial value to n. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: vt:clear 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina). Clear the display. This does not move the 6 cursor. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:csi 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina); this displays the ESC[ sequence that is 6 the start of many DEC escape sequences. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:down 1 2 Data Stack: n- 3 Address Stack: - 4 5 Move the cursor down the specified number of rows. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:esc 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina); this displays the ESC character. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:home 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina). Move the cursor to the top left corner 6 of the display. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:left 1 2 Data Stack: n- 3 Address Stack: - 4 5 Move the cursor left the specified number of rows. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:reset 1 2 Data Stack: - 3 Address Stack: - 4 5 Part of (termina). Reset the terminal state. This will return 6 to the default colors and attributes. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:right 1 2 Data Stack: n- 3 Address Stack: - 4 5 Move the cursor right the specified number of rows. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:row,col 1 2 Data Stack: rc- 3 Address Stack: - 4 5 Part of (termina). Move the cursor to row r, column c. These 6 are addressed starting at 1, 1, not 0, 0. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:set/color 1 2 Data Stack: n- 3 Address Stack: - 4 5 Set the foreground or background color. This is used internally 6 by the fg: and bg: words. 7 8 This is part of (termina). 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: vt:up 1 2 Data Stack: n- 3 Address Stack: - 4 5 Move the cursor up the specified number of rows. 6 7 Part of (termina). 8 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: while 1 2 Data Stack: q- 3 Address Stack: - 4 5 Run quotation in a loop. The quote must return a flag at the end 6 of each iteration. If true, the loop continues. If false, it 7 ends. 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: xcp 1 2 Data Stack: """- 3 Address Stack: - 4 5 Parse for a starting block, a destination, and a quantity. 6 Copy the quantity of blocks from the starting point to the 7 destination. Overlapping ranges are not supported. 8 9 This is part of (nonix) 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: xmv 1 2 Data Stack: """- 3 Address Stack: - 4 5 Parse for a starting block, a destination, and a quantity. 6 Move the quantity of blocks from the starting point to the 7 destination. Overlapping ranges are not supported. 8 9 This is part of (nonix) 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: xor 1 2 Data Stack: nn-n 3 Address Stack: - 4 5 Perform a bitwise XOR between two values. 6 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: xrm 1 2 Data Stack: ""- 3 Address Stack: - 4 5 Parse for a starting block and a number of blocks. Erase the 6 specified number of blocks. 7 8 This is part of (nonix). 9 10 11 12 13 14 Type: word 15 Defined In: blocks ---------------------------------------------------------------- 0 Glossary: {{ 1 2 Data Stack: - 3 Address Stack: - 4 5 Begin a lexical scope. This starts the private portion of the 6 scope. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 Glossary: }} 1 2 Data Stack: - 3 Address Stack: - 4 5 Close a lexical scope. This unlinks the private dictionary 6 headers and resumes normal use of the dictionary. 7 8 9 10 11 12 13 14 Type: word 15 Defined In: rom ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: start 1 2 Welcome to *Konilo, a *personal, *pragmatic *ComputingSystem 3 written in a *UniqueDialect of *Forth and running on a *portable 4 *VirtualComputer named *ilo. 5 6 This is a *hypertext *manual for Konilo. Assuming you accessed 7 it by running +manual, you can enter any of the red links 8 (which start with an asterisk) to jump to that topic. Or hit ? 9 for some general help. If reading online, just click the links. 10 11 Some starting points: 12 13 *BasicInteractions *TheTools 14 *LanguageReference *LoadableExtensions 15 ---------------------------------------------------------------- 0 man: pronunciation 1 2 The system described here is Konilo (pronounced koh-nee-lo), 3 running on the ilo virtual computer. There are related 4 implementations for napia and arks as well. Those systems have 5 separate documentation. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Overview of Konilo 1 2 The Konilo 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 Konilo 1 2 Snapshots 3 4 You can obtain the latest version of Konilo frem 5 konilo.org or ilo.retroforth.org via Gemini or HTTP(S). 6 7 * gemini://konilo.org 8 * https://konilo.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 the Fossil version control system. 4 5 6 Via Fossil: 7 8 fossil clone http://fossils.retroforth.org:8000/ilo \ 9 konilo.fossil 10 mkdir konilo; cd konilo 11 fossil open ../konilo.fossil 12 13 14 15 ---------------------------------------------------------------- 0 man: build: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 man: build:d 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: build:cxx 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 man: build:csharp 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 man: build: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 man: build: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 man: build: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 man: build: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 man: binaries 1 2 In addition to the source code, I provide precompiled builds for 3 a variety of architectures and host operating systems. 4 5 These are available on konilo.org or ilo.retroforth.org and are 6 listed below the ilo source links. 7 8 Should you use these or build from source? It's up to you. I 9 prefer to build locally when possible, but if using a system 10 without the required development tools installed, using a pre- 11 compiled binary can be very helpful. 12 13 14 15 ---------------------------------------------------------------- 0 man: runningkonilo 1 2 To run Konilo, put the ilo binary somewhere in your path, then 3 copy ilo.rom and ilo.blocks to your working directory, Finally, 4 run ilo. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: listener 1 2 The listener is the primary interface to *Konilo. It reads and 3 evaluates your input in a continual loop. 4 5 Using Listener 6 7 To use the listener, just type in your code. The listener will 8 process each whitespace separated token separately, as entered. 9 (Though some buffering may occur, depending on your host and 10 *ilo combination; see *ListenerAndBuffering). You can use back- 11 space to make corrections within the current token, but not 12 anything before this. 13 14 15 ---------------------------------------------------------------- 0 man: basicinteractions 1 2 At the *listener you can enter code, and *Konilo will run what 3 you 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 *Konilo 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 Konilo: 14 15 bye ---------------------------------------------------------------- 0 man: blocks 1 2 *Konilo uses blocks to store code & 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 pair of *BlockEditors are included. I like using *BasicEditor 7 for most things. A more visual editor, *Tuhi, is also provided. 8 9 Additional tools like the *Catalogue and *Nonix provide for 10 locating, renaming, and organizing blocks. 11 12 Learning to use the blocks and tools operating on them is essen- 13 tial if you wish to make productive use of Konilo. 14 15 ---------------------------------------------------------------- 0 man: whatareblocks 1 2 In Konilo, 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 man: blockformat 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 man: binaryblocks 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 like +titles or +needs 6 7 E.g., for a binary format of drawing data I have the first row 8 contain a type ID, title for the drawing, and other metadata. 9 This is repeated for each block needed. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: commentingblocks 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 *InlineComments. I do this for *StackCmomments 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 *ShadowBlocks. This would involve alternating between blocks 13 with code and blocks with descriptions of the code on the 14 previous block. 15 ---------------------------------------------------------------- 0 man: startingthebasiceditor 1 2 Begin by telling *Konilo that you wish to edit a block. This is 3 done by providing the block number followed by +edit . For 4 example, to edit block 689: 5 6 #689 edit 7 8 Konilo will run +list to show the block, along with the line 9 numbers, a guide for identifying columns, and some status info. 10 Rerun +list to redisplay the block as you make edits. 11 12 To go the the next block, run +next, and to go to the previous 13 block, run +prev . 14 15 See *EditingWithTheBasicEditor ---------------------------------------------------------------- 0 man: editingwiththebasiceditor 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 your 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 man: runningcodefromthebasiceditor 1 2 You can run code in the current block with +run - remember to 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 man: groupingblocks 1 2 Often you will need more than one block for your programs. I 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) 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 man: findingblocks 1 2 *Konilo provides a few tools to help you locate *blocks. 3 4 +titles will display a list of all named blocks in the system. 5 6 You can use +locate followed by the first part of a block title 7 to see a list of all blocks that match. For instance, if you do 8 `locate (std)`, all blocks starting with "(std)" will be shown. 9 10 The +catalogue provides a visual browser for the blocks. 11 12 13 14 15 ---------------------------------------------------------------- 0 The Konilo Language 1 2 Konilo 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 Konilo will check the first character of a 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, Konilo 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 man: sigils 1 2 If you are familiar with traditional Forth, you likely notice 3 that no number handling is done. In Konilo these are handled by 4 a sigil. 5 6 The sigil system is a central part of Konilo'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 *HowSigilsWork 12 *DefiningSigils 13 *SigilTable 14 15 ---------------------------------------------------------------- 0 man: howsigilswork 1 2 Konilo 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 See *Sigils 13 14 15 ---------------------------------------------------------------- 0 man: sigiltable 1 2 +-------+---------------------------------------------------+ 3 | Sigil | Use | 4 +=======+===================================================+ 5 | : | Begin a colon definition | 6 | # | Process a number | 7 | ( | Begin a comment (ends at the first whitespace) | 8 | & | Return a pointer to a named item | 9 | ' | Return a pointer to a string | 10 | $ | Return the ASCII code of the first character | 11 | @ | Fetch a stored value from a variable | 12 | ! | Store into a variable | 13 | \ | Create an alias to a named item | 14 +-------+---------------------------------------------------+ 15 ---------------------------------------------------------------- 0 man: numbers 1 2 Number in *Konilo are signed, 32-bit integers. They are made by 3 using the # sigil. 4 5 For negative values, add a - after the # sigil. 6 7 Numbers are only supported in decimal (base 10), and any comma 8 or periods in a number are ignored. 9 10 Examples: 11 12 #100 #-50.25 #1,215 13 14 15 *BasicMath *NumberComparisons ---------------------------------------------------------------- 0 man: arrays 1 2 Arrays are sequences of values. They are one of the central data 3 types in *Konilo. 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 man: arraycreation 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 man: arrayaccessingelements 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 man: arrayiteration 1 2 Konilo 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 man: arraymerge 1 2 To combine two arrays into a new array, Konilo 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 man: arraycomparison 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 man: arraysubsets 1 2 You can extract subsets of an array. Konilo 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 man: strings 1 2 In *Konilo, strings are *arrays of *characters. You should 3 review the *arrays topic for information on the basic structure 4 and operations on them. 5 6 Konilo provides a variety of words for operating on strings. 7 There are in the `s:` namespace. Since strings are a type of 8 array, you can also use any `a:` words on them. 9 10 *StringCreation *StringComparison 11 *StringLifecycle *StringSubsets 12 *StringAccessCharacters *StringFilterAndMap 13 *StringIteration *StringCaseConversion 14 *StringMerge *StringTrimming 15 ---------------------------------------------------------------- 0 man: stringcreation 1 2 *Strings are created with the ' *sigil. 3 4 A string is a single token. Konilo will replace any underscores 5 (_) with spaces. 6 7 Some examples: 8 9 'hello_world! 10 '"Well,_that's_odd"_he_replied. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stringlifecycle 1 2 Strings created at the interpreter are stored in a rotating 3 buffer. This is used by both strings and arrays, and is used 4 by words operating on strings. 5 6 Strings inside definitions get compiled into the system memory. 7 8 You can copy a string to the buffer space using +s:temp or to 9 the system *memory by using +s:keep 10 11 If you won't be using the string quickly, it's best to put it 12 in system memory. 13 14 15 ---------------------------------------------------------------- 0 man: stringaccesscharacters 1 2 To read a specific character, pass a pointer to the string and 3 the offset to +s:fetch : 4 5 'Hello! #2 a:fetch 6 7 To store a character into an array, pass the value, a pointer to 8 the string, and the offset to +s:store : 9 10 $T 'there_is_a_wall #1 s:store 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stringiteration 1 2 *Konilo provdes +s:for-each to run a function against each 3 *character in a string. For instance, to display the ASCII 4 value of each item: 5 6 'Hello_World! [ (n-) n:put sp ] s:for-each 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stringmerge 1 2 To combine two strings into a new string, Konilo provides both 3 `s:append` and `s:prepend`. Each take two pointers to existing 4 strings and construct a new one. 5 6 'abc 'def s:append (create_string_abcdef) 7 'abc 'def s:prepend (create_string_defabc) 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stringcomparisons 1 2 +s:eq? 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stringsubsets 1 2 You can extract subsets of an array. Konilo 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 man: stringfilterandmap 1 2 +s:filter 3 +s:map 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stringcaseconversion 1 2 +s:to-upper 3 +s:to-lower 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: characters 1 2 Characters are numbers that correspond to graphemes or symbols 3 in a chosen encoding. In Konilo, I basically use ASCII as my 4 encoding. 5 6 Characters include the numbers 0-9, letters a-z & A-Z, as well 7 as all symbols and some forms of whitespace. 8 9 Strings are arrays of characters. 10 11 Words operating on characters are in the `c:` namespace. 12 13 *CharacterOperations 14 *CharacterEncoding 15 *CharacterClassification and *CharacterCaseConversion ---------------------------------------------------------------- 0 man: characterencoding 1 2 In Konilo, I use ASCII encoding. This is a valid subset of UTF8, 3 but I have not written words for processing multibyte UTF8 char- 4 acters. 5 6 A table of the ASCII characters can be displayed by loading the 7 (tools:ascii-table) blocks and running `ascii-table`. 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: characteroperations 1 2 The basic Konilo system provides a small number of words for 3 working with characters. 4 5 To push a character to the stack, use the `$` sigil. E.g., `$P` 6 would push the ASCII code for "P". 7 8 You can check the case of a character with +c:uppercase? or 9 +c:lowercase? . Changing the case is done with +c:to-upper and 10 +c:to-lower . 11 12 Reading characters is done with `c:get`, and display of them 13 uses `c:put`. And finally there is `c:t-s`, which returns a 14 string with a single character. 15 ---------------------------------------------------------------- 0 man: characterclassification 1 2 Konilo's standard library provides a variety of additional words 3 to aid in classifying characters. 4 5 Some of these include: 6 7 c:consonant? c:vowel? c:letter? c:digit? 8 c:whitespace? c:visible? 9 10 There are also inverse forms of these available by adding a `-` 11 after the `c:`. 12 13 14 15 ---------------------------------------------------------------- 0 man: charactercaseconversion 1 2 The base system includes `c:to-upper` and `c:to-lower`. In the 3 standard library one more word, `c:toggle-case` is added. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Variables: Overview & Creation 1 2 Variables are simple containers for values. Each variable can 3 hold a single value (number, pointer, etc). 4 5 To create a variable, use `var` or `var-n`. When using `var`, 6 the variable will have a default value set to zero. With 7 `var-n`, the initial value is taken from the stack. 8 9 Example: 10 11 'Flag var 12 #600 'Sum var-n 13 14 15 ---------------------------------------------------------------- 0 Variables: Accessing & Updating 1 2 You can obtain a stored value by getting a pointer to a variable 3 and using `fetch`. Or, for a more compact approach, use the `@` 4 sigil. 5 6 For updating a variable, use a pointer and `store` or the `!` 7 sigil. 8 9 Examples: 10 11 &Flag fetch 12 @Flag 13 14 #600 !Flag 15 #-14 &Flag store ---------------------------------------------------------------- 0 Variables: Additional Operations 1 2 Konilo also provides words for incrementing or decrementing 3 a variable. These are `v:inc` and `v:dec`. 4 5 Examples: 6 7 &Flag v:inc 8 &Flag v:dec 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Combinators 1 2 Words that operate on quotations (or more generally, pointers) 3 are called "combinators". In RetroForth there are many of 4 these. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Combinators: Conditional Execution 1 2 For conditional execution, RetroForth provides three basic 3 combinators: `choose`, `if`, and `-if`. 4 5 `choose` executes one of two quotes based on a flag. E.g., 6 7 #200 #100 eq? [ 'Match! ] [ 'Nope ] choose s:put 8 9 `if` executes a quote if a flag passed is true. E.g., 10 11 #100 #100 eq? [ 'Match! s:put ] if 12 13 `-if` executes a quote if the flag passed is false. E.g., 14 15 #100 #200 eq? [ 'No_Match! s:put ] -if ---------------------------------------------------------------- 0 Combinators: Loops 1 2 RetroForth uses combinators for loops. The basic system provides 3 five: `forever`, `times`, `indexed-times`, `until`, and `while`. 4 5 `forever` runs a quotation repeatedly, with no end. An example: 6 7 [ 'Oops! s:put nl ] forever 8 9 `times` and `indexed-times` take a count and a quote. Both run 10 the quote the specified number of times. If using the indexed 11 version, you can access the loop index via `I`. 12 13 #100 [ I n:put sp ] indexed-times 14 #25 [ 'Loops_are_fun s:put nl ] times 15 ---------------------------------------------------------------- 0 Combinators: Loops 1 2 `until` and `while` take quotes which return a flag. With 3 the `until` loop, it will run the quote repeatedly until this 4 flag is true. For `while`, it does so until the flag is false. 5 6 #100 [ dup n:put sp n:dec dup n:zero? ] until drop 7 8 #0 [ dup n:put sp n:inc dup #100 -eq? ] while drop 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Combinators: Data Flow 1 2 RetroForth also uses combinators for operations on values on 3 the data stack. 4 5 `dip` temporarily removes a value while executing a quote and 6 restores it after the quotation returns. 7 8 #1 #2 [ n:put ] dip n:put 9 10 `sip` is similar to `dip`, but leaves a copy of the value on 11 the stack. 12 13 #1 #2 [ n:put ] sip n:put n:put 14 15 ---------------------------------------------------------------- 0 Combinators: Data Flow (cont.) 1 2 For those with experience in traditional Forth, `dip` and `sip` 3 are similar to `>r ... r>` and `dup >r ... r>`. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Creating Words 1 2 Functions (called words) begin with a : sigil and end with a 3 `;`. Anything in between the name and the `;` form the word 4 definition. 5 6 An example: 7 8 :hello #100 n:put nl ; 9 10 This creates a new word ("hello") that will push 100 to the 11 stack, display it, then display a new line. 12 13 14 15 ---------------------------------------------------------------- 0 Quotations 1 2 A concept used heavily in Konilo is quotations. These are 3 anonymous blocks of code. In Konilo these are passed to words 4 which handle various actions like conditional execution and 5 loops. 6 7 A quote starts with a `[` and ends with `]`. 8 9 An example: 10 11 #100 #200 -eq? [ 'Not_equal! s:put nl ] if 12 13 Quotes may be nested. 14 15 ---------------------------------------------------------------- 0 Customizing the Startup 1 2 On startup the Konilo image will search for and, if found, run 3 a word named `startup`. By default this is defined to run the 4 `prelude` word. This will load blocks 1 and 2, and if they start 5 with a (, run the code in them. 6 7 The default blocks as I provide them will load various extras 8 like the (std) library and some programs (this is done in block 9 1) and then setup various settings like the terminal height and 10 width. The settings are done in block 2. 11 12 So to customize the startup process you have two basic options: 13 14 - write a new `startup` and save a custom image 15 - craft a custom set of startup blocks ---------------------------------------------------------------- 0 Customizing the Startup : Blocks 1 & 2 1 2 This is the preferable way to do customizations as it keeps the 3 image clean and in a known working state. 4 5 When loading blocks there is an obstacle. Konilo has a single 6 block buffer, so you can't just run another one while there is 7 still code waiting to be run in the current one. Loading another 8 will just overwrite the current buffer, leading to execution of 9 whatever remains after the load. 10 11 Instead, wrap the loads in a quotation, then have a `call` as 12 the last item in the block. The `call` should be at the end of 13 the last line. 14 15 The default blocks are setup this way. ---------------------------------------------------------------- 0 Customizing the Startup : Block 1 : Loading Extensions 1 2 I prefer to use block 1 to load any vocabularies I'd like to 3 keep on hand. For me this will include the (std) standard libra- 4 ry, (termina), and a few tools like (tools/describe), (nonix), 5 and (tools/catalogue). 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Customizing the Startup : Block 2 : Local Configuration 1 2 (termina) programs need to know some information about the local 3 screen size. I set this up in block 2. 4 5 I also like to have block 2 display a greeting block (0) or, for 6 specially purposed machines, run the main code for a program. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 Customizing the Startup : The `startup` Word 1 2 The other path to customizing the system is to create a custom 3 image with a new `startup` word. 4 5 To do this you will need an ilo with support for `rom:save`. The 6 standard C implementation supports this, but you should check 7 the source for your chosen one to make sure it's implemented. 8 9 To use this path, define a new `startup` and then run `rom:save` 10 11 E.g., for an image that displays "Hello World" and exits: 12 13 :startup (-) 'Hello_World s:put nl bye ; 14 rom:save 15 ---------------------------------------------------------------- 0 Loading Block Sets : Basics 1 2 Konilo provides `needs` to load sets of blocks. For this, start 3 the title line in each block with the same comment (the name of 4 the block set), then pass this to `needs`. 5 6 '(kohure) needs 7 8 This would load all blocks (in numeric order) that have (kohure) 9 as the first word in their title line. 10 11 It's probable that you will have block sets that need words in 12 other sets. While you can load the dependencies manually, it may 13 be better to use a load block. 14 15 ---------------------------------------------------------------- 0 Loading Block Sets : Load Blocks and * 1 2 To load a block and any dependencies, Konilo provides a word, 3 `*`, which parses for the name of a load block. This is just a 4 block with a specific title format that contains a list of words 5 needed to load dependencies. For instance, consider: 6 7 0 (LOAD:game:pig) 8 1 9 2 '(dusk:rng) needs '(dusk:dice) needs '(game:pig) needs 10 11 This can be loaded with: 12 13 * game:pig 14 15 ---------------------------------------------------------------- 0 man: termina 1 2 The basic Konilo system only needs a simple serial terminal or 3 line printer + keyboard. But these are uncommon in the modern 4 world. Konilo provides a vocabulary named (termina) that adds a 5 variety of words for dealing with terminals that support a small 6 subset of the standard DEC escape sequences. 7 8 *LoadingTermina *TerminaConcepts 9 *TerminaColorAttributes *SampleTerminaProgram 10 *TerminaCursorPosition 11 12 13 14 15 ---------------------------------------------------------------- 0 man: terminaconfiguration 1 2 To make use of (termina), you will need to provide some basic 3 information about your terminal. I recommend doing this in your 4 startup blocks. 5 6 - set `ti:width` to the number of columns in your terminal 7 - set `ti:height` to the number of rows in your terminal 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: terminacursorpositioning 1 2 A number of words are provided to move the cursor around. 3 4 vt:home Move the cursor to the top left corner 5 vt:row,col Move the cursor to the provided row & column 6 vt:up Move the cursor up one row 7 vt:down Move the cursor down one row 8 vt:left Move the cursor left one column 9 vt:right Move the cursor right one column 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: terminaclearingthescreen 1 2 To clear the screen, (termina) provides `vt:clear`. 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: terminacolors 1 2 If your terminal supports colors you can make use of a variety 3 of color words. 4 5 vt:reset Reset to the default colors 6 fg:black Set the foreground color to black 7 fg:red Set the foreground color to red 8 fg:green Set the foreground color to green 9 fg:yellow Set the foreground color to yellow 10 fg:blue Set the foreground color to blue 11 fg:magenta Set the foreground color to magenta 12 fg:cyan Set the foreground color to cyan 13 fg:white Set the foreground color to white 14 15 You can replace `fg` with `bg` to set the background color. ---------------------------------------------------------------- 0 man: textualuserinterface 1 2 Based on the core (termina) vocabulary, I also provide a set of 3 words for creating textual user interfaces. 4 5 The model used here has the user provide three functions. One 6 sets up a 'hints' area, one sets up key handlers, and one is 7 the display. The `ti:application` word calls the hints & key 8 handler setup, then runs a loop, calling the display word and 9 then displaying the 'hints' below it. It will then read a key 10 and process it. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuihints 1 2 The 'hints' area is displayed after the display code is run. It 3 will show key labels 0 - 9, along with text descriptions for 4 each. 5 6 Your code will need to provide a word or quote that sets up any 7 desired hints. An example: 8 9 [ 'Quit #0 ti:add-hint 10 'Search #1 ti:add-hint ] 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuikeyactions 1 2 Your code will need to provide a word or quote that sets up 3 actions for each key. 4 5 An example: 6 7 [ &ti:done $0 ti:set-action 8 [ bye ] $q ti:set-action ] 9 10 For consistency, I recommend setting '0' as the key to exit the 11 TUI program. 12 13 14 15 ---------------------------------------------------------------- 0 man: tuidisplay 1 2 You will need to provide a word to display whatever your program 3 needs. (termina) will run `vt:home` to move the cursor before 4 calling your display word, but if you may wish to use `vt:clear` 5 in your word. 6 7 8 (termina) doesn't really provide any limits on the display word, 9 but will position the cursor three lines above the bottom of the 10 terminal before displaying the hints area. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuiexample 1 2 . This implements a tiny block reader using `list#` as the 3 . display. 4 5 :reader:hints (-) 6 'Prev #1 ti:add-hint 'Next #2 ti:add-hint 7 'Quit #0 ti:add-hint ; 8 :reader:keys (-) 9 &prev $1 ti:set-action &next $2 ti:set-action 10 &ti:done $0 ti:set-action ; 11 :reader (-) 12 [ &reader:keys &reader:hints &list# ] ti:application ; 13 14 15 ---------------------------------------------------------------- 0 man: tuihelp 1 2 It's quite possible that your program will use keys other than 3 0-9 for actions. The TUI words provide a `ti:help` that displays 4 a block with help text for your program. To use this, bind a 5 quote with the block number and a call to `ti:help` to a key. I 6 like to use '?' for this. 7 8 An example: 9 10 [ #0 ti:help ] $? ti:set-action 11 12 Note that since this displays a block, if your program was using 13 the block buffer you will need to save and restore the contents 14 before calling `ti:help`. 15 ---------------------------------------------------------------- 0 man: kohure 1 2 Kohure is a small program for exploring and editing memory. It 3 has a (termina) TUI interface and can be loaded by running: 4 5 '(kohure) needs 6 7 To start it, run `kohure`. 8 9 *KohureInterface 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: kohureinterface 1 2 Kohure will display four columns of information. On the left is 3 the first address for the line being displayed. This is followed 4 by a disassembly of three memory cells, then the contents of the 5 cells as numeric data. And the last column is either a . or the 6 ASCII character each cell corresponds to. 7 8 As with all (termina) programs, a list of hot keys is displayed 9 below the output. 10 11 *KohureNavigation 12 *KohureEditing 13 *KohureUsageExample 14 15 ---------------------------------------------------------------- 0 man: kohurenavigation 1 2 You can move to the previous set of cells by using `1` or the 3 next using `2`. 4 5 To jump to the screen containing a particular address, enter `4` 6 followed by the address. E.g., to jump to 20,123 enter `420123`. 7 8 If you want to jump to the start of a word, you can use the leap 9 function. Enter `9` followed by the name of the word. E.g., to 10 go to the start of `s:put`, enter `9s:put`. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: kohureediting 1 2 Kohure provides two functions for altering memory. You can store 3 raw values using `8` or store an assembled instruction bundle 4 using `4`. 5 6 To store a value in memory, enter `8`, the address, a space, and 7 then the value to store. For instance, to store `1012` at cell 8 50,000: 9 10 850000 1012 11 12 Assembly is similar. Enter the `3`, the address, a space, and 13 then the instructions. They will be assembled with Pali and the 14 assembled bundle stored at the address. 15 ---------------------------------------------------------------- 0 man: kohureusageexample 1 2 As an example, this would create an anonymous function at 50,000 3 which adds 101 and 6, returning the value on the stack. 4 5 350,000 liliadre 6 850,001 101 7 850,002 6 8 9 You can test this by running it. Exit Kohure, then enter: 10 11 #50,000 call n:put nl 12 13 14 15 ---------------------------------------------------------------- 0 man: catalogue 1 2 *Konilo includes +titles to generate a list of block titles in 3 the *listener. This is useful, but on systems with a large set 4 of blocks can be difficult to read as the titles scroll by. 5 6 To provide better discoverability and use of the blocks, Konilo 7 also includes +catalogue. This is a *termina based browser which 8 lists the blocks in pages of 16 blocks, with easy access to view 9 or editing the blocks using *Tuhi. 10 11 *StartingCatalogue 12 *NavigatingWithCatalogue 13 *EditingBlocks 14 15 ---------------------------------------------------------------- 0 man: startingcatalogue 1 2 *Catalogue is part of the standard block set, so all you need 3 to do is enter +catalogue at the *listener to start it: 4 5 catalogue 6 7 (You can also run it via +catalog if you prefer) 8 9 *CatalogueInterface 10 *CatalogueViewOrEdit 11 12 13 14 15 ---------------------------------------------------------------- 0 man: catalogueinterface 1 2 Catalogue will present a three column display. On the left is a 3 series of letters which represent the titles on display. On the 4 right is the block number. And in the middle are the actual ti- 5 tle lines for each block. 6 7 A series of keyboard shortcuts are displayed at below this. 8 9 The display shows a 'page' of sixteen blocks. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: cataloguevieworedit 1 2 To display a block you can use option `3` followed by the letter 3 corresponding to the desired block. Catalogue will then display 4 it on screen and wait for you to enter `x`. 5 6 To edit a block, just enter the letter corresponding to the line 7 Catalogue will start a block editor on the block. 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuhi 1 2 Konilo includes a small, line oriented block editor as part of 3 the base system. This is very useful (and is what I use for most 4 of my writing), but there is room for more visual editors. For 5 this, Konilo include an editor named Tuhi. 6 7 A default system will have this loaded, but if you don't load it 8 in yours, run this to get it: 9 10 '(tuhi) needs 11 12 Note that you may need to load (termina) first. 13 14 *TuhiConcepts, *TuhiInterface, *UsingTuhi 15 ---------------------------------------------------------------- 0 man: tuhiconcepts 1 2 Like the *BasicEditor, *Tuhi is a line oriented editor. 3 4 Edits operate on entire lines, there is no provided facility for 5 replacing only a small part of the line. While this can be a 6 minor annoyance, it's quite workable in practice. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuhiinterface 1 2 *Tuhi will display the current block contents above a set of 3 keyboard shortcuts for various actions. 4 5 On the left of each line is a single letter. This is the line 6 identifier. 7 8 Tuhi provides one notable feature lacking in the basic editor: 9 optional support for syntax highlighting. To use this, ensure 10 the +tuhi:cfg/syntax variable is set to a non-zero value. This 11 can be toggled from within Tuhi. 12 13 When active, if the block starts with a '(', Tuhi will attempt 14 to display it as source code, with different token types being 15 colored. ---------------------------------------------------------------- 0 man: usingtuhi 1 2 To replace a line, enter the line identifer, then the new text 3 for the line. For example, to replace line 'd' with 'hello', 4 type `dhello` and press enter. 5 6 A number of additional editing commands are available. A single 7 line buffer is provided for cut/copy/paste operations. To use 8 this, you could enter `Xh` to cut line 'h' into the buffer and 9 `Vc` to paste it in line 'c'. Use `C` instead of `X` to copy 10 rather than cut the line. 11 12 Indenting a line can be done with `]` or unindenting with `[`. 13 14 To erase the entire block, enter `N`. 15 ---------------------------------------------------------------- 0 man: tuhisaveandload 1 2 Tuhi binds `6` to save the block and `7` to reload it from the 3 block storage. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuhinavigation 1 2 Tuhi provides a few functions for moving through the blocks. 3 4 The first of these are moving to the previous (`1`) and next 5 (`2`) blocks. 6 7 You can jump to a specific block by entering `4` followed by 8 the block number. E.g., to jump to block '1231', do: 9 10 41231 11 12 Tuhi also provides a "leap" function via `9`. To use this, 13 enter `9` followed by the start of the block title. 14 15 9(tuhi) ---------------------------------------------------------------- 0 man: tuhihelp 1 2 Tuhi has a help screen bound to `?`. Enter this to see a summary 3 of the various functions it provides. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: tuhilistsyntax 1 2 If you are using the basic editor, it may be useful to look at 3 a block with syntax highlighting. Instead of bringing up Tuhi, 4 you can use `list:syntax` to display the block using Tuhi's 5 block display code. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: hypertext 1 2 The *manual is written using *HyperText. This is a *TextFormat 3 providing a means of connecting various pieces via links (marked 4 in the text by a leading * character) 5 6 A secondary set of links to *Glossary entries is provided by use 7 of the + character. 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: glossary 1 2 The Glossary is a collection of data on the *words provided by 3 *Konilo. Within the *Manual, references to the Glossary are 4 given a + prefix. 5 6 A typical Glossary entry will have the word name, stack summary 7 and a description. They may also include a small example. 8 9 Glossary blocks have a title of Glossary: WordName 10 11 The basic Konilo system includes Glossary entries for all words 12 in the *ilo.rom and the *StartupBlocks. I encourage you to add 13 your own words to it as well. 14 15 ---------------------------------------------------------------- 0 man: building 1 2 *ilo has been implemented in many languagiues. I provide some 3 brief instructions on building these. 4 5 C: *Build:C 6 C++: *Build:cxx 7 C#: *Build:csharp 8 D: *Build:D 9 Kotlin: *Build:Kotlin 10 Nim: *Build:Nim 11 Rust: *Build:Rust 12 Swift: *Build:Swift 13 14 15 ---------------------------------------------------------------- 0 man: ilo 1 2 ilo is a *VirtualComputer. It provides a *portable platform on 3 which *Konilo (and other programs) can run. Moving these to a 4 new host requires only porting the ilo computer. 5 6 ilo has been implemented in many languages. These include 7 assembly (x86-64 & ARM), C, C#, C++, D, Go, Hare, Kotlin, LISP, 8 Lua, Nim, Python, Rust, Swift, and TypeScript. It has been run 9 on a wide variety of host systems, including some ARM and ESP32 10 boards. 11 12 Topics 13 -------------------------------------- 14 *iloArchitecture *iloDevices 15 *iloInstructions *iloImplementations ---------------------------------------------------------------- 0 man: konilos 1 2 See *Konilo 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: iloarchitecture 1 2 *ilo implements a minimal instruction set computer design, with 3 two stacks, a small pool of RAM, terminal interface, and block 4 storage. 5 6 Some implementations add additional devices. 7 8 *iloConstraints 9 *iloInstructions 10 *iloDevices 11 *StackComputing 12 13 14 15 ---------------------------------------------------------------- 0 man: iloconstraints 1 2 *ilo is designed to be small enough that it can be easily 3 implemented and understood by a single programmer. 4 5 +---------------+-----------------------+ 6 | Item | Size | 7 +===============+=======================+ 8 | memory | 65,536 cells | 9 | data stack | 32 numbers | 10 | address stack | 256 numbers | 11 | cell | 32-bit signed integer | 12 | min value | -2,147,483,647 | 13 | max value | 2,147,483,646 | 14 +---------------+-----------------------+ 15 ---------------------------------------------------------------- 0 man: iloinstructions 1 2 Opode Instruction Names Data Stack Effects 3 ===== ================= ==================================== 4 00-05 .. li du dr sw pu - -n n-nn n- nm-mn n- 5 06-11 po ju ca cc cj re -n a- a- fa- fa- - 6 12-17 eq ne lt gt fe st nn-f nn-f nn-f nn-f a-n na- 7 18-23 ad su mu di an or nn-n nn-n nn-n nn-nn nn-n nn-n 8 24-29 xo sl sr cp cy io nn-n nn-n nn-n nnn- nnn- n- 9 ===== ================= ==================================== 10 11 *ilo has 30 instructions. A brief reference to these is shown 12 in the above table. Detailed information is also available; see 13 *iloDetailedInstructions. 14 15 Four instructionsa are packed into an *iloInstructionBundle ---------------------------------------------------------------- 0 man: ilodetailedinstructions 1 2 *iloInstructions00-05 3 *iloInstructions06-11 4 *iloInstructions12-17 5 *iloInstructions18-23 6 *iloInstructions24-29 7 8 The above links will provide more details on the individual *ilo 9 instructions. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: iloinstructions00-05 1 2 +----+----+--------+-------------------------------------------+ 3 | Op | Nm | Stack | Description | 4 +====+====+========+===========================================+ 5 | 00 | .. | - | non-op | 6 | 01 | li | -n | push value in following cell to stack | 7 | 02 | du | n-nn | duplicate top stack item | 8 | 03 | dr | n- | discard top stack item | 9 | 04 | sw | ab-ba | swap top two stack items | 10 | 05 | pu | n- | move top stack item to address stack | 11 +----+----+--------+-------------------------------------------+ 12 13 More at *iloDetailedInstructions 14 15 ---------------------------------------------------------------- 0 man: iloinstructions06-11 1 2 +----+----+--------+-------------------------------------------+ 3 | Op | Nm | Stack | Description | 4 +====+====+========+===========================================+ 5 | 06 | po | -n | move top address stack item to data stack | 6 | 07 | ju | a- | jump to an address | 7 | 08 | ca | a- | call a function | 8 | 09 | cc | fa- | call a function if the flag is non-zero | 9 | 10 | cj | fa- | jump to a function if the flag is non-zero| 10 | 11 | re | - | return from a call or conditional call | 11 +----+----+--------+-------------------------------------------+ 12 13 More at *iloDetailedInstructions 14 15 ---------------------------------------------------------------- 0 man: iloinstructions12-17 1 2 +----+----+--------+-------------------------------------------+ 3 | Op | Nm | Stack | Description | 4 +====+====+========+===========================================+ 5 | 12 | eq | ab-f | compare two values for equality. a == b | 6 | 13 | ne | ab-f | compare two values for inequality. a != b | 7 | 14 | lt | ab-f | compare two values for less than. a < b | 8 | 15 | gt | ab-f | compare two values for greater than. a > b| 9 | 16 | fe | a-n | fetch a stored value in memory | 10 | 17 | st | na- | store a value into memory | 11 +----+----+--------+-------------------------------------------+ 12 13 More at *iloDetailedInstructions 14 15 ---------------------------------------------------------------- 0 man: iloinstructions18-23 1 2 +----+----+--------+-------------------------------------------+ 3 | Op | Nm | Stack | Description | 4 +====+====+========+===========================================+ 5 | 18 | ad | ab-c | add two numbers. a + b | 6 | 19 | su | ab-c | subtract two numbers. a - b | 7 | 20 | mu | ab-c | multiply two numbers. a * b | 8 | 21 | di | ab-cd | divide and get remainder. a % b, a / b | 9 | 22 | an | ab-c | bitwise and | 10 | 23 | or | ab-c | bitwise or | 11 +----+----+--------+-------------------------------------------+ 12 13 More at *iloDetailedInstructions 14 15 ---------------------------------------------------------------- 0 man: iloinstructions24-29 1 2 +----+----+--------+-------------------------------------------+ 3 | Op | Nm | Stack | Description | 4 +====+====+========+===========================================+ 5 | 24 | xo | ab-c | bitwise xor | 6 | 25 | sl | ab-c | shift left. a << b | 7 | 26 | sr | ab-c | shift right. a >> b | 8 | 27 | cp | sdn-f | compare two memory regions | 9 | 28 | cy | sdn- | copy memory | 10 | 29 | io | n- | perform i/o operation | 11 +----+----+--------+-------------------------------------------+ 12 13 More at *iloDetailedInstructions 14 15 ---------------------------------------------------------------- 0 man: iloinstructionbundle 1 2 *ilo allows up to four instructions to be packed into a single 3 memory location. These are processed in order. Instructions that 4 modify the instruction pointer (other than `li`) can not be 5 followed by anything other than a non-op to avoid unpredictable 6 behavior. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stackcomputing 1 2 *ilo is a *stack *computer. It provides two last in, first out 3 (LIFO) stacks. One is used to holddata being passed between 4 functions, the other holds the return addresses needed to allow 5 calling and returning from functions. 6 7 As noted by Phil Koopman in "Stack Computers: The New Wave": 8 9 From a theoretical viewpoint stacks themselves are important, 10 since stacks are the most basic and natural tool that can be 11 used in processing well structured code. 12 13 I find that learning to use a stack machine well takes time, but 14 have found that it is quite productive once one is used to it. 15 ---------------------------------------------------------------- 0 man: stack 1 2 A stack is a data structure that provides access to data in a 3 last in, first out manner. Stacks sit at the heart of *Forth, 4 and are a crucial part of the *iloArchitecture. 5 6 *StackShufflers 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: computer 1 2 A computer is a device for performing computations (or, in an 3 older sense, a person doing computations). 4 5 *ilo is a *VirtualComputer that can run on a variety of 6 *PhysicalComputer systems. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: virtualcomputer 1 2 A virtual computer is a *computer defined as a program for use 3 on a *PhysicalComputer. 4 5 Use of a virtual computer allows easier *portable computing as 6 programs running on it only require the virtual computer to be 7 updated to work on new machines. 8 9 They are also able to be simpler and cleaner to write and use. 10 11 A disadvantge is performance: virtual computers will be slow 12 compared to the physical hosts they run on. 13 14 Examples of virtual computers include *ilo, *nga, and *uxn. 15 ---------------------------------------------------------------- 0 man: physicalcomputer 1 2 A physical computer is a *computer made of hardware. 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: stackshufflers 1 2 Stack shufflers are words which alter the layout of the *stack. 3 4 Basic Basic *Combinators Queries 5 -------- ---------- ------------ -------------- 6 +dup +dup-pair +dip +depths 7 +drop +drop-pair +sip +depth/data 8 +swap +push +bi +depth/address 9 +over +pop +bi* 10 +tuck +bi@ 11 +rot +tri 12 +roll +tri* 13 +unroll +tri@ 14 +reorder 15 ---------------------------------------------------------------- 0 man: thetools 1 2 *Konilo provides a number of tools for you to use. 3 4 Standard Tools Loadable Tools 5 -------------- -------------- 6 *Listener *Kohure 7 *BasicEditor *WISP 8 *Catalogue *Wiki 9 *Tuhi 10 *REM 11 *Nonix 12 *Manual 13 14 Some *amusements are also included. 15 ---------------------------------------------------------------- 0 man: basiceditor 1 2 "Beware the Integrated Development Environments of March. Me, 3 I stick with ed(1)" - @aka_pugs@mastodon.social 4 5 The basic editor is the standard editor for *Konilo. 6 7 It's a simple, line-oriented editor for writing and reading 8 blocks in the *listener. 9 10 Topics 11 =============================================================== 12 *BasicEditorConcepts *AdvancedEditingWithBasicEditor 13 *StartingTheBasicEditor *DisplayingBlocks 14 *EditingWithTheBasicEditor 15 *RunningCodeFromTheBasicEditor ---------------------------------------------------------------- 0 man: personal 1 2 Hi! I'm Charles Childers, the developer of *Konilo and the *ilo 3 computer. 4 5 Konilo is, for me, a very personal project. While I share it 6 freely, it's intended for my use, and as such will carry many 7 eccentricities. 8 9 This starts with the *Forth. In some ways it follows traditional 10 norms: a *dictionary, two *stacks, *ThreadedCode. But there are 11 also *quotations, *sigils, and a very non-traditional set of 12 *word names. 13 14 I hope you find it interesting, and perhaps useful. 15 ---------------------------------------------------------------- 0 man: nonix 1 2 Nonix is a collection of "not unix" tools for use in *Konilo. 3 4 Over the last few decades I've become a bit accustomed to the 5 tool names from unix. Needing a few tools to copy, move, and 6 perform other operations on blocks, I decided to borrow these 7 names for my tools with similar roles. 8 9 *CopyAndMoveBlocks 10 *DeletingBlocks 11 *LocatingBlocks 12 *OptionalNonixTools 13 14 15 ---------------------------------------------------------------- 0 man: rem 1 2 REM is a visual block editor. It differs from the *BasicEditor & 3 *Tuhi by providing a movable cursor and ability to replace parts 4 of lines instead of the entire line. 5 6 The REM editor is loaded by default; start it by running +rem 7 If your blocks do not load it by default, you can load it with: 8 9 '(rem) needs 10 11 *REMConcepts, *REMInterface, *UsingREM 12 13 14 15 ---------------------------------------------------------------- 0 man: pragmatic 1 2 The *Konilo *ComputingSystem tries to be pragmatic. 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: computingsystem 1 2 *Konilo is a computing system that runs on a *VirtualComputer, 3 with the *Forth language and a bunch of useful tools. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: portable 1 2 The *Konilo *ComputingSystem is portable actross a wide variety 3 of hosts thanks to its *ilo *VirtualComputer. 4 5 Konilo has been run on a variety of machines from the last 40+ 6 years. Builds of ilo are available for machines like an 8088/DOS 7 and 68k/mac, through modern amd64 and ARM64 systems. 8 9 The use of a virtual computer allows the same system to easily 10 move between physical hosts without change. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: ilo.rom 1 2 The ilo.rom is a file containing a program for the *ilo computer 3 (the most common of which is the *Konilo *ComputingSystem). 4 5 It, along with the *ilo and *ilo.blocks, form a complete set of 6 files for the system. 7 8 All ilo implementations share the same image format, allowing 9 easy sharing of programs across various hosts. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: ilo.blocks 1 2 A file containing a set of *blocks for the *ilo computer. 3 4 The blocks collection is a major part of the *Konilo system. 5 All *ilo implementations share the same block file format, so 6 data is easily *portable across various hosts. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: sigil 1 2 See *sigils 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: forth 1 2 Forth is a *stack based language providing simplicity, 3 efficiency, and extensibility for a wide range of 4 programming adventures. 5 6 A *UniqueDialect sits at the heart of *Konilo, and allows 7 programs to be easily written, tested, and extended as needed. 8 This dialect makes extensive use of *sigils, *quotations, and 9 *combinators, and (mostly) avoids forward parsing, focusing on 10 using the stack to pass data between words. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: konilo 1 2 Konilo is a *Forth-based *ComputingSystem running on the *ilo 3 *VirtualComputer. 4 5 A full Konilo system has three parts: 6 7 - *ilo computer 8 - *ilo.rom w/Konilo system 9 - *ilo.blocks w/Konilo *blocks 10 11 See *KoniloMeaning 12 13 14 15 ---------------------------------------------------------------- 0 man: manual 1 2 This is a reference and guide to *Konilo. It's written as a 3 *wiki, using a simple *hypertext *markup format and is generally 4 topical in structure. 5 6 The manual is also a program running within Konilo. This allows 7 browsing the manual contents and editing (generally via *tuhi) 8 the contents. 9 10 *ManualInterface 11 *ManualNavigation 12 *AddingTopics 13 14 15 ---------------------------------------------------------------- 0 man: textformat 1 2 In *Konilo, most data is stored in various textual formats. 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: markup 1 2 The *manual uses a very simple structure. 3 4 The title line for the *block must be lowercase, and start with 5 the word man: followed by a space, then the page name. 6 7 Links to pages start with an *. Links to glossary entries start 8 with a +. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: languagereference 1 2 Data Types Functions & Execution Stacks 3 ----------- --------------------- --------------------- 4 *Numbers *Sigils *StackShufflers 5 *Characters *CreatingWords *DataFlowCombinators 6 *Arrays *Quotations *Stacks 7 *Strings *Combinators 8 *Pointers *Variables 9 10 Other Words Word List 11 ----------- --------------------- --------------------- 12 *Blocks *Dictionary *WordsByName 13 *Memory *Words 14 15 ---------------------------------------------------------------- 0 man: (sigil:`) 1 2 This adds a new sigil, `, which serves to allow running any 3 word during compilation. It can replace the use of immediate 4 (see the *(immediate) extension). 5 6 Example: 7 8 :test here n:put nl ; 9 .bar #1 `test #2 `test ; 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: dictionary 1 2 The dictionary is a linked list which keeps track of all the 3 *word names. See *DictionaryEntryFormat for details on the 4 fields in the entries. A +Dictionary variable holds a pointer 5 to the latest header. 6 7 I try to follow a general *NamingConvention in choosing word 8 names. 9 10 Words acting on dictionary entries are in the `d:` *namespace. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: dictionaryentryformat 1 2 Each *dictionary entry has the following format: 3 4 - link to the prior entry (0 for no priors) 5 - hash of the word name (made using +s:hash ) 6 - pointer to the start of the word 7 8 The actual word name is not saved, only a hash of it. 9 10 Words pointing to a negative address are treated as immediate. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: words 1 2 See *word 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: word 1 2 A word is a function or data structure that has been given a 3 name in the *dictionary. 4 5 *CreatingWords 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: variables 1 2 See *variable 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: variable 1 2 A variable is a *word pointing to data in memory. 3 4 *CreatingVariables 5 *AccessingVariables 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: quotations 1 2 See *quote 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: quote 1 2 A quote is an anonymous, nestable function. These are used for 3 data and flow control in *Konilo. 4 5 *CreatingQuotes 6 7 *Combinators are functions that operate on quotes (or function 8 pointers). 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: memory 1 2 Memory is the space where compiled code and data live. 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: blockeditors 1 2 Konilo includes several block editors. The minimal system has 3 the *BasicEditor, and a visual editor named *Tuhi is inclued as 4 part of the standard blocks. 5 6 A visual editor named *REM is also in the blocks, but is not 7 loaded by default. This editor is a visual, modal editor with 8 inspiration from vi. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: combinators 1 2 A combinator is a function that consumes functions as input. 3 These are grouped into three primary types: 4 5 *CompositionalCombinators 6 *ExecutionFlowCombinators 7 *DataFlowCombinators 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: compositionalcombinators 1 2 A compositional combinator takes elements from the stack and 3 returns a new quote. 4 5 +curry 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: executionflowcombinators 1 2 Execution flow *combinators execute other functions. 3 4 invocation conditional looping 5 ---------- ----------- ---------- 6 +call +choose +times 7 +jump +if +indexed-times 8 +gc +-if +while 9 +until 10 +forever 11 12 Some data types include a `for-each` form that would be classed 13 as an execution flow combinator. These include +a:for-each and 14 +s:for-each 15 ---------------------------------------------------------------- 0 man: dataflowcombinators 1 2 These *combinators exist to simplify stack usage. I prefer use 3 of these over the more primitive *StackShufflers. 4 5 preserving cleave spread apply 6 ---------- ------ ------ ----- 7 +dip +bi +bi* +bi@ 8 +sip +tri +tri* +tri@ 9 10 Preserve run code while preserving portions of the data stack 11 Cleave applies multiple quotations to a value or set of values 12 Spread applies multiple quotations to multiple values 13 Apply combinators apply a single quotation to multiple values 14 15 ---------------------------------------------------------------- 0 man: namespace 1 2 The *NamingConvention used for *Konilo *words groups them into 3 collections by use of a short namespace prefix. 4 5 Some of the common ones include: 6 7 a: *arrays 8 c: *characters 9 d: *dictionary 10 e: *BasicEditor 11 n: *numbers 12 s: *strings 13 sigil: *sigils 14 sys: system 15 v: *variables ---------------------------------------------------------------- 0 man: namingconvention 1 2 - Readability is important 3 - Be consistent 4 - Never use *sigils as the first character of a name 5 - Never use underscores in word names 6 - Use short names for indices 7 - Word names start with a `-` for "not" 8 - Words returning a flag end in ? 9 10 The word names will generally follow a form like: 11 12 [namespace:]name 13 14 Use of a *NameSpace is optional, but recommended for consist- 15 ency and to make it easier to identify related words. ---------------------------------------------------------------- 0 man: creatingvariables 1 2 To create a *variable you can use +var or +var-n 3 4 +var takes a name, and creates a variable with an initial value 5 of 0. +var-n takes an initial value and a name and creates the 6 variable with the provided initial value. 7 8 'Count var 9 #10 'Base var 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: accessingvariables 1 2 To access a *variable you can use +store and +fetch or the ! and 3 @ sigils. The & sigil will return a *pointer to it. 4 5 Updating a Variable 6 7 #16 &Base store 8 #16 !Base 9 10 Fetching a Variable 11 12 &Base fetch 13 @Base 14 15 ---------------------------------------------------------------- 0 man: creatingwords 1 2 There are two types of words: functions and data. 3 4 Functions are defined as *ColonDefinitions, with the word name 5 starting with the : sigil followed by a whitespace separated 6 list of words or data, ending with a +; 7 8 Data may be defined as a *variable, as a custom structure using 9 +d:create or via other data creation words. See *DataDefinitions 10 11 To make use of a data word, you must use the & sigil to get a 12 *pointer to it; leaving off the & sigil will cause Konilo to try 13 to run the data as if it were a function, which is likely to 14 crash your system. 15 ---------------------------------------------------------------- 0 man: pointer 1 2 A pointer is a *number that corresponds to a *memory address. 3 4 Many *words return pointers. In the *StackComments, these are 5 often indicated by `s`, `p`, or `a`. 6 7 To obtain a pointer to a word, use the & sigil: 8 9 &n:add 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: konilomeaning 1 2 The Konilo name derives from two sources. 3 4 In Toki Pona, kon refers to an essence or spirit and ilo refers 5 to a a machine or device. Hence Konilo is the spirit or essence 6 of a machine. 7 8 In Esperanto, ilo refers to a tool, and koni to knowing, so it 9 can be taken to mean a "knowing machine". 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: uniquedialect 1 2 The *Forth at the heart of Konilo is not a traditional model. As 3 with other Forth systems, it has a *dictionary of *words and two 4 *stacks. But the implementation is quite different. For example: 5 6 In Konilo, source is evaluated token by token, using *sigils to 7 guide the compiler in understanding how to work with them. 8 9 Other than sigils, Konilo makes extensive use of *quotations and 10 *combinators to implement control structures. 11 12 Konilo provides a number of vocabularies for working with data 13 like strings and arrays which are not present in traditional 14 Forth systems. 15 ---------------------------------------------------------------- 0 man: copyandmoveblocks 1 2 *Nonix provides several words for copying and moving blocks. 3 4 Copying a single block: 5 6 +cp source# dest# 7 8 Copying multiple blocks: 9 10 +xcp source# dest# number# 11 12 For move operations use +mv and +xmv instead. 13 14 See also: *DeletingBlocks 15 ---------------------------------------------------------------- 0 man: deletingblocks 1 2 You can delete the contents of a block using +rm or +xrm 3 4 Erase a block: 5 6 +rm block# 7 8 Erase multiple blocks: 9 10 +xrm first# number# 11 12 13 14 15 ---------------------------------------------------------------- 0 man: locatingblocks 1 2 *Nonix provides +locate for helping to find blocks. This reads a 3 string with the first part of the block title and then scans all 4 blocks, displaying a list of the ones which match the provided 5 string. 6 7 Example: 8 9 +locate (std) 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: optionalnonixtools 1 2 If you load the (opt:nonix) blocks, several additional things 3 will be available. These include +df to get a summary of block 4 usage, +block-map for generating a visual map of used vs free 5 blocks, and +blocks-containing: which searches the title line 6 for a string (this differs from +locate in that it searches the 7 full title as opposed to just the start of the title). 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: kohure 1 2 Kohure is an optional tool for browsing memory. 3 4 *StartingKohure 5 *KohureDisplay 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: startingkohure 1 2 To load *Kohure, you can use the *AsteriskLoader: 3 4 * kohure 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: kohuredisplay 1 2 The display in *Kohure shows seven columns. From left to right 3 these are: 4 5 (1) Starting address 6 (3) Instructions 7 (3) Raw values 8 (1) ASCII symbols 9 10 Each row has three memory cells displayed in three different 11 forms. This can be used to help identify compiled code or data. 12 13 14 15 ---------------------------------------------------------------- 0 man: asteriskloader 1 2 While you can load a block set with +needs a second option is 3 available. *Konilo provides +* which parses for a "load block" 4 name, and then runs the code in this. 5 6 +* is useful since +needs can not be nested. A load block wraps 7 the various dependencies in a *quotation, which is then run. By 8 doing this, the +needs are run sequentially, not nested. 9 10 *WritingLoadBlocks 11 *UsingAsteriskLoader 12 13 14 15 ---------------------------------------------------------------- 0 man: writingloadblocks 1 2 Load blocks for *AsteriskLoader are given a title of the form: 3 4 (LOAD:name) 5 6 +* will parse for a name, construct the above form, then load 7 the block. The contents are wrapped into a *quotation and then 8 run. 9 10 An example: 11 12 (LOAD:sample) 13 '(opt:s) needs 14 '(math) needs 15 '(sample) needs ---------------------------------------------------------------- 0 man: usingasteriskloader 1 2 The *AsteriskLoader is invoked via +* 3 4 Enter a * followed by a space, then the name of the load block. 5 As an example, to load game:pig do: 6 7 * game:pig 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: wisp 1 2 WISP is "Writing In Small Pieces", a small tool for writing and 3 browsing a personal log, with one block per day. 4 5 *LoadingWISP 6 *WISPDisplay 7 *AddingEntriesToWISP 8 *NavigatingWISP 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: wiki 1 2 The wiki is a *hypertext system for creating a *personal store 3 of knowledge. It shares a common core with this *manual, but 4 uses a different data set. 5 6 *LoadingWiki 7 *WikiDisplay 8 *WikiNavigation 9 *WritingWikiPages 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: loadingwisp 1 2 *WISP can be loaded with the *AsteriskLoader: 3 4 * wisp 5 6 To start the WISP program after loading, just enter. 7 8 wisp 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: loadingwiki 1 2 The *wiki can be loaded with the *AsteriskLoader: 3 4 * wiki 5 6 To start the wiki browser, enter: 7 8 wiki:browse 9 10 To look up a wiki page in the *listener, do: 11 12 wiki pagename 13 14 15 ---------------------------------------------------------------- 0 man: wispdisplay 1 2 The display for *WISP is similar to the *Tuhi editor. The entry 3 is shown, with the date in red and the text in cyan. A set of 4 quick actions is shown below this. 5 6 Pressing `3` will jump to the most recent entry. 7 8 Pressing `4` will start a new entry in *Tuhi. 9 10 Pressing `8` will let you edit the current entry in Tuhi. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: navigatingwisp 1 2 *WISP only provides a few limited options for navigation. 3 4 `1` will move you to the previous entry. 5 `2` will move you to the next entry. 6 `3` will bring you to the most recent entry. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: addingentriestowisp 1 2 To add a new entry, start *WISP and press `4`. The *tuhi editor 3 will start on the next available block. 4 5 Entries should be formatted with the date in the title line, and 6 the rest of the block is the days entry. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: manualinterface 1 2 The manual browser presents a simple terminal interface to the 3 embedded documentation. The top portion of the screen is used 4 to show a *block, with some shortcuts listed below. 5 6 The shortcuts are: 7 8 1 - Return to the start of the manual 9 3 - Start the *Tuhi editor on an empty block 10 8 - Start the Tuhi editor on the current block 11 12 To load a topic (marked with a leading *), enter the * and topic 13 name. Then hit enter or space. Glossary entries (marked with a 14 leading +) can be loaded the same way. 15 ---------------------------------------------------------------- 0 man: manualnavigation 1 2 As with much of the *Konilo system, the *manual is written as 3 an interactive, terminal-based program. The *ManualInterface 4 displays a block, containing a manual topic, and has a few 5 functions for moving to new topics. 6 7 - Press `1` to load the *Start page. 8 - Enter * followed by a link name to display that page. 9 - Enter + followed by a word name to lookup that word in the 10 *glossary. 11 - Use [ and ] to move between pages 12 13 The manual does not provide a history function. To go back you 14 will need to enter the * page name of the prior page. Page names 15 are case insensitive; glossary names are not. ---------------------------------------------------------------- 0 man: amusements 1 2 *Konilo includes a few programs for amusement purposes. 3 4 (game:pig) 5 a small dice game 6 7 (game:conways-life) 8 conway's game of life 9 10 (1d-cellular-automata 11 a simple demonstration of 1D cellular automata 12 13 (jmf:mandelbrot) 14 a mandelbrot viewer 15 ---------------------------------------------------------------- 0 man: stringtrimming 1 2 +s:trim-left 3 +s:trim-right 4 +s:trim 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: basicmath 1 2 *Konilo provides a number of basic math operations. 3 4 Addition: +n:add 5 Subtraction: +n:sub 6 Multiplication: +n:mul 7 Division: +n:div 8 Remainder: +n:mod 9 Increment: +n:inc 10 Decrement: +n:dec 11 Negation: +n:negate 12 Absolution: +n:abs 13 14 15 ---------------------------------------------------------------- 0 man: numbercomparisons 1 2 +eq? +-eq? +lt? +gt? 3 +lteq? +gteq? 4 +n:zero? +n:-zero? 5 +n:between? 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: addingtopics 1 2 New topics can be added to the *manual. You can use `3` from the 3 browser to start the *Tuhi editor on a new block. 4 5 You then need to set the block title to `man:`, a space, and the 6 topic name. The entire title line must be lowercase. 7 8 Each topic is limited to a single block. Break up larger topics, 9 and use the *markup to add links to the subtopics. 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: listenerandbuffering 1 2 The *listener is intended to interpret your code as you type. 3 But most Unix-like systems will have the terminal set to a line 4 buffered model by default. On these, interpretation does not 5 occur until enter is pressed. To work around this, you have two 6 options: 7 8 - use an *ilo which changes the terminal mode. Some, like the 9 mult/ilo (vm/milo.c) wil do this, but most defer to the host. 10 - use host tools to change the mode. E.g., on Linux and BSD you 11 can use stty(1) to do this: 12 13 stty cbreak; ./ilo; stty -cbreak 14 15 ---------------------------------------------------------------- 0 man: pointers 1 2 A pointer is a number which points to a *memory address. In 3 Konilo these are returned by many words, including much of the 4 *arrays and *strings vocabularies, creation of *quotations, and 5 the & *sigil. 6 7 *Combinators operate on pointers. 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: pointer 1 2 See *pointers 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: colondefintions 1 2 Most *words are defined as colon definitions. These follow a 3 form like: 4 5 :name ... definition ... ; 6 7 The : *sigil creates a word with the provided name and adds it 8 to the *dictionary. It then starts the compilation process. The 9 compiler reads in code, just like interpretations, but adds the 10 words to the new definition. The +; word ends the definition 11 and turns off the compiler. 12 13 14 15 ---------------------------------------------------------------- 0 man: datadefinitions 1 2 To define a custom data structure, you can use +d:create. 3 4 'name d:create .... code to lay down data .... 5 6 E.g., to make an array with three values you could do: 7 8 'MyArray d:create #3 comma #100 comma #200 comma #300 comma 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: loadableextensions 1 2 *Konilo includes a variety of useful extensions that are not 3 loaded by the default system. 4 5 Compiler Data & Utility Host-Interface 6 ------------ ------------------------ -------------- 7 *(immediate) *(vars) *(s:format) *(crc:drawing) 8 *(does) *(const) *(s:dedup) *(teensy4.1) 9 *(if;) *(enum) *(dusk:rng) *(x86) 10 *(case) *(array|) *(dusk:dice) 11 *(does) *(short) *(crc:turtle) 12 *(sigil:`) *(math) *(sigil:") 13 *(opt:s) *(quad) 14 *(opt:n) 15 *(linked-list) ---------------------------------------------------------------- 0 man: (immediate) 1 2 The (immediate) extension adds a new word, `immediate` which 3 changes the most recent word to be run when encountered in a 4 definition, rather than having a *pointer compiled in. This is 5 useful when creating new compiler extensions or adding support 6 for new data structures. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (does) 1 2 Traditional *Forth systems have a CREATE/DOES> pairing for 3 defining a word which creates a data structure and attaches an 4 action to be used on it. This extension adds support for a 5 similar functionality using a new `does` *combinator. 6 7 As an example: 8 9 :constant (n"-) 10 s:get/token d:create comma [ fetch process-data ] does ; 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (if;) 1 2 The (if;) extensions adds a *combinator, `if;`, which acts 3 like +if but also exits the caller if the passed condition 4 is true (non-zero). 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (case;) 1 2 (case;) adds a new *combinator, `case`, that provides a more 3 concise way to handle multiple checks/execution. It requires 4 the *(if;) extension to be loaded first. 5 6 It replaces this syntax: 7 8 dup eq? if; 9 10 With: 11 12 case 13 14 15 ---------------------------------------------------------------- 0 man: (const) 1 2 *Konilo does not provide anything directly like CONSTANT in 3 traditional *Forth. Rather, I just write words which return 4 a value. This extension adds a `const` word, which can be used 5 like this: 6 7 #100 'NAME const 8 9 There is also an `s:const` form included for use with strings. 10 11 This does not make constants that are directly runnable. To use 12 them, you will need to use the & *sigil with them. E.g., 13 14 #100 'name const 15 &name n:put ---------------------------------------------------------------- 0 man: (vars) 1 2 (vars) adds two new words for creating multiple *variables. 3 4 The first, `vars` is used like: 5 6 #3 vars A B C 7 8 It takes in a count, then parses for names and creates the 9 variables with the provided names. 10 11 The second is `vars|`. This is used like: 12 13 vars| A B C | 14 15 It parses for names, creates them until a | is reached. ---------------------------------------------------------------- 0 man: (enum) 1 2 (enum) adds a word, `enum|`, which takes an initial value and 3 then enters a parse loop, creating constants with the value and 4 the parsed name. The value is incremented after each creation. 5 Parsing ends when | is encountered. E.g., 6 7 #5 enum| A B C D E F | 8 9 To obtain the value, use the name with the & *sigil. E.g., 10 11 &A 12 13 14 15 ---------------------------------------------------------------- 0 man: (short) 1 2 The (short) vocabulary adds support for 16-bit integer math. 3 The functionality is a few basic math operations: 4 5 short:add 6 short:sub 7 short:mul 8 short:div 9 short:mod 10 11 It also provides a short:MIN and short:MAX constant (as words) 12 13 14 15 ---------------------------------------------------------------- 0 man: (array|) 1 2 This extension adds a word, `array|`, which creates new numeric 3 *arrays. It is used like this: 4 5 array| 1100 45 33 78 96 12 -154 | 6 7 It will parse for numbers, ending when | is encountered. The 8 resulting array is created in *memory at +here 9 10 This can not be used to create arrays inside a *ColonDefinition 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (math) 1 2 This is Arland's (math) vocabulary, adding a variety of math 3 words. These include a random number generator, some fixed 4 point support, and sin/cos/tan. 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (opt:s) 1 2 This expands the `s:` *NameSpace to include new words. The 3 new words include: 4 5 Formatting 6 ----------- 7 s:ljust 8 s:rjust 9 s:pad/left 10 s:pad/right 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (opt:n) 1 2 This expands the `n:` *NameSpace to add new words. These 3 include: 4 5 Counting Bits 6 -------------- 7 n:count-bits 8 n:digits 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (dusk:rng) 1 2 A three seed random number generator by Arland. 3 4 Words 5 ------------------ 6 set-seeds (abc-) 7 get-seeds (-abc) 8 rng (-n) 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (dusk:dice) 1 2 This is a small vocabulary for rolling dice. It uses the 3 *(dusk:rng) words. 4 5 Vocabulary 6 ------------------------------ 7 dice:Sides Variable. 8 dice:Relative Variable. 9 dice:roll (-n) 10 dice:draw (n-) 11 12 13 14 15 ---------------------------------------------------------------- 0 man: (s:format) 1 2 This adds `s:format` for creating strings from a template. The 3 format string can have a mix of several actions, each of which 4 is preceeded by a %. The formatters are: 5 6 Action Usage 7 ------ ----------------------------------- 8 %n Insert a number from the stack. 9 %c Insert a character from the stack 10 %s Insert a string from the stack 11 12 An example: 13 14 #3 #2 #1 '%n+%n=%n s:format 15 ---------------------------------------------------------------- 0 man: (crc:drawing) 1 2 There are two extensions to *ilo providing access to a graphical 3 display. This vocabulary is for using the simpler of the two. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: iloimplementations 1 2 *ilo has been implemented in many languages. 3 4 +--------+-------------+-------+ 5 | c | c# | c++ | 6 | d | go | hare | 7 | kotlin | lisp | lua | 8 | nim | python | rust | 9 | swift | typescript | | 10 +--------+-------------+-------+ 11 12 & amd64 + aarch64 assembly 13 14 There are some *iloVariants with additional features. 15 ---------------------------------------------------------------- 0 man: ilovariants 1 2 In addition to the standard *iloImplementations, a few variants 3 exist with non-standard additions. 4 5 *multIlo supports multiple *ilo systems under a single process. 6 7 *iloX86 runs directly on 32-bit x86 systems 8 9 *iloTeensy runs on the Teensy4.1 10 11 ilo+graphics adds a simple framebuffer and limited graphics 12 support. 13 14 15 ---------------------------------------------------------------- 0 man: multilo 1 2 mult/ilo is an extended version of *ilo. It does not add new i/o 3 or instructions, but rather adds the ability to switch between 4 multiple copies of *Konilo. 5 6 *UsingMultIlo 7 *ConfiguringMultIlo 8 *multIloLimitations 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: ilox86 1 2 The *ilo computer can be run directly on 32-bit x86 hardware. In 3 this configuration, the system is started using the GRUB boot 4 loader and then ilo takes over. 5 6 It provides the basic *iloDevices, but also adds a couple of new 7 things including access to the x86 i/o ports and physical RAM. 8 This also includes variants supporting simple graphics via the 9 *(crc:drawing) extension and *multIlo support. 10 11 Topics 12 ------------------------------------------ 13 *iloX86Prerequisites *InstallingIloX86 14 *BootingIloX86 *UpdatingIloX86 15 *RunningIloX86 *iloX86Performance ---------------------------------------------------------------- 0 man: ilodevices 1 2 An *ilo computer will provide a few i/o devices. 3 4 - block storage 5 - keyboard 6 - text display 7 - ability to save an *ilo.rom (optional) 8 9 Some implementations will provide additional, host-specific 10 devices and *LoadableExtensions for using these. 11 12 Most of what I write targets only the basic ilo system and does 13 not use any optional or host-specific devices. 14 15 ---------------------------------------------------------------- 0 man: installingilox86 1 2 To install *iloX86 onto a system you will need an x86 computer, 3 a prepared boot disk, and a blank hard disk. Boot to GRUB, and 4 select the `Install or Update Blocks` option. This will present 5 three options: 6 7 (I)NSTALL or (U)PDATE BLOCKS or (A)BORT 8 9 Press I to copy the blocks to the hard disk. The blocks will be 10 copied, then you can press a key to reboot. 11 12 You can now proceed to *RunningIloX86 13 14 15 ---------------------------------------------------------------- 0 man: runningilox86 1 2 You will need a computer with the installed blocks, a prepared 3 boot disk, and some patience. 4 5 Boot the computer, and choose one of the Konilo options. (I use 6 *multilo most of the time). *ilo will start and display the 7 welcome block when ready. 8 9 At this point it's ready to use. 10 11 Tip: if you do not intend to use the blocks, you can run the 12 "Konilo (minimal)" option to load just the *ilo.rom. If 13 taking this route, only the words in that will be available 14 15 ---------------------------------------------------------------- 0 man: updatingilox86 1 2 The "Install or Update Blocks" option on the boot disk can be 3 used to update the primary system blocks (0-128) to the latest 4 set. Choosing to update will not alter blocks 1 or 2, to leave 5 your *LocalConfiguration alone. 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: ilox86prerequisites 1 2 To install or run *iloX86 you will need: 3 4 Hardware 5 ------------------------------------------ 6 x86 or amd64 compute 7 2MB RAM (4MB for *multilo) 8 PS/2 (or compatible) keyboard 9 VGA (or compatible) display 10 PATA hard drive (or SATA w/PATA emulation) 11 Bootable floppy drive 12 13 The hard drive will need to be dedicated to Konilo as it is 14 used directly for block storage. 15 ---------------------------------------------------------------- 0 man: bootingilox86 1 2 To boot *iloX86, you will need a boot disk. This will need GRUB 3 (or another multiboot compliant boot loader), the various kernel 4 images for iloX86, and an appropriately setup menu. I provide a 5 3.5" disk image with these on konilo.org 6 7 The boot process has the BIOS (or UEFI?) start GRUB, which then 8 starts the iloX86 kernel. This initializes the hardware and 9 runs an embedded copy of *ilo.rom. 10 11 Once iloX86 has loaded, the system is identical to any other 12 *ilo computer. 13 14 15 ---------------------------------------------------------------- 0 man: ilox86performance 1 2 *iloX86 is not particularly fast. This is mostly due to I/O 3 limitations. 4 5 At present, all I/O is done by using port i/o and polling. This 6 is very wasteful in CPU cycles, and places significant limits in 7 terms of performance. 8 9 As of Q1 2024 I am (slowly) looking into DMA and expanding use 10 of interrupts to help improve things, but this is not a high 11 priority project for me. 12 13 14 15 ---------------------------------------------------------------- 0 man: usingmultilo 1 2 *multIlo allows switching between multiple *ilo computers. There 3 are two primary variations, each with different key bindings. 4 5 Hosted Native 6 ------ ------- 7 Switch to Previous CTRL+p F11 8 Switch to Next CTRL+ F12 9 Jump To Session F1 - F5 10 Restart Current CTRL+c F9 11 Shutdown CTRL+a 12 13 14 15 ---------------------------------------------------------------- 0 man: configuringmultilo 1 2 Configuration of *multIlo is done by editing the source. There 3 is presently one setting that you may wish to alter. 4 5 Near the top of the milo.c source file is a #define for ILOS. 6 This is the number of sessions to support. By default it is set 7 to 5, but you can raise or lower it as desired. 8 9 If using the *iloX86 variation of multIlo, you will also need to 10 alter the iob() function to add or remove cases for the F1-Fn 11 keys for directly jumping between sessions. 12 13 14 15 ---------------------------------------------------------------- 0 man: multilolimitations 1 2 *multIlo allows switching between multiple sessions, but there 3 are a few limitations you should be aware of. 4 5 - each session has its own ram, stacks, and registers 6 - all sessions share the same *blocks 7 - all sessions use the same *ilo.rom 8 - only the active *ilo session is actually running; background 9 sessions are suspended 10 - switching sessions can only be done while the system is 11 waiting for input 12 13 14 15 ---------------------------------------------------------------- 0 man: iloteensy 1 2 A port of *ilo for the Teensy 4.1 development board. It's based 3 on the C implementation and has a few non-standard extensions. 4 5 Requirements Topics 6 ---------------------------- ------- 7 - Teensy 4.1 *BuildingIloTeensy 8 - SD Card with: *iloTeensyExtensions 9 - ilo.rom 10 - ilo.blocks 11 - serial terminal interface 12 13 I've used this, via a serial over USB connection, for several 14 months without any issues. 15 ---------------------------------------------------------------- 0 man: buildingiloteensy 1 2 The *iloTeensy system is compiled using the Arduino IDE with the 3 Teensyduino extensions. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: iloteensyextensions 1 2 *iloTeensy adds i/o devices for doing a few things: 3 4 - writing to pins (high or low) 5 - changing pin mode 6 - reading from pins 7 - clock functions 8 - delay, delay-microseconds, delay-nanoseconds 9 - get hour, minute, seconds, day, month, or year 10 11 In the future I expect to expand this a little, to provide 12 access to physical memory, and more of the onboard devices. 13 14 15 ---------------------------------------------------------------- 0 man: wordsbyname 1 2 *Konilo includes several hundred words. This is an alphabetical 3 listing of those in the basic *ilo.rom and the default *blocks. 4 The listing indicates the source of each word. Follow the links 5 to the glossary to get a deeper insight into them. 6 7 *WordsByName0 *WordsByName1 *WordsByName2 *WordsByName3 8 *WordsByName4 *WordsByName5 *WordsByName6 *WordsByName7 9 *WordsByName8 *WordsByName9 *WordsByName10 *WordsByName11 10 *WordsByName12 *WordsByName13 *WordsByName14 *WordsByName15 11 *WordsByName16 *WordsByName17 *WordsByName18 *WordsByName19 12 *WordsByName20 *WordsByName21 *WordsByName22 *WordsByName23 13 *WordsByName24 *WordsByName25 *WordsByName26 *WordsByName27 14 *WordsByName28 *WordsByName29 *WordsByName30 15 ---------------------------------------------------------------- 0 man: wordsbyname0 1 2 +) rom 3 +* blocks 4 +---reveal--- rom 5 +-eq? rom 6 +-if rom 7 +. rom 8 +.s blocks 9 +0 rom 10 +1 rom 11 +10 rom 12 +11 rom 13 +12 rom 14 +13 rom 15 +14 rom ---------------------------------------------------------------- 0 man: wordsbyname1 1 2 +15 rom 3 +2 rom 4 +3 rom 5 +4 rom 6 +5 rom 7 +6 rom 8 +7 rom 9 +8 rom 10 +9 rom 11 +; rom 12 +?jump rom 13 +BaseBlock rom 14 +Block rom 15 +Blocks rom ---------------------------------------------------------------- 0 man: wordsbyname2 1 2 +Compiler rom 3 +Dictionary rom 4 +FALSE blocks 5 +Free rom 6 +I rom 7 +J rom 8 +K rom 9 +Sigils rom 10 +TRUE blocks 11 +[ rom 12 +] rom 13 +a:-eq? rom 14 +a:append rom 15 +a:behead rom ---------------------------------------------------------------- 0 man: wordsbyname3 1 2 +a:chop rom 3 +a:contains? rom 4 +a:copy rom 5 +a:dup rom 6 +a:eq? rom 7 +a:fetch rom 8 +a:filter rom 9 +a:first rom 10 +a:for-each rom 11 +a:hash rom 12 +a:index rom 13 +a:indices rom 14 +a:last rom 15 +a:left rom ---------------------------------------------------------------- 0 man: wordsbyname4 1 2 +a:length rom 3 +a:make rom 4 +a:make/temp rom 5 +a:map rom 6 +a:middle rom 7 +a:prepend rom 8 +a:reduce rom 9 +a:reverse rom 10 +a:right rom 11 +a:store rom 12 +a:temp rom 13 +a:th rom 14 +allot rom 15 +and rom ---------------------------------------------------------------- 0 man: wordsbyname5 1 2 +assemble:opcode blocks 3 +b:fetch blocks 4 +b:pack blocks 5 +b:store blocks 6 +b:to-byte-address blocks 7 +b:unpack blocks 8 +bg:black blocks 9 +bg:blue blocks 10 +bg:cyan blocks 11 +bg:green blocks 12 +bg:magenta blocks 13 +bg:red blocks 14 +bg:white blocks 15 +bg:yellow blocks ---------------------------------------------------------------- 0 man: wordsbyname6 1 2 +bi rom 3 +bi* rom 4 +bi@ rom 5 +bit:clear blocks 6 +bit:get blocks 7 +bit:set blocks 8 +block:Sets blocks 9 +block:buffer rom 10 +block:empty? blocks 11 +block:first-matching blocks 12 +block:for-each blocks 13 +block:load rom 14 +block:name blocks 15 +block:save rom ---------------------------------------------------------------- 0 man: wordsbyname7 1 2 +block:set:add blocks 3 +block:set:init blocks 4 +block:set:known? blocks 5 +block:title blocks 6 +buffer:add blocks 7 +buffer:empty blocks 8 +buffer:end blocks 9 +buffer:get blocks 10 +buffer:set blocks 11 +buffer:size blocks 12 +buffer:start blocks 13 +bye rom 14 +c:-consonant? blocks 15 +c:-digit? blocks ---------------------------------------------------------------- 0 man: wordsbyname8 1 2 +c:-letter? blocks 3 +c:-lowercase? blocks 4 +c:-uppercase? blocks 5 +c:-visible? blocks 6 +c:-vowel? blocks 7 +c:-whitespace? blocks 8 +c:consonant? blocks 9 +c:digit? blocks 10 +c:get rom 11 +c:letter? blocks 12 +c:lowercase? rom 13 +c:put rom 14 +c:to-lower rom 15 +c:to-s rom ---------------------------------------------------------------- 0 man: wordsbyname9 1 2 +c:to-upper rom 3 +c:toggle-case blocks 4 +c:uppercase? rom 5 +c:visible? blocks 6 +c:vowel? blocks 7 +c:whitespace? blocks 8 +call rom 9 +cat blocks 10 +catalog blocks 11 +catalogue blocks 12 +choose rom 13 +clear blocks 14 +code: blocks 15 +comma rom ---------------------------------------------------------------- 0 man: wordsbyname10 1 2 +compare rom 3 +compile:call rom 4 +compile:jump rom 5 +compile:lit rom 6 +compiling? rom 7 +copy rom 8 +cp blocks 9 +curry rom 10 +d blocks 11 +d:address rom 12 +d:create rom 13 +d:exists? rom 14 +d:hash rom 15 +d:link rom ---------------------------------------------------------------- 0 man: wordsbyname11 1 2 +d:lookup rom 3 +depth/address rom 4 +depth/data rom 5 +depths rom 6 +describe blocks 7 +describe:word blocks 8 +dip rom 9 +drop rom 10 +drop-pair rom 11 +dtc rom 12 +dump blocks 13 +dup rom 14 +dup-pair rom 15 +e:Display rom ---------------------------------------------------------------- 0 man: wordsbyname12 1 2 +e:copy blocks 3 +e:cut blocks 4 +e:erase/line rom 5 +e:for-each-line blocks 6 +e:indent blocks 7 +e:insert rom 8 +e:insert-at rom 9 +e:line rom 10 +e:paste blocks 11 +e:replace rom 12 +e:replace-at rom 13 +e:to-line rom 14 +e:unindent blocks 15 +edit rom ---------------------------------------------------------------- 0 man: wordsbyname13 1 2 +eq? rom 3 +f:add blocks 4 +f:div blocks 5 +f:mul blocks 6 +f:put blocks 7 +f:scale blocks 8 +f:sub blocks 9 +fetch rom 10 +fetch-next rom 11 +fg:black blocks 12 +fg:blue blocks 13 +fg:cyan blocks 14 +fg:green blocks 15 +fg:magenta blocks ---------------------------------------------------------------- 0 man: wordsbyname14 1 2 +fg:red blocks 3 +fg:white blocks 4 +fg:yellow blocks 5 +fill rom 6 +forever rom 7 +gc rom 8 +glossary:exists? blocks 9 +glossary:locate blocks 10 +gt? rom 11 +gteq? rom 12 +here rom 13 +i blocks 14 +if rom 15 +indexed-times rom ---------------------------------------------------------------- 0 man: wordsbyname15 1 2 +internal:lit rom 3 +internal:quote rom 4 +interpret rom 5 +invoke blocks 6 +io rom 7 +jump rom 8 +l blocks 9 +list rom 10 +list# rom 11 +list* rom 12 +list:syntax blocks 13 +load rom 14 +locate blocks 15 +lt? rom ---------------------------------------------------------------- 0 man: wordsbyname16 1 2 +lteq? rom 3 +man blocks 4 +man:START blocks 5 +man:Termina blocks 6 +man:edit blocks 7 +man:exists? blocks 8 +man:list blocks 9 +man:locate blocks 10 +man:new blocks 11 +manual blocks 12 +mv blocks 13 +n blocks 14 +n:-zero? rom 15 +n:MAX blocks ---------------------------------------------------------------- 0 man: wordsbyname17 1 2 +n:MIN blocks 3 +n:abs rom 4 +n:add rom 5 +n:between? rom 6 +n:dec rom 7 +n:div rom 8 +n:divmod rom 9 +n:even? blocks 10 +n:get rom 11 +n:inc rom 12 +n:limit rom 13 +n:max rom 14 +n:min rom 15 +n:mod rom ---------------------------------------------------------------- 0 man: wordsbyname18 1 2 +n:mul rom 3 +n:negate rom 4 +n:negative? blocks 5 +n:odd? blocks 6 +n:positive? blocks 7 +n:put rom 8 +n:random blocks 9 +n:random-mod blocks 10 +n:sign blocks 11 +n:sqrt blocks 12 +n:square blocks 13 +n:strictly-positive? blocks 14 +n:sub rom 15 +n:to-s rom ---------------------------------------------------------------- 0 man: wordsbyname19 1 2 +n:zero? rom 3 +needs rom 4 +new rom 5 +next rom 6 +nip rom 7 +nl rom 8 +not rom 9 +or rom 10 +over rom 11 +p blocks 12 +pop rom 13 +prelude rom 14 +prev rom 15 +process-data rom ---------------------------------------------------------------- 0 man: wordsbyname20 1 2 +push rom 3 +r blocks 4 +reorder blocks 5 +reset blocks 6 +restart rom 7 +rm blocks 8 +roll blocks 9 +rom:save rom 10 +rot rom 11 +run rom 12 +s blocks 13 +s:-eq? rom 14 +s:ASCII-LETTERS blocks 15 +s:ASCII-LOWERCASE blocks ---------------------------------------------------------------- 0 man: wordsbyname21 1 2 +s:ASCII-UPPERCASE blocks 3 +s:CONSONANTS blocks 4 +s:DIGITS blocks 5 +s:PUNCTUATION blocks 6 +s:VOWELS blocks 7 +s:WHITESPACE blocks 8 +s:append rom 9 +s:begins-with? blocks 10 +s:behead rom 11 +s:chop rom 12 +s:contains/s? blocks 13 +s:contains? rom 14 +s:copy rom 15 +s:dup rom ---------------------------------------------------------------- 0 man: wordsbyname22 1 2 +s:ends-with? blocks 3 +s:eq? rom 4 +s:evaluate rom 5 +s:fetch rom 6 +s:filter rom 7 +s:first rom 8 +s:for-each rom 9 +s:get/line rom 10 +s:get/token rom 11 +s:hash rom 12 +s:index/c rom 13 +s:index/s blocks 14 +s:keep rom 15 +s:last rom ---------------------------------------------------------------- 0 man: wordsbyname23 1 2 +s:left rom 3 +s:length rom 4 +s:map rom 5 +s:middle rom 6 +s:prepend rom 7 +s:put rom 8 +s:reduce rom 9 +s:reverse rom 10 +s:rewrite rom 11 +s:right rom 12 +s:store rom 13 +s:temp rom 14 +s:th rom 15 +s:to-lower rom ---------------------------------------------------------------- 0 man: wordsbyname24 1 2 +s:to-n rom 3 +s:to-upper rom 4 +s:trim blocks 5 +s:trim-left blocks 6 +s:trim-right blocks 7 +save rom 8 +seed blocks 9 +set rom 10 +shift-left rom 11 +shift-right rom 12 +sigil:! rom 13 +sigil:# rom 14 +sigil:$ rom 15 +sigil:& rom ---------------------------------------------------------------- 0 man: wordsbyname25 1 2 +sigil:' rom 3 +sigil:( rom 4 +sigil:: rom 5 +sigil:@ rom 6 +sigil:\ rom 7 +sigil:get rom 8 +sigil:set rom 9 +sip rom 10 +sp rom 11 +startup rom 12 +store rom 13 +store-next rom 14 +swap rom 15 +sys:BUFFERS blocks ---------------------------------------------------------------- 0 man: wordsbyname26 1 2 +sys:EOM blocks 3 +sys:buffers/block rom 4 +sys:buffers/input rom 5 +sys:buffers/loops rom 6 +sys:buffers/needs rom 7 +sys:buffers/numeric-conversion rom 8 +sys:buffers/reserved rom 9 +sys:buffers/scope rom 10 +sys:buffers/strings+arrays rom 11 +sys:info rom 12 +tab rom 13 +ti:add-hint blocks 14 +ti:application blocks 15 +ti:done blocks ---------------------------------------------------------------- 0 man: wordsbyname27 1 2 +ti:get-action blocks 3 +ti:height blocks 4 +ti:help blocks 5 +ti:reset-actions blocks 6 +ti:reset-display blocks 7 +ti:reset-hints blocks 8 +ti:set-action blocks 9 +ti:set-display blocks 10 +ti:width blocks 11 +times rom 12 +titles rom 13 +tri rom 14 +tri* rom 15 +tri@ rom ---------------------------------------------------------------- 0 man: wordsbyname28 1 2 +tuck rom 3 +tuhi blocks 4 +tuhi:cfg/colors,bg blocks 5 +tuhi:cfg/colors,fg blocks 6 +tuhi:cfg/colors,line# blocks 7 +tuhi:cfg/status blocks 8 +tuhi:cfg/syntax blocks 9 +unroll blocks 10 +until rom 11 +use rom 12 +using rom 13 +v:dec rom 14 +v:dec-by blocks 15 +v:inc rom ---------------------------------------------------------------- 0 man: wordsbyname29 1 2 +v:inc-by blocks 3 +v:limit blocks 4 +v:off blocks 5 +v:on blocks 6 +v:preserve blocks 7 +v:update blocks 8 +var rom 9 +var-n rom 10 +vt:clear blocks 11 +vt:csi blocks 12 +vt:down blocks 13 +vt:esc blocks 14 +vt:home blocks 15 +vt:left blocks ---------------------------------------------------------------- 0 man: wordsbyname30 1 2 +vt:reset blocks 3 +vt:right blocks 4 +vt:row,col blocks 5 +vt:set/color blocks 6 +vt:up blocks 7 +while rom 8 +xcp blocks 9 +xmv blocks 10 +xor rom 11 +xrm blocks 12 +{{ rom 13 +}} rom 14 15 ---------------------------------------------------------------- 0 man: loadingtermina 1 2 If you are using the standard set of blocks that come with 3 Konilo, Termina will be loaded by default. If you have modified 4 the startup, you may need to load it manually. 5 6 To load, the easiest way is to use +needs 7 8 '(termina) needs 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: terminaconcepts 1 2 Termina provides a scaffold for writing keyboard driven programs 3 on a DEC compatible terminal (or terminal emulator). 4 5 Programs using Termina will have: 6 7 ================================#============================= 8 - a visual display area | *TerminaDisplay 9 - partially user defined | 10 - a menu of quick actions | *TerminaHints 11 - a keystroke to action map | *TerminaActions 12 - an optional help screen | *TerminaHelp 13 ================================#============================= 14 15 ---------------------------------------------------------------- 0 man: terminadisplay 1 2 The display is an important part of a *Termina program. Termina 3 will call your display word at the start of each cycle. You are 4 responsible for clearing or redrawing as needed. 5 6 You can look at the +ti:height and +ti:width variables to get a 7 sense of the display size set by the operator. I generally try 8 to support an 80x20 display size, with 16 rows dedicated to my 9 program display. 10 11 Termina will display a hints area (see *TerminaHints) below the 12 display. The positioning is based on +ti:height 13 14 15 ---------------------------------------------------------------- 0 man: terminahints 1 2 *Termina displays a "hints" area below the *TerminaDisplay. It 3 shows labels for keys 0-9, which serve as the primary keys for 4 *TerminaActions. 5 6 Your Termina program will provide a word to populate the hints 7 data. This should use +ti:add-hint to assign labels to each of 8 the supported keys. (For additional keys outside of 0-9, I 9 suggest using *TerminaHelp and binding to $?). 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: terminaactions 1 2 Actions in *Termina are words bound to specific keys. When the 3 key is pressed, the action handler is called. 4 5 Generally the most common actions should be bound to 0-9, and 6 *TerminaHints should be provided. I recommend binding $0 to 7 +ti:done for consistency with the existing programs. 8 9 Your code will provide a word to setup the key actions you need. 10 11 Some words to look at relating to this: 12 13 +ti:set-action 14 +ti:get-action 15 +ti:reset-actions ---------------------------------------------------------------- 0 man: terminahelp 1 2 *Termina provides a small program under +ti:help for displaying 3 a single block of help text. This takes a block number from the 4 stack. An example use might look like: 5 6 [ #123 ti:help ] $? ti:set-action 7 8 I recommend using $? as the binding for the primary help screen. 9 This is a good place to list additional *TerminaActions your 10 program provides. 11 12 13 14 15 ---------------------------------------------------------------- 0 man: sampleterminaprogram 1 2 :hints 3 'Previous #1 ti:add-hint 4 'Next #2 ti:add-hint 'Quit #0 ti:add-hint ; 5 6 :actions 7 &prev $1 ti:set-action &next $2 ti:set-action 8 &ti:done $0 ti:set-action ; 9 10 :display 11 clear list# ; 12 13 :block-viewer [ &actions &hints &display ] ti:application ; 14 15 . Above is a short (termina) block viewer program ---------------------------------------------------------------- 0 man: basiceditorconcepts 1 2 The *BasicEditor operates on a copy of the block being edited. 3 Changes made to the block are only written to disk after +save 4 is entered. 5 6 BasicEditor is loosely inspired by old BASIC systems, where code 7 was entered with line numbers. This is a very simple approach to 8 the code entry, with very limited editing options (mainly just 9 retyping a line), though some words exist for editing parts of a 10 line. 11 12 It's somewhat expected that most users will probably use *Tuhi 13 (an extended *Termina interface to the *BasicEditor) or *REM, 14 but only the BasicEditor is built into every *Konilo image. 15 ---------------------------------------------------------------- 0 man: displayingblocks 1 2 The *BasicEditor provides a few different words for displaying 3 the block being edited. These are: 4 5 Word Description 6 ======#========================================================= 7 +list Display the block with line numbers to the left of each 8 line. A horizontal ruler with column indicators is shown 9 above and below the block. 10 11 +list# Display the block with line numbers to the left of each 12 line. 13 14 +list* Display the block with no additional elements. 15 ---------------------------------------------------------------- 0 man: basiceditorindention 1 2 I use a format with two spaces per indention level. The (std) 3 library adds +e:indent and +e:unindent words to aid with this. 4 5 To add a level of indention to a line, use +e:indent 6 7 #10 e:indent 8 9 To remove a level of indention, use +e:unindent 10 11 #10 e:unindent 12 13 Return to *AdvancedEditingWithBasicEditor 14 15 ---------------------------------------------------------------- 0 man: basiceditorcutcopypaste 1 2 The (std) library adds +e:cut +e:copy and +e:paste to the 3 *BasicEditor. These allow you to copy or move a line into a 4 separate buffer and insert the copied or cut line into a 5 different line (or into a different block) 6 7 To cut or copy a line use of of: 8 9 #10 e:cut (or) #10 e:copy 10 11 And to replace a line with cut or copied line us: 12 13 #10 e:paste 14 15 Return to *AdvancedEditingWithBasicEditor ---------------------------------------------------------------- 0 man: advancededitingwithbasiceditor 1 2 The *BasicEditor provides a few words for altering lines or 3 portions of them. 4 5 *BasicEditorIndention 6 *BasicEditorCutCopyPaste 7 *BasicEditorReplacePartial 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: basiceditorreplacepartial 1 2 Retyping an entire line can be annoying if you just need to fix 3 a small portion of it. To help with this, the *BasicEditor has 4 +e:replace-at 5 6 This word takes a line number, a column number, and the text to 7 insert. For instance: 8 9 #10 #5 'this_gets_inserted_into_line_10_at_column_5 10 e:replace-at 11 12 Return to *AdvancedEditingWithBasicEditor 13 14 15 ---------------------------------------------------------------- 0 man: navigatingwithcatalogue 1 2 *Catalogue provides a few options for exploring the blocks. 3 4 Key Action 5 ----#---------------------------------------------------------- 6 1 Switch to the previous page of 16 blocks 7 2 Switch to the next page page 16 blocks 8 4 Jump to the page containing a block. After pressing 4, 9 enter the block number. Catalogue will locate and show 10 the page containing it. 11 9 Leap to the first page containing a block title. After 12 pressing 9, enter the first part of the block title. 13 Catalogue will locate it and display the page containing 14 it. 15 ---------------------------------------------------------------- 0 man: (quad) 1 2 The (quad) extension adds a set of quad combinators that fit 3 alongside +bi +bi* +bi@ and +tri +tri* +tri@ 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: nga 1 2 Nga is the *VirtualComputer that *RetroForth runs on. It is 3 similar to, but not compatible with, *ilo. 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: uxn 1 2 Uxn (and varvara) is a small *VirtualComputer that was developed 3 by *HundredRabbits. It is a stack based system, with 64kb of RAM 4 and a number of I/O devices. 5 6 Some interesting things in this are a focus on visual and audio 7 programs, the use of circular stacks, and the unique Uxntal 8 language. 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: hundredrabbits 1 2 Hundred Rabbits (100r.co) is a small artist collective that 3 explores low-tech solutions and documents their findings. They 4 live & work aboard a ship. 5 6 Of note is the *Uxn *VirtualComputer. 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 man: definingsigils 1 2 You can define new *sigils by writing them as *words and then 3 attaching it to the *SigilTable using +sigil:set 4 5 An example of a sigil that just displays the token passed to it 6 might look like: 7 8 :sigil:? (s-) s:put nl ; 9 &sigil:? $? sigil:set 10 11 You can remove a sigil by setting it to a value of zero: 12 13 #0 $? sigil:set 14 15 ---------------------------------------------------------------- 0 man: remconcepts 1 2 The two primary editors (*BasicEditor and *Tuhi) are both line 3 oriented, with limited ability to replace text within a line. In 4 contrast, *REM exists to provide a visual editor that can edit 5 existing lines more easily. 6 7 REM provides a cursor (movable with ijkl or chtn) that can be 8 positioned within the block, and an entry mode that overwrites 9 text starting at the cursor position without erasing the entire 10 line. 11 12 The key mapping was chosen to work on both QWERTY and DVORAK 13 layouts. 14 15 ---------------------------------------------------------------- 0 man: reminterface 1 2 *REM presents a visual interface using the *termina framework. 3 The display has the line numbers on the left (for reference), 4 with the block contents to the right. The display uses the *tuhi 5 syntax highlighting mode. 6 7 A movable cursor is displayed in the block. 8 9 Below this is a set of hot keys, with additional keys available 10 (hit ? while running for the help screen). 11 12 13 14 15 ---------------------------------------------------------------- 0 man: usingrem 1 2 The basic usage model of *REM is to move the cursor to where you 3 wish to begin typing, then hit 'a'. Enter the text (your input 4 will show as white on blue during entry), then hit enter when 5 done. 6 7 As with *Tuhi, use '6' to save or '7' to reload. 8 9 Hit '?' for a full help screen. 10 11 Cursor movement is done with ijkl (qwerty) or chtn (dvorak). 12 These map to up, left, down, and right. 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ---------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15