-
Notifications
You must be signed in to change notification settings - Fork 3
/
lib.fs
32 lines (25 loc) · 780 Bytes
/
lib.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(one (line (comment
:\ ^key ^10 ^= ^if ^; ^\ ^;
~\ one line comment
:cr ^10 ^emit ^;
:.s ^. ^. ^. ^. ^. ^. ^. ^. ^cr ^;
:alloc ^here ^@ ^swap ^over ^+ ^here ^! ^;
(create (null-terminated (string
~\ stored in memory as as length, characters...
:"init ^here ^@ ^cell ^+ ^;
:"loop ^dup ^key ^dup ~key " ^= ^if ^; ^swap ^c! ^1 ^+ ^"loop ^;
:"done ^drop ^drop ^here ^@ ^swap ^- ^dup (null ^1 ^+ ^alloc ^swap ^over ^! ^;
:" ^"init ^"loop ^"done ^;
(print (string
:."init ^dup ^dup ^@ ^+ ^swap ^cell ^+ ^;
:."loop ^over ^over ^= ^if ^; ^dup ^c@ ^emit ^1 ^+ ^."loop ^;
:." ^."init ^."loop ^cr ^;
:msg ~" hello world" ^;
~msg ~."
:cmd ^cell ^+ ^system ^;
:uname ~" uname -a" ^cmd ^;
~uname
:square ^dup ^* ^;
~\ calculated at compile time
:25square ~25 ~square ^;
~25square ~. ~cr