diff --git a/blk/263 b/blk/263 index dbaf796..6dc146a 100644 --- a/blk/263 +++ b/blk/263 @@ -5,7 +5,11 @@ VARIABLE XCURRENT : (xentry) XCON (entry) XCOFF ; : XCREATE (xentry) 11 C, ; - : XCODE XCON CODE XCOFF ; - : XIMM XCON IMMEDIATE XCOFF ; +: _xapply ( a -- a-off ) + DUP ORG @ > IF ORG @ - BIN( @ + THEN ; +: XCOMPILE + XCON ' _xapply LITA + LIT< , (find) DROP _xapply , XCOFF ; +: X[COMPILE] XCON ' _xapply , XCOFF ; diff --git a/blk/265 b/blk/265 index 98d3d66..d29d8b5 100644 --- a/blk/265 +++ b/blk/265 @@ -4,7 +4,7 @@ XCURRENT @ SWAP ( xcur w ) _find ( a f ) IF ( a ) DUP IMMED? IF ABORT THEN - DUP ORG @ > IF ORG @ - BIN( @ + THEN , + _xapply , ELSE ( w ) 0x02 RAM+ @ SWAP ( cur w ) _find ( a f ) IF DUP IMMED? NOT IF ABORT THEN EXECUTE diff --git a/blk/288 b/blk/288 index d26471b..af8d5b6 100644 --- a/blk/288 +++ b/blk/288 @@ -1,4 +1,4 @@ -PC ORG @ 0x22 + ! ( litWord, 0xf7, very tight on the 0x100 limit ) +PC ORG @ 0x22 + ! ( litWord, 0xf7, tight on the 0x100 limit ) ( Like numberWord, but instead of being followed by a 2 bytes number, it's followed by a null-terminated string. When called, puts the string's address on PS ) diff --git a/blk/415 b/blk/415 index 8ed1836..4ed5cf8 100644 --- a/blk/415 +++ b/blk/415 @@ -1 +1 @@ -1 2 LOADR+ +1 4 LOADR+ diff --git a/blk/416 b/blk/416 index 60f0030..4e4498b 100644 --- a/blk/416 +++ b/blk/416 @@ -1,14 +1,14 @@ -( LITN has to be defined after the last immediate usage of - it to avoid bootstrapping issues ) -: LITN 32 , , ( 32 == NUMBER ) ; +: EMIT + ( 0x53==(emit) override ) + 0x53 RAM+ @ DUP IF EXECUTE ELSE DROP (emit) THEN ; -: IMMED? 1- C@ 0x80 AND ; +: (print) + BEGIN + C@+ ( a+1 c ) + ( exit if null or 0xd ) + DUP 0xd = OVER NOT OR IF 2DROP EXIT THEN + EMIT ( a ) + AGAIN +; -( ';' can't have its name right away because, when created, it - is not an IMMEDIATE yet and will not be treated properly by - xcomp. ) -: _ - ['] EXIT , - R> DROP ( exit : ) -; IMMEDIATE diff --git a/blk/417 b/blk/417 index e109431..5e19ff6 100644 --- a/blk/417 +++ b/blk/417 @@ -1,16 +1,13 @@ -XCURRENT @ ( to PSP ) -: : - (entry) - ( We cannot use LITN as IMMEDIATE because of bootstrapping - issues. Same thing for ",". - 32 == NUMBER 14 == compiledWord ) - [ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, +: ," BEGIN - WORD - (find) - ( is word ) - IF DUP IMMED? IF EXECUTE ELSE , THEN - ( maybe number ) - ELSE (parse) LITN THEN + C< + ( 34 is ASCII for " ) + DUP 34 = IF DROP EXIT THEN C, AGAIN ; -( from PSP ) ';' SWAP 4 - C! + +: ." + 34 , ( 34 == litWord ) ," 0 C, + COMPILE (print) +; IMMEDIATE + +: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE diff --git a/blk/418 b/blk/418 new file mode 100644 index 0000000..60f0030 --- /dev/null +++ b/blk/418 @@ -0,0 +1,14 @@ +( LITN has to be defined after the last immediate usage of + it to avoid bootstrapping issues ) +: LITN 32 , , ( 32 == NUMBER ) ; + +: IMMED? 1- C@ 0x80 AND ; + +( ';' can't have its name right away because, when created, it + is not an IMMEDIATE yet and will not be treated properly by + xcomp. ) +: _ + ['] EXIT , + R> DROP ( exit : ) +; IMMEDIATE + diff --git a/blk/419 b/blk/419 new file mode 100644 index 0000000..e109431 --- /dev/null +++ b/blk/419 @@ -0,0 +1,16 @@ +XCURRENT @ ( to PSP ) +: : + (entry) + ( We cannot use LITN as IMMEDIATE because of bootstrapping + issues. Same thing for ",". + 32 == NUMBER 14 == compiledWord ) + [ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, + BEGIN + WORD + (find) + ( is word ) + IF DUP IMMED? IF EXECUTE ELSE , THEN + ( maybe number ) + ELSE (parse) LITN THEN + AGAIN ; +( from PSP ) ';' SWAP 4 - C! diff --git a/blk/420 b/blk/420 index fd6f127..e22593a 100644 --- a/blk/420 +++ b/blk/420 @@ -8,6 +8,6 @@ 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 438 print +422 core 440 print 442 fmt 447 readln 453 blk diff --git a/blk/438 b/blk/438 deleted file mode 100644 index 1fe79e5..0000000 --- a/blk/438 +++ /dev/null @@ -1,13 +0,0 @@ -: EMIT - ( 0x53==(emit) override ) - 83 RAM+ @ DUP IF EXECUTE ELSE DROP (emit) THEN ; - -: (print) - BEGIN - C@+ ( a+1 c ) - ( exit if null or 0xd ) - DUP 13 = OVER NOT OR IF 2DROP EXIT THEN - EMIT ( a ) - AGAIN -; - diff --git a/blk/439 b/blk/439 deleted file mode 100644 index 6abc49d..0000000 --- a/blk/439 +++ /dev/null @@ -1,16 +0,0 @@ -: ," - BEGIN - C< - ( 34 is ASCII for " ) - DUP 34 = IF DROP EXIT THEN C, - AGAIN ; - -: ." - 34 , ( 34 == litWord ) ," 0 C, - COMPILE (print) -; IMMEDIATE - -: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE - -: (uflw) ABORT" stack underflow" ; - diff --git a/blk/440 b/blk/440 index 96b1ba4..1c9ce35 100644 --- a/blk/440 +++ b/blk/440 @@ -1,3 +1,4 @@ +: (uflw) ABORT" stack underflow" ; : BS 8 EMIT ; : LF 10 EMIT ; : CR 13 EMIT ; diff --git a/emul/forth.bin b/emul/forth.bin index 3d94aec..22f408d 100644 Binary files a/emul/forth.bin and b/emul/forth.bin differ diff --git a/emul/xcomp.fs b/emul/xcomp.fs index 07c4963..5fce1ce 100644 --- a/emul/xcomp.fs +++ b/emul/xcomp.fs @@ -4,6 +4,8 @@ 212 LOAD ( z80 assembler ) 262 LOAD ( xcomp ) : CODE XCODE ; +: COMPILE XCOMPILE ; IMMEDIATE +: [COMPILE] X[COMPILE] ; IMMEDIATE : IMMEDIATE XIMM ; : (entry) (xentry) ; : : [ ' X: , ] ; diff --git a/recipes/rc2014/xcomp.fs b/recipes/rc2014/xcomp.fs index 95a92bf..2969319 100644 --- a/recipes/rc2014/xcomp.fs +++ b/recipes/rc2014/xcomp.fs @@ -10,6 +10,8 @@ RAMSTART 0x70 + CONSTANT ACIA_MEM 212 LOAD ( z80 assembler ) 262 LOAD ( xcomp ) : CODE XCODE ; +: COMPILE XCOMPILE ; IMMEDIATE +: [COMPILE] X[COMPILE] ; IMMEDIATE : IMMEDIATE XIMM ; : (entry) (xentry) ; : CREATE XCREATE ; diff --git a/recipes/ti84/xcomp.fs b/recipes/ti84/xcomp.fs index 51c0367..078904d 100644 --- a/recipes/ti84/xcomp.fs +++ b/recipes/ti84/xcomp.fs @@ -9,6 +9,8 @@ RAMSTART 0x72 + CONSTANT KBD_MEM 262 LOAD ( xcomp ) 522 LOAD ( font compiler ) : CODE XCODE ; +: COMPILE XCOMPILE ; IMMEDIATE +: [COMPILE] X[COMPILE] ; IMMEDIATE : IMMEDIATE XIMM ; : (entry) (xentry) ; : CREATE XCREATE ; ( for KBD tbls ) diff --git a/recipes/trs80/xcomp.fs b/recipes/trs80/xcomp.fs index 0f3ebb5..a35ad8c 100644 --- a/recipes/trs80/xcomp.fs +++ b/recipes/trs80/xcomp.fs @@ -4,6 +4,8 @@ RS_ADDR 0x80 - CONSTANT RAMSTART 212 LOAD ( z80 assembler ) 262 LOAD ( xcomp ) : CODE XCODE ; +: COMPILE XCOMPILE ; IMMEDIATE +: [COMPILE] X[COMPILE] ; IMMEDIATE : IMMEDIATE XIMM ; : (entry) (xentry) ; : : [ ' X: , ] ;