diff --git a/blk/050 b/blk/050 index 215c842..9f991c7 100644 --- a/blk/050 +++ b/blk/050 @@ -5,6 +5,7 @@ Memory ? a -- Print value of addr a +! n a -- Increase value of addr a by n C@ a -- c Set c to byte at address a +C@+ a -- a+1 c Fetch c from a and inc a. C! c a -- Store byte c in address a CURRENT -- a Set a to wordref of last added entry. CURRENT* -- a A pointer to active CURRENT*. Useful diff --git a/forth/core.fs b/forth/core.fs index 6c308af..129b912 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -179,3 +179,6 @@ R> DROP I 2- @ ( I I a ) = UNTIL ; + +( a -- a+1 c ) +: C@+ DUP C@ SWAP 1+ SWAP ; diff --git a/forth/fmt.fs b/forth/fmt.fs index 8d9dcd0..a143e08 100644 --- a/forth/fmt.fs +++ b/forth/fmt.fs @@ -54,11 +54,10 @@ LOOP DROP 8 0 DO - DUP C@ + C@+ DUP <>{ 0x20 &< 0x7e |> <>} IF DROP '.' THEN EMIT - 1+ LOOP CRLF ; diff --git a/forth/print.fs b/forth/print.fs index f758e4d..1dcd8ee 100644 --- a/forth/print.fs +++ b/forth/print.fs @@ -5,22 +5,21 @@ : (print) BEGIN - DUP C@ ( a c ) + C@+ ( a+1 c ) ( exit if null ) DUP NOT IF 2DROP EXIT THEN EMIT ( a ) - 1 + ( a+1 ) AGAIN ; : ." 34 , ( 34 == litWord ) BEGIN - C< DUP ( c c ) + C< ( 34 is ASCII for " ) - DUP 34 = IF DROP DROP 0 0 THEN - C, - 0 = UNTIL + DUP 34 = IF DROP 0 THEN + DUP C, + NOT UNTIL COMPILE (print) ; IMMEDIATE diff --git a/forth/str.fs b/forth/str.fs index dcc80c9..9828c0e 100644 --- a/forth/str.fs +++ b/forth/str.fs @@ -1,7 +1,5 @@ : SLEN ( a -- n ) DUP ( astart aend ) - BEGIN - DUP C@ 0 = IF -^ EXIT THEN - 1+ - AGAIN + BEGIN C@+ NOT UNTIL + 1- -^ ;