swissChili | 7c626b9 | 2022-01-01 23:35:39 -0800 | [diff] [blame] | 1 | \ Core words for DOS FORTH |
| 2 | |
swissChili | e4d2e28 | 2022-01-04 22:22:27 -0800 | [diff] [blame] | 3 | : NIP SWAP DROP ; |
swissChili | 94f1e76 | 2022-01-29 21:55:45 -0800 | [diff] [blame] | 4 | : / /MOD NIP ; |
| 5 | : MOD /MOD DROP ; |
| 6 | |
swissChili | ce85f57 | 2022-04-20 16:54:34 -0700 | [diff] [blame^] | 7 | : LITERAL IMMED ' LIT , , ; |
| 8 | : [COMPILE] IMMED WORD FIND >CFA , ; |
| 9 | : RECURSE IMMED LATEST , >CFA , ; |
swissChili | 94f1e76 | 2022-01-29 21:55:45 -0800 | [diff] [blame] | 10 | |
| 11 | \ Control structures |
| 12 | |
| 13 | \ cond IF <*b0> true ELSE false THEN rest |
swissChili | ce85f57 | 2022-04-20 16:54:34 -0700 | [diff] [blame^] | 14 | : IF ( -- *then ) IMMED ' 0BRANCH , HERE @ 0 , ; |
swissChili | 94f1e76 | 2022-01-29 21:55:45 -0800 | [diff] [blame] | 15 | |
swissChili | ce85f57 | 2022-04-20 16:54:34 -0700 | [diff] [blame^] | 16 | : THEN ( *then -- *then ) IMMED |
swissChili | 94f1e76 | 2022-01-29 21:55:45 -0800 | [diff] [blame] | 17 | DUP HERE @ SWAP ( *then *then *here ) |
| 18 | SWAP - ( *then *here-*then ) |
| 19 | SWAP ! ; |
| 20 | |
swissChili | ce85f57 | 2022-04-20 16:54:34 -0700 | [diff] [blame^] | 21 | : ELSE ( *then -- *here ) IMMED |
swissChili | 94f1e76 | 2022-01-29 21:55:45 -0800 | [diff] [blame] | 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 ) ; |
swissChili | 7c626b9 | 2022-01-01 23:35:39 -0800 | [diff] [blame] | 30 | |
swissChili | e4d2e28 | 2022-01-04 22:22:27 -0800 | [diff] [blame] | 31 | DUMP-IMAGE FORTH.COM |
| 32 | BYE |