blob: 74aff9d32ae41b47a7dba4844326e8853fed1776 [file] [log] [blame]
swissChili7c626b92022-01-01 23:35:39 -08001\ Core words for DOS FORTH
2
swissChilie4d2e282022-01-04 22:22:27 -08003: NIP SWAP DROP ;
swissChili94f1e762022-01-29 21:55:45 -08004: / /MOD NIP ;
5: MOD /MOD DROP ;
6
7: LITERAL IMMEDIATE ' LIT , , ;
8: [COMPILE] IMMEDIATE WORD FIND >CFA , ;
9: RECURSE IMMEDIATE LATEST , >CFA , ;
10
11\ Control structures
12
13\ cond IF <*b0> true ELSE false THEN rest
14: IF ( -- *then ) IMMEDIATE ' 0BRANCH , HERE @ 0 , ;
15
16: THEN ( *then -- *then ) IMMEDIATE
17 DUP HERE @ SWAP ( *then *then *here )
18 SWAP - ( *then *here-*then )
19 SWAP ! ;
20
21: ELSE ( *then -- *here ) IMMEDIATE
22 ' BRANCH ,
23 HERE @ ( *then *ph )
24 0 ,
25 SWAP ( *ph *then )
26 DUP ( *ph *then *then )
27 HERE @ ( *ph *then *then *here )
28 SWAP - ( *ph *then diff )
29 SWAP ! ( *ph ) ;
swissChili7c626b92022-01-01 23:35:39 -080030
swissChilie4d2e282022-01-04 22:22:27 -080031DUMP-IMAGE FORTH.COM
32BYE