Add word "C@+"

This commit is contained in:
Virgil Dupras 2020-04-16 18:58:11 -04:00
parent eefa8e6de5
commit 5cb4a7de9a
5 changed files with 12 additions and 12 deletions

View File

@ -5,6 +5,7 @@ Memory
? a -- Print value of addr a ? a -- Print value of addr a
+! n a -- Increase value of addr a by n +! n a -- Increase value of addr a by n
C@ a -- c Set c to byte at address a 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 C! c a -- Store byte c in address a
CURRENT -- a Set a to wordref of last added entry. CURRENT -- a Set a to wordref of last added entry.
CURRENT* -- a A pointer to active CURRENT*. Useful CURRENT* -- a A pointer to active CURRENT*. Useful

View File

@ -179,3 +179,6 @@
R> DROP I 2- @ ( I I a ) R> DROP I 2- @ ( I I a )
= UNTIL = UNTIL
; ;
( a -- a+1 c )
: C@+ DUP C@ SWAP 1+ SWAP ;

View File

@ -54,11 +54,10 @@
LOOP LOOP
DROP DROP
8 0 DO 8 0 DO
DUP C@ C@+
DUP <>{ 0x20 &< 0x7e |> <>} DUP <>{ 0x20 &< 0x7e |> <>}
IF DROP '.' THEN IF DROP '.' THEN
EMIT EMIT
1+
LOOP LOOP
CRLF CRLF
; ;

View File

@ -5,22 +5,21 @@
: (print) : (print)
BEGIN BEGIN
DUP C@ ( a c ) C@+ ( a+1 c )
( exit if null ) ( exit if null )
DUP NOT IF 2DROP EXIT THEN DUP NOT IF 2DROP EXIT THEN
EMIT ( a ) EMIT ( a )
1 + ( a+1 )
AGAIN AGAIN
; ;
: ." : ."
34 , ( 34 == litWord ) 34 , ( 34 == litWord )
BEGIN BEGIN
C< DUP ( c c ) C<
( 34 is ASCII for " ) ( 34 is ASCII for " )
DUP 34 = IF DROP DROP 0 0 THEN DUP 34 = IF DROP 0 THEN
C, DUP C,
0 = UNTIL NOT UNTIL
COMPILE (print) COMPILE (print)
; IMMEDIATE ; IMMEDIATE

View File

@ -1,7 +1,5 @@
: SLEN ( a -- n ) : SLEN ( a -- n )
DUP ( astart aend ) DUP ( astart aend )
BEGIN BEGIN C@+ NOT UNTIL
DUP C@ 0 = IF -^ EXIT THEN 1- -^
1+
AGAIN
; ;