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 | |
| 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 ) ; |
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 |