diff --git a/blk/060 b/blk/060 index 2bbca54..25b341f 100644 --- a/blk/060 +++ b/blk/060 @@ -4,8 +4,6 @@ I/O result in n as well as whether parsing was a success in f (false = failure, true = success) -(parse*) -- a Variable holding the current pointer for - system number parsing. By default, (parse). (print) a -- Print string at addr a. . n -- Print n in its decimal form .x n -- Print n's LSB in hex form. Always 2 @@ -13,4 +11,6 @@ I/O .X n -- Print n in hex form. Always 4 characters. Numbers are never considered negative. "-1 .X" --> ffff + + (cont.) diff --git a/blk/081 b/blk/081 index c1aa219..4ab6143 100644 --- a/blk/081 +++ b/blk/081 @@ -4,7 +4,7 @@ RAMSTART INITIAL_SP +55 (key) override +04 HERE +59 blk's variables +06 C CMP 1 = ; : 0< 32767 > ; +: >= < NOT ; +: <= > NOT ; +: 0>= 0< NOT ; - +( a -- a+1 c ) +: C@+ DUP C@ SWAP 1+ SWAP ; +( c a -- a+1 ) +: C!+ SWAP OVER C! 1+ ; diff --git a/blk/398 b/blk/398 index a544ed8..d7cb9b0 100644 --- a/blk/398 +++ b/blk/398 @@ -1,16 +1,11 @@ -( This is only the "early parser" in earlier stages. No need - for an abort message ) -: (parse) (parsed) NOT IF ABORT THEN ; +( strings being sent to parse routines are always null + terminated ) -: C DROP ( exit : ) -; IMMEDIATE - +( Read word from C<, copy to WORDBUF, null-terminate, and + return, make HL point to WORDBUF. ) +: WORD + 0x0e RAM+ ( 0e == WORDBUF ) + TOWORD ( a c ) + BEGIN + ( We take advantage of the fact that char MSB is + always zero to pre-write our null-termination ) + OVER ! 1+ ( a+1 ) + C< ( a c ) + DUP WS? + UNTIL + ( a this point, PS is: a WS ) + ( null-termination is already written ) + 2DROP + 0x0e RAM+ ; diff --git a/blk/407 b/blk/407 index d74dae5..f6a7134 100644 --- a/blk/407 +++ b/blk/407 @@ -1,16 +1,10 @@ -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*) @ EXECUTE LITN THEN - AGAIN ; -( from PSP ) ';' SWAP 4 - C! +: SCPY + BEGIN ( a ) + DUP C@ ( a c ) + DUP C, ( a c ) + NOT IF DROP EXIT THEN + 1+ ( a+1 ) + AGAIN +; + + diff --git a/blk/408 b/blk/408 new file mode 100644 index 0000000..1fce040 --- /dev/null +++ b/blk/408 @@ -0,0 +1,15 @@ +: [entry] + HERE @ ( w h ) + SWAP SCPY ( h ) + ( Adjust HERE -1 because SCPY copies the null ) + HERE @ 1- ( h h' ) + DUP HERE ! ( h h' ) + SWAP - ( sz ) + ( write prev value ) + HERE @ CURRENT @ - , + ( write size ) + C, + HERE @ CURRENT ! +; + +: (entry) WORD [entry] ; diff --git a/blk/409 b/blk/409 new file mode 100644 index 0000000..f93ab0e --- /dev/null +++ b/blk/409 @@ -0,0 +1,9 @@ +: INTERPRET + BEGIN + WORD + (find) + NOT IF (parse) ELSE EXECUTE THEN + C DROP ( exit : ) +; IMMEDIATE + diff --git a/blk/413 b/blk/413 new file mode 100644 index 0000000..e109431 --- /dev/null +++ b/blk/413 @@ -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/436 b/blk/436 index 1bbd442..8ea4b45 100644 --- a/blk/436 +++ b/blk/436 @@ -8,7 +8,3 @@ DROP ; -( a -- a+1 c ) -: C@+ DUP C@ SWAP 1+ SWAP ; -( c a -- a+1 ) -: C!+ SWAP OVER C! 1+ ; diff --git a/blk/438 b/blk/438 index ffe20dd..e69de29 100644 --- a/blk/438 +++ b/blk/438 @@ -1,3 +0,0 @@ -: >= < NOT ; -: <= > NOT ; -: 0>= 0< NOT ; diff --git a/blk/446 b/blk/446 deleted file mode 100644 index d7cb9b0..0000000 --- a/blk/446 +++ /dev/null @@ -1,11 +0,0 @@ -( strings being sent to parse routines are always null - terminated ) - -: (parsec) ( a -- n f ) - ( apostrophe is ASCII 39 ) - DUP C@ 39 = OVER 2+ C@ 39 = AND ( a f ) - NOT IF 0 EXIT THEN ( a 0 ) - ( surrounded by apos, good, return ) - 1+ C@ 1 ( n 1 ) -; - diff --git a/blk/447 b/blk/447 deleted file mode 100644 index bac471c..0000000 --- a/blk/447 +++ /dev/null @@ -1,14 +0,0 @@ -( returns negative value on error ) -: _ ( c -- n ) - ( '0' is ASCII 48 ) - 48 - - DUP 0< ( bad ) OVER 10 < ( good ) OR IF EXIT THEN - ( 'a' is ASCII 97. 59 = 97 - 48 ) - 49 - - DUP 0< IF EXIT THEN ( bad ) - DUP 6 < IF 10 + EXIT THEN ( good ) - ( bad ) - 255 - -; - - diff --git a/blk/448 b/blk/448 deleted file mode 100644 index e400a39..0000000 --- a/blk/448 +++ /dev/null @@ -1,15 +0,0 @@ -: (parseh) ( a -- n f ) - ( '0': ASCII 0x30 'x': 0x78 0x7830: 30768 ) - DUP @ 30768 = NOT IF 0 EXIT THEN ( a 0 ) - ( We have "0x" prefix ) - 2+ - 0 ( a r ) - BEGIN - SWAP C@+ ( r a+1 c ) - DUP NOT IF 2DROP 1 EXIT THEN ( r, 1 ) - _ ( r a n ) - DUP 0< IF ROT 2DROP 0 EXIT THEN ( a 0 ) - ROT 16 * + ( a r*16+n ) - AGAIN -; - diff --git a/blk/449 b/blk/449 deleted file mode 100644 index eb50ae5..0000000 --- a/blk/449 +++ /dev/null @@ -1,10 +0,0 @@ -( returns negative value on error ) -: _ ( c -- n ) - ( '0' is ASCII 48 ) - 48 - - DUP 0< ( bad ) OVER 2 < ( good ) OR IF EXIT THEN - ( bad ) - 255 - -; - - diff --git a/blk/450 b/blk/450 deleted file mode 100644 index e8788f9..0000000 --- a/blk/450 +++ /dev/null @@ -1,16 +0,0 @@ -: (parseb) ( a -- n f ) - ( '0': ASCII 0x30 'b': 0x62 0x6230: 25136 ) - DUP @ 25136 = NOT IF 0 EXIT THEN ( a 0 ) - ( We have "0b" prefix ) - 2+ - 0 ( a r ) - BEGIN - SWAP C@+ ( r a+1 c ) - DUP NOT IF 2DROP 1 EXIT THEN ( r 1 ) - _ ( r a n ) - DUP 0< IF ROT 2DROP 0 EXIT THEN ( a 0 ) - ROT 2 * + ( a r*2+n ) - AGAIN -; - - diff --git a/blk/451 b/blk/451 deleted file mode 100644 index 7f308d4..0000000 --- a/blk/451 +++ /dev/null @@ -1,10 +0,0 @@ -: (parse) ( a -- n ) - (parsec) IF EXIT THEN - (parseh) IF EXIT THEN - (parseb) IF EXIT THEN - (parsed) IF EXIT THEN - ( nothing works ) - LIT< (wnf) (find) IF EXECUTE ELSE ABORT THEN -; - -' (parse) (parse*) ! diff --git a/emul/forth.bin b/emul/forth.bin index 6c12adf..fd113c7 100644 Binary files a/emul/forth.bin and b/emul/forth.bin differ