diff --git a/blk/001 b/blk/001 index ea1c2d5..0d35d8c 100644 --- a/blk/001 +++ b/blk/001 @@ -7,7 +7,7 @@ MASTER INDEX 200 Z80 assembler 260 Cross compilation 280 Z80 boot code 350 ACIA driver 370 SD Card driver 390 Cross-compiled core -420 Core words 480 AT28 Driver +428 Core words 480 AT28 Driver 490 TRS-80 Recipe 520 Fonts 550 TI-84+ Recipe diff --git a/blk/422 b/blk/422 deleted file mode 100644 index 445bcf4..0000000 --- a/blk/422 +++ /dev/null @@ -1,10 +0,0 @@ -: [ INTERPRET ; IMMEDIATE -: ] R> DROP ; -: LIT< WORD 34 , SCPY 0 C, ; IMMEDIATE -: LITA 36 , , ; -: '? WORD (find) ; -: ' - '? (?br) [ 4 , ] EXIT - LIT< (wnf) (find) DROP EXECUTE -; -: ['] ' LITA ; IMMEDIATE diff --git a/blk/423 b/blk/423 deleted file mode 100644 index 0f436d7..0000000 --- a/blk/423 +++ /dev/null @@ -1,5 +0,0 @@ -: COMPILE ' LITA ['] , , ; IMMEDIATE -: [COMPILE] ' , ; IMMEDIATE -: BEGIN H@ ; IMMEDIATE -: AGAIN COMPILE (br) H@ - , ; IMMEDIATE -: UNTIL COMPILE (?br) H@ - , ; IMMEDIATE diff --git a/blk/424 b/blk/424 deleted file mode 100644 index 7bd64ff..0000000 --- a/blk/424 +++ /dev/null @@ -1,13 +0,0 @@ -: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE -40 CURRENT @ 4 - C! -( Hello, hello, krkrkrkr... do you hear me? - Ah, voice at last! Some lines above need comments - BTW: Forth lines limited to 64 cols because of default - input buffer size in Collapse OS - - 40 is ASCII for '('. We do this to simplify XPACK's task of - not mistakenly consider '(' definition as a comment. - LIT<: 34 == litWord - LITA: 36 == addrWord - COMPILE: Tough one. Get addr of caller word (example above - (br)) and then call LITA on it. ) diff --git a/blk/426 b/blk/426 deleted file mode 100644 index c80b968..0000000 --- a/blk/426 +++ /dev/null @@ -1,12 +0,0 @@ -: ELSE ( a1 -- a2 | a1: IF cell a2: ELSE cell ) - COMPILE (br) - 2 ALLOT - DUP H@ -^ SWAP ( a-H a ) - ! - H@ 2- ( push a. -2 for allot offset ) -; IMMEDIATE - -: [IF] - IF EXIT THEN - LIT< [THEN] BEGIN DUP WORD S= UNTIL DROP ; -: [THEN] ; diff --git a/blk/420 b/blk/428 similarity index 82% rename from blk/420 rename to blk/428 index e22593a..c42f756 100644 --- a/blk/420 +++ b/blk/428 @@ -8,6 +8,5 @@ itself to a full intepreter, which can then be relinked with the Relinker. There is no loader for these libraries because you will typically XPACK (B267) them. -422 core 440 print -442 fmt 447 readln -453 blk +430 core 442 fmt +447 readln 453 blk diff --git a/blk/430 b/blk/430 index 4bd8e56..8fa4553 100644 --- a/blk/430 +++ b/blk/430 @@ -1,14 +1,15 @@ -: DOES> - ( Overwrite cellWord in CURRENT ) - ( 43 == doesWord ) - 43 CURRENT @ C! - ( When we have a DOES>, we forcefully place HERE to 4 - bytes after CURRENT. This allows a DOES word to use "," - and "C," without messing everything up. ) - CURRENT @ 3 + HERE ! - ( HERE points to where we should write R> ) - R> , - ( We're done. Because we've popped RS, we'll exit parent - definition ) +: [ INTERPRET ; IMMEDIATE +: ] R> DROP ; +: LIT< WORD 34 , SCPY 0 C, ; IMMEDIATE +: LITA 36 , , ; +: '? WORD (find) ; +: ' + '? (?br) [ 4 , ] EXIT + LIT< (wnf) (find) DROP EXECUTE ; - +: ['] ' LITA ; IMMEDIATE +: COMPILE ' LITA ['] , , ; IMMEDIATE +: [COMPILE] ' , ; IMMEDIATE +: BEGIN H@ ; IMMEDIATE +: AGAIN COMPILE (br) H@ - , ; IMMEDIATE +: UNTIL COMPILE (?br) H@ - , ; IMMEDIATE diff --git a/blk/431 b/blk/431 index 5b89d16..7bd64ff 100644 --- a/blk/431 +++ b/blk/431 @@ -1,8 +1,13 @@ -: VARIABLE CREATE 2 ALLOT ; -: CONSTANT CREATE , DOES> @ ; +: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE +40 CURRENT @ 4 - C! +( Hello, hello, krkrkrkr... do you hear me? + Ah, voice at last! Some lines above need comments + BTW: Forth lines limited to 64 cols because of default + input buffer size in Collapse OS -( In addition to pushing H@ this compiles 2>R so that loop - variables are sent to PS at runtime ) -: DO COMPILE 2>R H@ ; IMMEDIATE -: LOOP COMPILE (loop) H@ - , ; IMMEDIATE -: LEAVE R> R> DROP I 1- >R >R ; + 40 is ASCII for '('. We do this to simplify XPACK's task of + not mistakenly consider '(' definition as a comment. + LIT<: 34 == litWord + LITA: 36 == addrWord + COMPILE: Tough one. Get addr of caller word (example above + (br)) and then call LITA on it. ) diff --git a/blk/425 b/blk/432 similarity index 100% rename from blk/425 rename to blk/432 diff --git a/blk/433 b/blk/433 index 2e22895..c80b968 100644 --- a/blk/433 +++ b/blk/433 @@ -1,11 +1,12 @@ -: ROLL - DUP NOT IF EXIT THEN - 1+ DUP PICK ( n val ) - SWAP 2 * (roll) ( val ) - SWAP DROP -; - -: 2OVER 3 PICK 3 PICK ; -: 2SWAP 3 ROLL 3 ROLL ; - +: ELSE ( a1 -- a2 | a1: IF cell a2: ELSE cell ) + COMPILE (br) + 2 ALLOT + DUP H@ -^ SWAP ( a-H a ) + ! + H@ 2- ( push a. -2 for allot offset ) +; IMMEDIATE +: [IF] + IF EXIT THEN + LIT< [THEN] BEGIN DUP WORD S= UNTIL DROP ; +: [THEN] ; diff --git a/blk/434 b/blk/434 index 0523223..4bd8e56 100644 --- a/blk/434 +++ b/blk/434 @@ -1,13 +1,14 @@ -: MOVE ( a1 a2 u -- ) - ( u ) 0 DO ( a1 a2 ) - SWAP C@+ ( a2 a1+1 x ) - ROT C!+ ( a1+1 a2+1 ) - LOOP 2DROP ; -: MOVE- ( a1 a2 u -- ) - SWAP OVER + 1- ( a1 u a2+u-1 ) - ROT 2 PICK + 1- ( u a2+u-1 a1+u-1 ) - ROT ( u ) 0 DO ( a2 a1 ) - C@- ( a2 a1-1 x ) - ROT C!- ( a1-1 a2-1 ) SWAP ( a2 a1 ) - LOOP 2DROP ; -: PREV 3 - DUP @ - ; +: DOES> + ( Overwrite cellWord in CURRENT ) + ( 43 == doesWord ) + 43 CURRENT @ C! + ( When we have a DOES>, we forcefully place HERE to 4 + bytes after CURRENT. This allows a DOES word to use "," + and "C," without messing everything up. ) + CURRENT @ 3 + HERE ! + ( HERE points to where we should write R> ) + R> , + ( We're done. Because we've popped RS, we'll exit parent + definition ) +; + diff --git a/blk/435 b/blk/435 index 3cb48b4..5b89d16 100644 --- a/blk/435 +++ b/blk/435 @@ -1,13 +1,8 @@ -: WORD( - DUP 1- C@ ( name len field ) - 127 AND ( 0x7f. remove IMMEDIATE flag ) - 3 + ( fixed header len ) - - -; -: FORGET - ' DUP ( w w ) - ( HERE must be at the end of prev's word, that is, at the - beginning of w. ) - WORD( HERE ! ( w ) - PREV CURRENT ! -; +: VARIABLE CREATE 2 ALLOT ; +: CONSTANT CREATE , DOES> @ ; + +( In addition to pushing H@ this compiles 2>R so that loop + variables are sent to PS at runtime ) +: DO COMPILE 2>R H@ ; IMMEDIATE +: LOOP COMPILE (loop) H@ - , ; IMMEDIATE +: LEAVE R> R> DROP I 1- >R >R ; diff --git a/blk/436 b/blk/436 index 8ea4b45..2e22895 100644 --- a/blk/436 +++ b/blk/436 @@ -1,10 +1,11 @@ -( Drop RSP until I-2 == INTERPRET. ) -: EXIT! - ['] INTERPRET ( I ) - BEGIN ( I ) - DUP ( I I ) - R> DROP I 2- @ ( I I a ) - = UNTIL - DROP +: ROLL + DUP NOT IF EXIT THEN + 1+ DUP PICK ( n val ) + SWAP 2 * (roll) ( val ) + SWAP DROP ; +: 2OVER 3 PICK 3 PICK ; +: 2SWAP 3 ROLL 3 ROLL ; + + diff --git a/blk/437 b/blk/437 new file mode 100644 index 0000000..0523223 --- /dev/null +++ b/blk/437 @@ -0,0 +1,13 @@ +: MOVE ( a1 a2 u -- ) + ( u ) 0 DO ( a1 a2 ) + SWAP C@+ ( a2 a1+1 x ) + ROT C!+ ( a1+1 a2+1 ) + LOOP 2DROP ; +: MOVE- ( a1 a2 u -- ) + SWAP OVER + 1- ( a1 u a2+u-1 ) + ROT 2 PICK + 1- ( u a2+u-1 a1+u-1 ) + ROT ( u ) 0 DO ( a2 a1 ) + C@- ( a2 a1-1 x ) + ROT C!- ( a1-1 a2-1 ) SWAP ( a2 a1 ) + LOOP 2DROP ; +: PREV 3 - DUP @ - ; diff --git a/blk/438 b/blk/438 new file mode 100644 index 0000000..3cb48b4 --- /dev/null +++ b/blk/438 @@ -0,0 +1,13 @@ +: WORD( + DUP 1- C@ ( name len field ) + 127 AND ( 0x7f. remove IMMEDIATE flag ) + 3 + ( fixed header len ) + - +; +: FORGET + ' DUP ( w w ) + ( HERE must be at the end of prev's word, that is, at the + beginning of w. ) + WORD( HERE ! ( w ) + PREV CURRENT ! +; diff --git a/blk/439 b/blk/439 new file mode 100644 index 0000000..8ea4b45 --- /dev/null +++ b/blk/439 @@ -0,0 +1,10 @@ +( Drop RSP until I-2 == INTERPRET. ) +: EXIT! + ['] INTERPRET ( I ) + BEGIN ( I ) + DUP ( I I ) + R> DROP I 2- @ ( I I a ) + = UNTIL + DROP +; + diff --git a/emul/xcomp.fs b/emul/xcomp.fs index 5fce1ce..2ecd8cd 100644 --- a/emul/xcomp.fs +++ b/emul/xcomp.fs @@ -21,7 +21,7 @@ CURRENT @ XCURRENT ! ( Update LATEST ) PC ORG @ 8 + ! ," CURRENT @ HERE ! " -422 459 XPACKR +430 459 XPACKR ," ' (key) 12 RAM+ ! " ORG @ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC! diff --git a/recipes/rc2014/xcomp.fs b/recipes/rc2014/xcomp.fs index 2969319..30590a1 100644 --- a/recipes/rc2014/xcomp.fs +++ b/recipes/rc2014/xcomp.fs @@ -27,7 +27,7 @@ CURRENT @ XCURRENT ! (entry) _ ( Update LATEST ) PC ORG @ 8 + ! -422 452 XPACKR ( core print fmt readln ) +430 452 XPACKR ( core fmt readln ) 123 132 XPACKR ( linker ) ," : _ ACIA$ RDLN$ (ok) ; _ " ORG @ 256 /MOD 2 PC! 2 PC! diff --git a/recipes/ti84/xcomp.fs b/recipes/ti84/xcomp.fs index 078904d..34c49f6 100644 --- a/recipes/ti84/xcomp.fs +++ b/recipes/ti84/xcomp.fs @@ -74,7 +74,7 @@ CREATE ~FNT CPFNT3x5 (entry) _ ( Update LATEST ) PC ORG @ 8 + ! -422 451 XPACKR ( core print fmt readln ) +430 451 XPACKR ( core fmt readln ) ," : _ LCD$ KBD$ (ok) RDLN$ ; _ " ORG @ 0x100 - 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC! diff --git a/recipes/trs80/xcomp.fs b/recipes/trs80/xcomp.fs index a35ad8c..689c748 100644 --- a/recipes/trs80/xcomp.fs +++ b/recipes/trs80/xcomp.fs @@ -21,7 +21,7 @@ CURRENT @ XCURRENT ! ( Update LATEST ) PC ORG @ 8 + ! ," CURRENT @ HERE ! " -422 459 XPACKR ( core print readln fmt blk ) +430 459 XPACKR ( core readln fmt blk ) 499 500 XPACKR ( trs80.fs ) ( 0x0a == NLPTR. TRS-80 wants CR-only newlines ) ," : _ ['] CR 0x0a RAM+ ! BLK$ FD$ (ok) RDLN$ ; _ "