blob: b844633cbd6d2333ef57d3100c07b0603a87f92f [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
swissChilice85f572022-04-20 16:54:34 -07007: LITERAL IMMED ' LIT , , ;
8: [COMPILE] IMMED WORD FIND >CFA , ;
9: RECURSE IMMED LATEST , >CFA , ;
swissChili94f1e762022-01-29 21:55:45 -080010
11\ Control structures
12
13\ cond IF <*b0> true ELSE false THEN rest
swissChilice85f572022-04-20 16:54:34 -070014: IF ( -- *then ) IMMED ' 0BRANCH , HERE @ 0 , ;
swissChili94f1e762022-01-29 21:55:45 -080015
swissChilice85f572022-04-20 16:54:34 -070016: THEN ( *then -- *then ) IMMED
swissChili94f1e762022-01-29 21:55:45 -080017 DUP HERE @ SWAP ( *then *then *here )
18 SWAP - ( *then *here-*then )
19 SWAP ! ;
20
swissChilice85f572022-04-20 16:54:34 -070021: ELSE ( *then -- *here ) IMMED
swissChili94f1e762022-01-29 21:55:45 -080022 ' 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