summaryrefslogtreecommitdiff
path: root/jefs.fs
blob: 8f38805a498b91eab86b00a8e5c23a33a4f3d0e9 (plain)
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
33
34
35
36
37
38
39
: cell+ 8 + ;
: syswrite ( u c-addr fd -- n ) 1 syscall3 ;
: say ( c-addr u -- ) swap 1 syswrite drop ;
: emit ( chr -- ) sp cell+ 1 swap 1 syswrite 2drop ;
: cr 10 emit ;

: decimal 10 base ! ;
: hex 16 base ! ;

hex
: ret, c3 c, ;
decimal

: cells 8 * ;
: allot here @ swap here +! ;

: [compile] parse find drop >cfa compile, ; immediate
: ' parse find drop >cfa [compile] lit ; immediate \ note: no error handling (yet)
: literal [compile] lit ; immediate
: constant create [compile] lit ret, ;
: variable 1 cells allot create [compile] lit ret, ;

\ TODO interpret mode strings?
: s" [ char " ] literal >in @ 1 + >in ! ( skip spc ) [compile] litstring ; immediate
: ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting

: begin here @ ; immediate
: again branch here @ 4 + - d, ; immediate \ add 4 to get to beginning of the next instruction
: until 0branch here @ 4 + - d, ; immediate
: if 0branch here @ 0 d, ; immediate ( I: -- a )
: else branch here @ 0 d, swap dup here @ swap - 4 - swap d! ; immediate
: then dup here @ swap - 4 - swap d! ; immediate

: / /mod swap drop ;
: mod /mod drop ;

: testing 0 if TESTSTR else TESTSTR2 then say cr ;

testing bye