OSDN Git Service

v 162, added Conditionnal Compilation and bootloader
[fast-forth/master.git] / FastForthWords.txt
1
2 FORTH vocabulary
3 ----------------
4 ASM             CODE            HI2LO           COLD            WARM            (WARM)          WIPE            RST_HERE        
5 PWR_HERE        RST_STATE       PWR_STATE       MOVE            LEAVE           +LOOP           LOOP            DO              
6 REPEAT          WHILE           AGAIN           UNTIL           BEGIN           THEN            ELSE            IF              
7 ;               :               DEFER           DOES>           CREATE          CONSTANT        VARIABLE        POSTPONE        
8 RECURSE         IMMEDIATE       IS              [']             ]               [               \               '               
9 ABORT"          ABORT           QUIT            EVALUATE        COUNT           LITERAL         ,               EXECUTE         
10 >NUMBER         FIND            WORD            ."              S"              TYPE            SPACES          SPACE           
11 CR              (CR)            NOECHO          ECHO            EMIT            (EMIT)          (ACCEPT)        ACCEPT          
12 KEY             (KEY)           C,              ALLOT           HERE            .               D.              U.              
13 SIGN            HOLD            #>              #S              #               <#              BL              STATE           
14 BASE            >IN             CPL             TIB             PAD             J               I               UNLOOP          
15 U<              >               <               =               0>              0<              0=              DABS            
16 ABS             NEGATE          XOR             OR              AND             -               +               C!              
17 C@              !               @               DEPTH           R@              R>              >R              ROT             
18 OVER            SWAP            NIP             DROP            ?DUP            DUP             LIT             EXIT
19
20
21 ASSEMBLER vocabulary
22 --------------------
23 ?GOTO           GOTO            FW3             FW2             FW1             BW3             BW2             BW1          
24 ?JMP            JMP             REPEAT          WHILE           AGAIN           UNTIL           ELSE            THEN         
25 IF              0=              0<>             U>=             U<              0<              0>=             S<           
26 S>=             RRUM            RLAM            RRAM            RRCM            POPM            PUSHM           CALL         
27 PUSH.B          PUSH            SXT             RRA.B           RRA             SWPB            RRC.B           RRC          
28 AND.B           AND             XOR.B           XOR             BIS.B           BIS             BIC.B           BIC          
29 BIT.B           BIT             DADD.B          DADD            CMP.B           CMP             SUB.B           SUB          
30 SUBC.B          SUBC            ADDC.B          ADDC            ADD.B           ADD             MOV.B           MOV          
31 RETI            LO2HI           COLON           ENDASM          ENDCODE         (SLEEP)         SLEEP
32
33
34 CONDCOMP ADD-ON
35 ---------------
36 [DEFINED]       [UNDEFINED]     [IF]            [ELSE]          [THEN]          COMPARE         MARKER        
37
38
39 VOCABULARY ADD-ON
40 -----------------
41 DEFINITIONS     ONLY            PREVIOUS        ALSO            ASSEMBLER       FORTH           VOCABULARY
42
43
44 ANS_COMPLEMENT ADD-ON
45 ---------------------
46 >BODY           SOURCE          .(              (               DECIMAL         HEX             FILL            [CHAR]          
47 CHAR            +!              MIN             MAX             2/              2*              1-              1+              
48 RSHIFT          LSHIFT          INVERT          2OVER           2SWAP           2DROP           2DUP            2!              
49 2@              S>D             CELL+           CELLS           CHAR+           CHARS           ALIGN           ALIGNED         
50 */              */MOD           MOD             /               /MOD            *               FM/MOD          SM/REM          
51 UM/MOD          M*              UM*             {ANS_COMP}
52
53
54 SD_CARD_LOADER ADD-ON
55 ---------------------
56 LOAD"           {SD_LOAD}
57
58
59 SD_CARD_READ_WRITE ADD-ON
60 -------------------------
61 TERM2SD"        SD_EMIT         WRITE           READ            CLOSE           DEL"            WRITE"          READ"
62
63
64 UTILITY ADD-ON
65 --------------
66 DUMP            U.R             WORDS           ?               .RS             .S              {UTILITY}       
67
68
69 SD_TOOLS ADD-ON
70 ---------------
71 DIR             FAT             CLUSTER         SECTOR          {SD_TOOLS}
72
73
74 ; a word within brackets [] is an immediate word. (other words may also be immediate)
75 ; a word doubled with another word between parentheses () is a DEFERred word, the first being initialised with the second.
76 ; when ADD-ONs are compiled into the kernel, their respective MARKER word identified with braces {}  does nothing.
77
78 ; the words that are not commented are ANS94 compliant; search for their definition here: https://forth-standard.org/search
79
80
81 FORTH WORDS
82
83 ASM <word> --       used to begin an assembler word which is not interpretable by FORTH (because use of CALL ... RET).
84                     this defined <word> must be ended with ENDASM.
85
86 CODE <word> --      begins an assembler word interpretable by FORTH (MOV @IP+,PC instead of CALL ... RET)
87                     this defined <word> must be ended with ENDCODE.
88
89 HI2LO --            used to switch from a high level (FORTH) to low level (assembler) modes.
90
91 COLD --             Software reset
92
93 WARM --             DEFERred word initialized by default with (WARM)
94
95 (WARM) --           performs a hot start
96
97 WIPE --             resets the program memory to its original state before any add.
98
99 RST_HERE --         defines the bound of the program memory protected against COLD or hardware reset.
100
101 PWR_HERE --         defines the bound of the program memory protected against ON/OFF.
102
103 RST_STATE --        remove all words defined after RST_HERE
104
105 PWR_STATE --        remove all words defined after PWR_HERE
106
107 MOVE
108 LEAVE           
109 +LOOP           
110 LOOP            
111 DO              
112 REPEAT          
113 WHILE           
114 AGAIN           
115 UNTIL           
116 BEGIN           
117 THEN            
118 ELSE            
119 IF              
120 ;               
121 :               
122 DEFER           
123 DOES>           
124 CREATE          
125 CONSTANT        
126 VARIABLE        
127 POSTPONE        
128 RECURSE         
129 IMMEDIATE       
130 IS              
131 [']             
132 ]               
133 [               
134 \               
135 '               
136 ABORT"          
137 ABORT           
138 QUIT            
139 EVALUATE        
140 COUNT           
141 LITERAL         
142 ,               
143 EXECUTE         
144 >NUMBER         
145 FIND            
146 WORD            
147 ."              
148 S"              
149 TYPE            
150 SPACES          
151 SPACE           
152 CR              
153 (CR)            
154 NOECHO          
155 ECHO            
156 EMIT            
157 (EMIT)          
158 (ACCEPT)        
159 ACCEPT          
160 KEY             
161 (KEY)           
162 C,              
163 ALLOT           
164 HERE            
165 .               
166 D.              
167 U.              
168 SIGN            
169 HOLD            
170 #>              
171 #S              
172 #               
173 <#              
174 BL              
175 STATE           
176 BASE            
177 >IN             
178 CPL     -- size         of terminal input buffer TIB
179 TIB     -- addr         of terminal input buffer TIB            
180 PAD     -- addr         of PAD            
181 J               
182 I               
183 UNLOOP          
184 U<              
185 >               
186 <               
187 =               
188 0>              
189 0<              
190 0=              
191 DABS            
192 ABS             
193 NEGATE          
194 XOR             
195 OR              
196 AND             
197 -               
198 +               
199 C!              
200 C@              
201 !               
202 @               
203 DEPTH           
204 R@              
205 R>              
206 >R              
207 ROT             
208 OVER            
209 SWAP            
210 NIP             
211 DROP            
212 ?DUP            
213 DUP             
214 LIT --          execution part of LITERAL            
215 EXIT
216
217
218
219 ASSEMBLER WORDS see: http://www.ece.utep.edu/courses/web3376/Notes_files/ee3376-isa.pdf
220                      http://www.ti.com/lit/ug/slau367n/slau367n.pdf#page=158
221                      howto.md for symbolic alias of registers, symbolic jumps (IF ELSE THEN...),..
222
223
224
225 ?GOTO           used after a conditionnal to branch to a label FWx or BWx
226 GOTO            used as unconditionnal branch to a label FWx or BWx
227
228 FW3             FORWARD branch destination n°3
229 FW2             
230 FW1             
231
232 BW3             BACKWARD branch destination n°3
233 BW2             
234 BW1          
235
236 ?JMP            used after a conditionnal to jump to a defined word
237 JMP             unconditionnal jump to a defined word
238
239 REPEAT          assembler version of the FORTH word REPEAT
240 WHILE           idem
241 AGAIN           idem
242 UNTIL           idem
243 ELSE            idem
244 THEN            idem
245 IF              idem
246
247 0=              conditionnal     
248 0<>             conditionnal
249 U>=             conditionnal
250 U<              conditionnal
251 0<              conditionnal, to use only with ?JMP ?GOTO
252 0>=             conditionnal, to use only with IF UNTIL WHILE
253 S<              conditionnal
254 S>=             conditionnal
255
256 RRUM            used as : RRUM n,REG   with 0 < n < 5
257 RLAM            same syntax
258 RRAM            same syntax
259 RRCM            same syntax
260 POPM            POP multiple registers, used as : POPM X,S  to pop X,W,T,S
261 PUSHM           PUSH multiple registers, used as : PUSHM S,X   to push S,T,W,X
262
263 CALL            see TI assembler
264 PUSH.B          
265 PUSH            
266 SXT             
267 RRA.B           
268 RRA             
269 SWPB            
270 RRC.B           
271 RRC          
272 AND.B           
273 AND             
274 XOR.B           
275 XOR             
276 BIS.B           
277 BIS             
278 BIC.B           
279 BIC          
280 BIT.B           
281 BIT             
282 DADD.B          
283 DADD            
284 CMP.B           
285 CMP             
286 SUB.B           
287 SUB          
288 SUBC.B          
289 SUBC            
290 ADDC.B          
291 ADDC            
292 ADD.B           
293 ADD             
294 MOV.B           
295 MOV          
296 RETI            
297
298 LO2HI           switch between low level and high level interpretation mode (counterpart of HI2LO), without saving IP.
299 COLON           PUSH IP then performs LO2HI, used as CODE <word> ... assembler cmd ... COLON ... FORTH words ... ;
300 ENDASM          to end an ASM definition
301 ENDCODE         to end a CODE definition
302 (SLEEP)         the default SLEEP definition
303 SLEEP           DEFERred word initialised with (SLEEP), which enables to create a background task.
304
305
306 CONDCOMP ADD-ON
307 ---------------
308 [DEFINED]  
309 [UNDEFINED]
310 [IF]
311 [ELSE]
312 [THEN]
313 COMPARE                 
314 MARKER