sjack
2024-04-03 07:59:59 UTC
Put aside all my extensions and explored using FigForth core
words only. Here are three of several things I found interesting:
Fig-Forth 1.0.A
( Example #1, Stash data stack items)
: XX S0 @ SP! ; OK
: S0! S0 ! ; OK
: !S0 TIB @ S0! ; OK
: .S S0 @ BEGIN CELL - SP@ OVER < WHILE DUP ? REPEAT DROP ; OK
( some stack items.............) 1 2 3 4 5 OK
.s 1 2 3 4 5 OK
( stash them...................) sp@ s0! OK
( use the stack................) 666 777 888 OK
.s 666 777 888 OK
( restore stashed items........) xx !s0 OK
.s 1 2 3 4 5 OK
( Example #2, Input counted string _directly_ into given storage area)
: CREATE: <BUILDS DOES> ; OK
: := DP @ SWAP DP ! 1 WORD DP ! ; OK
CREATE: FOO 64 ALLOT ( storage area for counted string FOO) OK
FOO := Hello Chuck! OK
FOO COUNT CR TYPE
Hello Chuck! OK
( Example #3, Easily edit block screen without editor)
lib OK
0 60 (LINE) DROP 1024 BLANKS OK
0 60 (LINE) EXPECT ( FOO BAR ) OK
1 60 (LINE) EXPECT : FOO ." foo " ; OK
2 60 (LINE) EXPECT : BAR ." bar " ; OK
UPDATE FLUSH OK
60 LIST
SCR # 60
0 ( FOO BAR )
1 : FOO ." foo " ;
2 : BAR ." bar " ;
3
4
...
OK
( Note RETURNS entered after EXPECTs)
PS: Having initializing variables can be a nice fit:
CREATE: FCB 0 , HERE 64 ALLOT HERE 1024 ALLOT
CONSTANT FCB.BUF
CONSTANT FCB.NAME
PS2: Alignment after data is not needed when storage is followed
by a definition since Fig word names need not start on a
word boundary (in my build).
words only. Here are three of several things I found interesting:
Fig-Forth 1.0.A
( Example #1, Stash data stack items)
: XX S0 @ SP! ; OK
: S0! S0 ! ; OK
: !S0 TIB @ S0! ; OK
: .S S0 @ BEGIN CELL - SP@ OVER < WHILE DUP ? REPEAT DROP ; OK
( some stack items.............) 1 2 3 4 5 OK
.s 1 2 3 4 5 OK
( stash them...................) sp@ s0! OK
( use the stack................) 666 777 888 OK
.s 666 777 888 OK
( restore stashed items........) xx !s0 OK
.s 1 2 3 4 5 OK
( Example #2, Input counted string _directly_ into given storage area)
: CREATE: <BUILDS DOES> ; OK
: := DP @ SWAP DP ! 1 WORD DP ! ; OK
CREATE: FOO 64 ALLOT ( storage area for counted string FOO) OK
FOO := Hello Chuck! OK
FOO COUNT CR TYPE
Hello Chuck! OK
( Example #3, Easily edit block screen without editor)
lib OK
0 60 (LINE) DROP 1024 BLANKS OK
0 60 (LINE) EXPECT ( FOO BAR ) OK
1 60 (LINE) EXPECT : FOO ." foo " ; OK
2 60 (LINE) EXPECT : BAR ." bar " ; OK
UPDATE FLUSH OK
60 LIST
SCR # 60
0 ( FOO BAR )
1 : FOO ." foo " ;
2 : BAR ." bar " ;
3
4
...
OK
( Note RETURNS entered after EXPECTs)
PS: Having initializing variables can be a nice fit:
CREATE: FCB 0 , HERE 64 ALLOT HERE 1024 ALLOT
CONSTANT FCB.BUF
CONSTANT FCB.NAME
PS2: Alignment after data is not needed when storage is followed
by a definition since Fig word names need not start on a
word boundary (in my build).