[gforth] / gforth / cross.fs  

gforth: gforth/cross.fs


1 : anton 1.1 \ CROSS.FS The Cross-Compiler 06oct92py
2 :     \ Idea and implementation: Bernd Paysan (py)
3 : anton 1.30
4 : anton 1.69 \ Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
5 : anton 1.30
6 :     \ This file is part of Gforth.
7 :    
8 :     \ Gforth is free software; you can redistribute it and/or
9 :     \ modify it under the terms of the GNU General Public License
10 :     \ as published by the Free Software Foundation; either version 2
11 :     \ of the License, or (at your option) any later version.
12 :    
13 :     \ This program is distributed in the hope that it will be useful,
14 :     \ but WITHOUT ANY WARRANTY; without even the implied warranty of
15 :     \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     \ GNU General Public License for more details.
17 :    
18 :     \ You should have received a copy of the GNU General Public License
19 :     \ along with this program; if not, write to the Free Software
20 :     \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 : anton 1.1
22 : jwilke 1.67 0
23 :     [IF]
24 :    
25 :     ToDo:
26 :     Crossdoc destination ./doc/crossdoc.fd makes no sense when
27 :     cross.fs is uses seperately. jaw
28 :     Do we need this char translation with >address and in branchoffset?
29 :     (>body also affected) jaw
30 :     Clean up mark> and >resolve stuff jaw
31 :    
32 :     [THEN]
33 : anton 1.48
34 :    
35 : jwilke 1.52 hex \ the defualt base for the cross-compiler is hex !!
36 :     Warnings off
37 :    
38 :     \ words that are generaly useful
39 :    
40 : pazsan 1.59 : KB 400 * ;
41 : jwilke 1.52 : >wordlist ( vocabulary-xt -- wordlist-struct )
42 :     also execute get-order swap >r 1- set-order r> ;
43 :    
44 :     : umax 2dup u< IF swap THEN drop ;
45 :     : umin 2dup u> IF swap THEN drop ;
46 : anton 1.1
47 : pazsan 1.23 : string, ( c-addr u -- )
48 :     \ puts down string as cstring
49 :     dup c, here swap chars dup allot move ;
50 : pazsan 1.5
51 : jwilke 1.52 : SetValue ( n -- <name> )
52 : pazsan 1.54 \G Same behaviour as "Value" if the <name> is not defined
53 :     \G Same behaviour as "to" if <name> is defined
54 : jwilke 1.52 \G SetValue searches in the current vocabulary
55 : jwilke 1.68 save-input bl word >r restore-input throw r> count
56 :     get-current search-wordlist
57 :     IF drop >r
58 :     \ we have to set current to be topmost context wordlist
59 :     get-order get-order get-current swap 1+ set-order
60 :     r> ['] to execute
61 :     set-order order
62 :     ELSE Value THEN ;
63 : jwilke 1.52
64 :     : DefaultValue ( n -- <name> )
65 : pazsan 1.54 \G Same behaviour as "Value" if the <name> is not defined
66 :     \G DefaultValue searches in the current vocabulary
67 : jwilke 1.52 save-input bl word >r restore-input throw r> count
68 :     get-current search-wordlist
69 : pazsan 1.56 IF bl word drop 2drop ELSE Value THEN ;
70 : anton 1.1
71 :     hex
72 :    
73 :     Vocabulary Cross
74 :     Vocabulary Target
75 :     Vocabulary Ghosts
76 :     VOCABULARY Minimal
77 :     only Forth also Target also also
78 :     definitions Forth
79 :    
80 :     : T previous Cross also Target ; immediate
81 :     : G Ghosts ; immediate
82 :     : H previous Forth also Cross ; immediate
83 :    
84 :     forth definitions
85 :    
86 :     : T previous Cross also Target ; immediate
87 :     : G Ghosts ; immediate
88 :    
89 :     : >cross also Cross definitions previous ;
90 :     : >target also Target definitions previous ;
91 :     : >minimal also Minimal definitions previous ;
92 :    
93 :     H
94 :    
95 :     >CROSS
96 :    
97 : jwilke 1.52 \ 1 Constant Cross-Flag \ to check whether assembler compiler plug-ins are
98 :     \ for cross-compiling
99 :     \ No! we use "[IFUNDEF]" there to find out whether we are target compiling!!!
100 :    
101 :     : comment? ( c-addr u -- c-addr u )
102 :     2dup s" (" compare 0=
103 :     IF postpone (
104 :     ELSE 2dup s" \" compare 0= IF postpone \ THEN
105 :     THEN ;
106 :    
107 :     \ Begin CROSS COMPILER:
108 :    
109 :    
110 :    
111 :     \ \ -------------------- Error Handling 05aug97jaw
112 :    
113 :     \ Flags
114 :    
115 :     also forth definitions \ these values may be predefined before
116 :     \ the cross-compiler is loaded
117 :    
118 :     false DefaultValue stack-warn \ check on empty stack at any definition
119 :     false DefaultValue create-forward-warn \ warn on forward declaration of created words
120 :    
121 :     [IFUNDEF] DebugMaskSrouce Variable DebugMaskSource 0 DebugMaskSource ! [THEN]
122 :     [IFUNDEF] DebugMaskCross Variable DebugMaskCross 0 DebugMaskCross ! [THEN]
123 :    
124 :     previous >CROSS
125 :    
126 : jwilke 1.53 : .dec
127 :     base @ decimal swap . base ! ;
128 :    
129 : jwilke 1.52 : .sourcepos
130 :     cr sourcefilename type ." :"
131 : jwilke 1.53 sourceline# .dec ;
132 : jwilke 1.52
133 :     : warnhead
134 :     \G display error-message head
135 :     \G perhaps with linenumber and filename
136 :     .sourcepos ." Warning: " ;
137 :    
138 :     : empty? depth IF .sourcepos ." Stack not empty!" THEN ;
139 :    
140 :     stack-warn [IF]
141 :     : defempty? empty? ;
142 :     [ELSE]
143 :     : defempty? ; immediate
144 :     [THEN]
145 :    
146 :    
147 : pazsan 1.54
148 : jwilke 1.52 \ \ GhostNames Ghosts 9may93jaw
149 :    
150 :     \ second name source to search trough list
151 :    
152 :     VARIABLE GhostNames
153 :     0 GhostNames !
154 :    
155 :     : GhostName ( -- addr )
156 :     here GhostNames @ , GhostNames ! here 0 ,
157 :     bl word count
158 :     \ 2dup type space
159 :     string, \ !! cfalign ?
160 :     align ;
161 :    
162 :     \ Ghost Builder 06oct92py
163 :    
164 :     \ <T T> new version with temp variable 10may93jaw
165 :    
166 :     VARIABLE VocTemp
167 :    
168 :     : <T get-current VocTemp ! also Ghosts definitions ;
169 :     : T> previous VocTemp @ set-current ;
170 :    
171 :     hex
172 :     4711 Constant <fwd> 4712 Constant <res>
173 :     4713 Constant <imm> 4714 Constant <do:>
174 :    
175 :     \ iForth makes only immediate directly after create
176 :     \ make atonce trick! ?
177 :    
178 :     Variable atonce atonce off
179 :    
180 :     : NoExec true ABORT" CROSS: Don't execute ghost" ;
181 :    
182 :     : GhostHeader <fwd> , 0 , ['] NoExec , ;
183 :    
184 :     : >magic ; \ type of ghost
185 :     : >link cell+ ; \ pointer where ghost is in target, or if unresolved
186 :     \ points to the where we have to resolve (linked-list)
187 :     : >exec cell+ cell+ ; \ execution symantics (while target compiling) of ghost
188 :     : >end 3 cells + ; \ room for additional tags
189 :     \ for builder (create, variable...) words the
190 :     \ execution symantics of words built are placed here
191 :    
192 :     Variable executed-ghost \ last executed ghost, needed in tcreate and gdoes>
193 :     Variable last-ghost \ last ghost that is created
194 :     Variable last-header-ghost \ last ghost definitions with header
195 :    
196 :     : Make-Ghost ( "name" -- ghost )
197 :     >in @ GhostName swap >in !
198 :     <T Create atonce @ IF immediate atonce off THEN
199 :     here tuck swap ! ghostheader T>
200 :     dup last-ghost !
201 :     DOES> dup executed-ghost ! >exec @ execute ;
202 :    
203 :     \ ghost words 14oct92py
204 :     \ changed: 10may93py/jaw
205 :    
206 :     : gfind ( string -- ghost true/1 / string false )
207 :     \ searches for string in word-list ghosts
208 :     dup count [ ' ghosts >wordlist ] ALiteral search-wordlist
209 :     dup IF >r >body nip r> THEN ;
210 :    
211 :     : gdiscover ( xt -- ghost true | xt false )
212 :     GhostNames
213 :     BEGIN @ dup
214 :     WHILE 2dup
215 :     cell+ @ dup >magic @ <fwd> <>
216 :     >r >link @ = r> and
217 :     IF cell+ @ nip true EXIT THEN
218 :     REPEAT
219 :     drop false ;
220 :    
221 :     VARIABLE Already
222 :    
223 :     : ghost ( "name" -- ghost )
224 :     Already off
225 :     >in @ bl word gfind IF Already on nip EXIT THEN
226 :     drop >in ! Make-Ghost ;
227 :    
228 :     : >ghostname ( ghost -- adr len )
229 :     GhostNames
230 :     BEGIN @ dup
231 :     WHILE 2dup cell+ @ =
232 :     UNTIL nip 2 cells + count
233 : pazsan 1.54 ELSE 2drop
234 :     \ true abort" CROSS: Ghostnames inconsistent"
235 :     s" ?!?!?!"
236 : jwilke 1.52 THEN ;
237 :    
238 :     ' >ghostname ALIAS @name
239 :    
240 :     : forward? ( ghost -- flag )
241 :     >magic @ <fwd> = ;
242 :    
243 :     \ Predefined ghosts 12dec92py
244 :    
245 :     ghost 0= drop
246 :     ghost branch ghost ?branch 2drop
247 :     ghost (do) ghost (?do) 2drop
248 :     ghost (for) drop
249 :     ghost (loop) ghost (+loop) 2drop
250 :     ghost (next) drop
251 :     ghost unloop ghost ;S 2drop
252 :     ghost lit ghost (compile) ghost ! 2drop drop
253 :     ghost (does>) ghost noop 2drop
254 :     ghost (.") ghost (S") ghost (ABORT") 2drop drop
255 :     ghost ' drop
256 :     ghost :docol ghost :doesjump ghost :dodoes 2drop drop
257 : pazsan 1.54 ghost :dovar drop
258 : jwilke 1.52 ghost over ghost = ghost drop 2drop drop
259 :     ghost - drop
260 : pazsan 1.54 ghost 2drop drop
261 :     ghost 2dup drop
262 : jwilke 1.52
263 :     \ \ Parameter for target systems 06oct92py
264 :    
265 :     \ we define it ans like...
266 :     wordlist Constant target-environment
267 :    
268 :     VARIABLE env-current \ save information of current dictionary to restore with environ>
269 :    
270 :     : >ENVIRON get-current env-current ! target-environment set-current ;
271 :     : ENVIRON> env-current @ set-current ;
272 : pazsan 1.43
273 : anton 1.48 >TARGET
274 : pazsan 1.43
275 : jwilke 1.67 : environment? ( adr len -- [ x ] true | false )
276 : jwilke 1.52 target-environment search-wordlist
277 :     IF execute true ELSE false THEN ;
278 :    
279 : jwilke 1.67 : e? bl word count T environment? H 0= ABORT" environment variable not defined!" ;
280 : jwilke 1.52
281 : jwilke 1.67 : has? bl word count T environment? H
282 : jwilke 1.53 IF \ environment variable is present, return its value
283 :     ELSE \ environment variable is not present, return false
284 :     \ !! JAW abort is just for testing
285 :     false true ABORT" arg"
286 :     THEN ;
287 : jwilke 1.52
288 :     : $has? T environment? H IF ELSE false THEN ;
289 : anton 1.48
290 : pazsan 1.54 >ENVIRON get-order get-current swap 1+ set-order
291 :     true SetValue compiler
292 : jwilke 1.53 true SetValue cross
293 : pazsan 1.54 true SetValue standard-threading
294 :     >TARGET previous
295 : jwilke 1.52
296 : pazsan 1.59
297 : jwilke 1.52 mach-file count included hex
298 : pazsan 1.43
299 : jwilke 1.53 >ENVIRON
300 :    
301 : pazsan 1.54 T has? ec H
302 :     [IF]
303 :     false DefaultValue relocate
304 :     false DefaultValue file
305 :     false DefaultValue OS
306 :     false DefaultValue prims
307 :     false DefaultValue floating
308 :     false DefaultValue glocals
309 :     false DefaultValue dcomps
310 :     false DefaultValue hash
311 :     false DefaultValue xconds
312 :     false DefaultValue header
313 :     [THEN]
314 :    
315 :     true DefaultValue interpreter
316 :     true DefaultValue ITC
317 :     false DefaultValue rom
318 : jwilke 1.53
319 : jwilke 1.52 >TARGET
320 : jwilke 1.53 s" relocate" T environment? H
321 :     [IF] SetValue NIL
322 :     [ELSE] >ENVIRON T NIL H SetValue relocate
323 :     [THEN]
324 : pazsan 1.43
325 :     >CROSS
326 :    
327 : jwilke 1.52 \ \ Create additional parameters 19jan95py
328 : pazsan 1.19
329 : jwilke 1.71 \ currently cross only works for host machines with address-unit-bits
330 :     \ eual to 8 because of s! and sc!
331 :     \ but I start to query the environment just to modularize a little bit
332 :    
333 :     : check-address-unit-bits ( -- )
334 :     \ s" ADDRESS-UNIT-BITS" environment?
335 :     \ IF 8 <> ELSE true THEN
336 :     \ ABORT" ADDRESS-UNIT-BITS unknown or not equal to 8!"
337 :    
338 :     \ shit, this doesn't work because environment? is only defined for
339 :     \ gforth.fi and not kernl???.fi
340 :     ;
341 :    
342 :     check-address-unit-bits
343 :     8 Constant bits/byte \ we define: byte is address-unit
344 :    
345 :     1 bits/byte lshift Constant maxbyte
346 : jwilke 1.67 \ this sets byte size for the target machine, an (probably right guess) jaw
347 :    
348 : pazsan 1.19 T
349 : jwilke 1.71 NIL Constant TNIL
350 :     cell Constant tcell
351 :     cell<< Constant tcell<<
352 :     cell>bit Constant tcell>bit
353 :     bits/char Constant tbits/char
354 :     bits/char H bits/byte T /
355 :     Constant tchar
356 :     float Constant tfloat
357 :     1 bits/char lshift Constant tmaxchar
358 :     [IFUNDEF] bits/byte
359 :     8 Constant tbits/byte
360 :     [ELSE]
361 :     bits/byte Constant tbits/byte
362 :     [THEN]
363 : pazsan 1.19 H
364 : jwilke 1.71 tbits/byte bits/byte / Constant tbyte
365 :    
366 : pazsan 1.19
367 : anton 1.48 \ Variables 06oct92py
368 :    
369 :     Variable image
370 :     Variable tlast TNIL tlast ! \ Last name field
371 :     Variable tlastcfa \ Last code field
372 :     Variable tdoes \ Resolve does> calls
373 :     Variable bit$
374 : jwilke 1.52
375 :     \ statistics 10jun97jaw
376 :    
377 :     Variable headers-named 0 headers-named !
378 :     Variable user-vars 0 user-vars !
379 :    
380 :     \ Memory initialisation 05dec92py
381 :    
382 :     [IFDEF] Memory \ Memory is a bigFORTH feature
383 :     also Memory
384 :     : initmem ( var len -- )
385 :     2dup swap handle! >r @ r> erase ;
386 :     toss
387 :     [ELSE]
388 :     : initmem ( var len -- )
389 :     tuck allocate abort" CROSS: No memory for target"
390 :     ( len var adr ) dup rot !
391 :     ( len adr ) swap erase ;
392 :     [THEN]
393 :    
394 :     \ MakeKernal 12dec92py
395 :    
396 :     : makekernel ( targetsize -- targetsize )
397 :     bit$ over 1- tcell>bit rshift 1+ initmem
398 :     image over initmem ;
399 :    
400 :     >MINIMAL
401 :     : makekernel makekernel ;
402 : jwilke 1.67 >CROSS
403 :    
404 :     : target>bitmask-size ( u1 -- u2 )
405 :     1- tcell>bit rshift 1+ ;
406 :    
407 :     : allocatetarget ( size --- adr )
408 :     dup allocate ABORT" CROSS: No memory for target"
409 :     swap over swap erase ;
410 : jwilke 1.52
411 :    
412 :    
413 : pazsan 1.54 \ \ memregion.fs
414 : jwilke 1.52
415 :    
416 :     Variable last-defined-region \ pointer to last defined region
417 :     Variable region-link \ linked list with all regions
418 :     Variable mirrored-link \ linked list for mirrored regions
419 :     0 dup mirrored-link ! region-link !
420 :    
421 :    
422 : jwilke 1.67 : >rname 6 cells + ;
423 :     : >rbm 5 cells + ;
424 :     : >rmem 4 cells + ;
425 :     : >rlink 3 cells + ;
426 : jwilke 1.52 : >rdp 2 cells + ;
427 :     : >rlen cell+ ;
428 :     : >rstart ;
429 :    
430 :    
431 :     : region ( addr len -- ) \G create a new region
432 :     \ check whether predefined region exists
433 :     save-input bl word find >r >r restore-input throw r> r> 0=
434 :     IF \ make region
435 :     drop
436 :     save-input create restore-input throw
437 :     here last-defined-region !
438 :     over ( startaddr ) , ( length ) , ( dp ) ,
439 : jwilke 1.67 region-link linked 0 , 0 , bl word count string,
440 : jwilke 1.52 ELSE \ store new parameters in region
441 :     bl word drop
442 :     >body >r r@ last-defined-region !
443 : jwilke 1.67 r@ >rlen ! dup r@ >rstart ! r> >rdp !
444 : jwilke 1.52 THEN ;
445 :    
446 :     : borders ( region -- startaddr endaddr ) \G returns lower and upper region border
447 : jwilke 1.67 dup >rstart @ swap >rlen @ over + ;
448 : jwilke 1.52
449 :     : extent ( region -- startaddr len ) \G returns the really used area
450 : jwilke 1.67 dup >rstart @ swap >rdp @ over - ;
451 : jwilke 1.52
452 :     : area ( region -- startaddr totallen ) \G returns the total area
453 : jwilke 1.67 dup >rstart swap >rlen @ ;
454 : jwilke 1.52
455 :     : mirrored \G mark a region as mirrored
456 :     mirrored-link
457 : jwilke 1.68 align linked last-defined-region @ , ;
458 : jwilke 1.52
459 : jwilke 1.67 : .addr ( u -- )
460 :     \G prints a 16 or 32 Bit nice hex value
461 : jwilke 1.52 base @ >r hex
462 :     tcell 2 u>
463 :     IF s>d <# # # # # '. hold # # # # #> type
464 :     ELSE s>d <# # # # # # #> type
465 :     THEN r> base ! ;
466 :    
467 :     : .regions \G display region statistic
468 :    
469 :     \ we want to list the regions in the right order
470 :     \ so first collect all regions on stack
471 :     0 region-link @
472 :     BEGIN dup WHILE dup @ REPEAT drop
473 :     BEGIN dup
474 : jwilke 1.67 WHILE cr
475 :     0 >rlink - >r
476 :     r@ >rname count tuck type
477 : jwilke 1.52 12 swap - 0 max spaces space
478 : jwilke 1.67 ." Start: " r@ >rstart @ dup .addr space
479 :     ." End: " r@ >rlen @ + .addr space
480 :     ." DP: " r> >rdp @ .addr
481 : jwilke 1.52 REPEAT drop
482 : jwilke 1.53 s" rom" T $has? H 0= ?EXIT
483 : jwilke 1.52 cr ." Mirrored:"
484 :     mirrored-link @
485 :     BEGIN dup
486 : jwilke 1.67 WHILE space dup cell+ @ >rname count type @
487 : jwilke 1.52 REPEAT drop cr
488 :     ;
489 :    
490 :     \ -------- predefined regions
491 :    
492 :     0 0 region address-space
493 :     \ total memory addressed and used by the target system
494 :    
495 :     0 0 region dictionary
496 :     \ rom area for the compiler
497 :    
498 : jwilke 1.53 T has? rom H
499 : jwilke 1.52 [IF]
500 :     0 0 region ram-dictionary mirrored
501 :     \ ram area for the compiler
502 :     [ELSE]
503 :     ' dictionary ALIAS ram-dictionary
504 :     [THEN]
505 :    
506 :     0 0 region return-stack
507 :    
508 :     0 0 region data-stack
509 :    
510 :     0 0 region tib-region
511 :    
512 :     ' dictionary ALIAS rom-dictionary
513 :    
514 :    
515 :     : setup-target ( -- ) \G initialize targets memory space
516 : jwilke 1.53 s" rom" T $has? H
517 : jwilke 1.52 IF \ check for ram and rom...
518 : jwilke 1.67 address-space area nip 0<>
519 :     ram-dictionary area nip 0<>
520 :     rom-dictionary area nip 0<>
521 : jwilke 1.52 and and 0=
522 :     ABORT" CROSS: define address-space, rom- , ram-dictionary, with rom-support!"
523 :     THEN
524 :     address-space area nip
525 :     IF
526 :     address-space area
527 :     ELSE
528 :     dictionary area
529 :     THEN
530 : jwilke 1.67 nip 0=
531 : jwilke 1.52 ABORT" CROSS: define at least address-space or dictionary!!"
532 : jwilke 1.67
533 :     \ allocate target for each region
534 :     region-link
535 :     BEGIN @ dup
536 :     WHILE dup
537 :     0 >rlink - >r
538 :     r@ >rlen @
539 :     IF \ allocate mem
540 :     r@ >rlen @ dup
541 :    
542 :     allocatetarget dup image !
543 :     r@ >rmem !
544 :    
545 :     target>bitmask-size allocatetarget
546 :     dup
547 :     bit$ !
548 :     r> >rbm !
549 :    
550 :     ELSE r> drop THEN
551 :     REPEAT ;
552 : jwilke 1.52
553 : pazsan 1.54 \ \ switched tdp for rom support 03jun97jaw
554 : jwilke 1.52
555 :     \ second value is here to store some maximal value for statistics
556 :     \ tempdp is also embedded here but has nothing to do with rom support
557 :     \ (needs switched dp)
558 :    
559 :     variable tempdp 0 , \ temporary dp for resolving
560 :     variable tempdp-save
561 :    
562 :     0 [IF]
563 :     variable romdp 0 , \ Dictionary-Pointer for ramarea
564 :     variable ramdp 0 , \ Dictionary-Pointer for romarea
565 :    
566 :     \
567 :     variable sramdp \ start of ram-area for forth
568 :     variable sromdp \ start of rom-area for forth
569 :    
570 :     [THEN]
571 :    
572 :    
573 :     0 value tdp
574 :     variable fixed \ flag: true: no automatic switching
575 :     \ false: switching is done automatically
576 :    
577 :     \ Switch-Policy:
578 :     \
579 :     \ a header is always compiled into rom
580 :     \ after a created word (create and variable) compilation goes to ram
581 :     \
582 :     \ Be careful: If you want to make the data behind create into rom
583 :     \ you have to put >rom before create!
584 :    
585 :     variable constflag constflag off
586 :    
587 : jwilke 1.67 : activate ( region -- )
588 :     \G next code goes to this region
589 :     >rdp to tdp ;
590 :    
591 : jwilke 1.52 : (switchram)
592 : jwilke 1.53 fixed @ ?EXIT s" rom" T $has? H 0= ?EXIT
593 : jwilke 1.67 ram-dictionary activate ;
594 : jwilke 1.52
595 :     : switchram
596 :     constflag @
597 :     IF constflag off ELSE (switchram) THEN ;
598 :    
599 :     : switchrom
600 : jwilke 1.67 fixed @ ?EXIT rom-dictionary activate ;
601 : jwilke 1.52
602 :     : >tempdp ( addr -- )
603 :     tdp tempdp-save ! tempdp to tdp tdp ! ;
604 :     : tempdp> ( -- )
605 :     tempdp-save @ to tdp ;
606 :    
607 :     : >ram fixed off (switchram) fixed on ;
608 :     : >rom fixed off switchrom fixed on ;
609 :     : >auto fixed off switchrom ;
610 :    
611 :    
612 :    
613 :     \ : romstart dup sromdp ! romdp ! ;
614 :     \ : ramstart dup sramdp ! ramdp ! ;
615 :    
616 : jwilke 1.67 \ default compilation goes to rom
617 : jwilke 1.52 \ when romable support is off, only the rom switch is used (!!)
618 :     >auto
619 :    
620 : anton 1.48 : there tdp @ ;
621 :    
622 : jwilke 1.52 >TARGET
623 : anton 1.48
624 : jwilke 1.52 \ \ Target Memory Handling
625 : anton 1.1
626 :     \ Byte ordering and cell size 06oct92py
627 :    
628 : pazsan 1.19 : cell+ tcell + ;
629 :     : cells tcell<< lshift ;
630 : jwilke 1.71 : chars tchar * ;
631 :     : char+ tchar + ;
632 : pazsan 1.19 : floats tfloat * ;
633 : anton 1.6
634 : anton 1.1 >CROSS
635 : pazsan 1.19 : cell/ tcell<< rshift ;
636 : anton 1.1 >TARGET
637 :     20 CONSTANT bl
638 : jwilke 1.52 \ TNIL Constant NIL
639 : anton 1.1
640 :     >CROSS
641 :    
642 : pazsan 1.20 bigendian
643 :     [IF]
644 : jwilke 1.52 : S! ( n addr -- ) >r s>d r> tcell bounds swap 1-
645 : pazsan 1.20 DO maxbyte ud/mod rot I c! -1 +LOOP 2drop ;
646 : jwilke 1.52 : S@ ( addr -- n ) >r 0 0 r> tcell bounds
647 : pazsan 1.20 DO maxbyte * swap maxbyte um* rot + swap I c@ + swap LOOP d>s ;
648 : pazsan 1.57 : Sc! ( n addr -- ) >r s>d r> tchar bounds swap 1-
649 :     DO maxbyte ud/mod rot I c! -1 +LOOP 2drop ;
650 :     : Sc@ ( addr -- n ) >r 0 0 r> tchar bounds
651 :     DO maxbyte * swap maxbyte um* rot + swap I c@ + swap LOOP d>s ;
652 : pazsan 1.19 [ELSE]
653 : jwilke 1.52 : S! ( n addr -- ) >r s>d r> tcell bounds
654 : pazsan 1.20 DO maxbyte ud/mod rot I c! LOOP 2drop ;
655 : jwilke 1.52 : S@ ( addr -- n ) >r 0 0 r> tcell bounds swap 1-
656 : pazsan 1.20 DO maxbyte * swap maxbyte um* rot + swap I c@ + swap -1 +LOOP d>s ;
657 : pazsan 1.57 : Sc! ( n addr -- ) >r s>d r> tchar bounds
658 :     DO maxbyte ud/mod rot I c! LOOP 2drop ;
659 :     : Sc@ ( addr -- n ) >r 0 0 r> tchar bounds swap 1-
660 :     DO maxbyte * swap maxbyte um* rot + swap I c@ + swap -1 +LOOP d>s ;
661 : anton 1.1 [THEN]
662 :    
663 : jwilke 1.67 : taddr>region ( taddr -- region | 0 )
664 :     \G finds for a target-address the correct region
665 :     \G returns 0 if taddr is not in range of a target memory region
666 :     region-link
667 :     BEGIN @ dup
668 :     WHILE dup >r
669 :     0 >rlink - >r
670 :     r@ >rlen @
671 :     IF dup r@ borders within
672 :     IF r> r> drop nip EXIT THEN
673 :     THEN
674 :     r> drop
675 :     r>
676 :     REPEAT
677 :     2drop 0 ;
678 :    
679 :     : (>regionimage) ( taddr -- 'taddr )
680 :     dup
681 :     \ find region we want to address
682 :     taddr>region dup 0= ABORT" Address out of range!"
683 :     >r
684 :     \ calculate offset in region
685 :     r@ >rstart @ -
686 :     \ add regions real address in our memory
687 :     r> >rmem @ + ;
688 :    
689 : anton 1.1 \ Bit string manipulation 06oct92py
690 :     \ 9may93jaw
691 :     CREATE Bittable 80 c, 40 c, 20 c, 10 c, 8 c, 4 c, 2 c, 1 c,
692 :     : bits ( n -- n ) chars Bittable + c@ ;
693 :    
694 :     : >bit ( addr n -- c-addr mask ) 8 /mod rot + swap bits ;
695 :     : +bit ( addr n -- ) >bit over c@ or swap c! ;
696 : pazsan 1.4 : -bit ( addr n -- ) >bit invert over c@ and swap c! ;
697 : jwilke 1.67
698 :     : (relon) ( taddr -- ) bit$ @ swap cell/ +bit ;
699 :     : (reloff) ( taddr -- ) bit$ @ swap cell/ -bit ;
700 :    
701 :     : (>image) ( taddr -- absaddr ) image @ + ;
702 :    
703 :     DEFER >image
704 :     DEFER relon
705 :     DEFER reloff
706 :     DEFER correcter
707 :    
708 :     T has? relocate H
709 :     [IF]
710 :     ' (relon) IS relon
711 :     ' (reloff) IS reloff
712 :     ' (>image) IS >image
713 :     [ELSE]
714 :     ' drop IS relon
715 :     ' drop IS reloff
716 : jwilke 1.68 ' (>regionimage) IS >image
717 : jwilke 1.67 [THEN]
718 : anton 1.1
719 :     \ Target memory access 06oct92py
720 :    
721 :     : align+ ( taddr -- rest )
722 : anton 1.48 tcell tuck 1- and - [ tcell 1- ] Literal and ;
723 : anton 1.22 : cfalign+ ( taddr -- rest )
724 : pazsan 1.39 \ see kernel.fs:cfaligned
725 : pazsan 1.43 /maxalign tuck 1- and - [ /maxalign 1- ] Literal and ;
726 : anton 1.1
727 :     >TARGET
728 :     : aligned ( taddr -- ta-addr ) dup align+ + ;
729 :     \ assumes cell alignment granularity (as GNU C)
730 :    
731 : anton 1.22 : cfaligned ( taddr1 -- taddr2 )
732 : pazsan 1.39 \ see kernel.fs
733 : anton 1.22 dup cfalign+ + ;
734 :    
735 : jwilke 1.52 : @ ( taddr -- w ) >image S@ ;
736 :     : ! ( w taddr -- ) >image S! ;
737 : pazsan 1.57 : c@ ( taddr -- char ) >image Sc@ ;
738 :     : c! ( char taddr -- ) >image Sc! ;
739 : anton 1.7 : 2@ ( taddr -- x1 x2 ) T dup cell+ @ swap @ H ;
740 :     : 2! ( x1 x2 taddr -- ) T swap over ! cell+ ! H ;
741 : anton 1.1
742 :     \ Target compilation primitives 06oct92py
743 :     \ included A! 16may93jaw
744 :    
745 :     : here ( -- there ) there ;
746 :     : allot ( n -- ) tdp +! ;
747 : jwilke 1.52 : , ( w -- ) T here H tcell T allot ! H T here drop H ;
748 : pazsan 1.57 : c, ( char -- ) T here tchar allot c! H ;
749 : jwilke 1.67 : align ( -- ) T here H align+ 0 ?DO bl T c, tchar H +LOOP ;
750 : anton 1.22 : cfalign ( -- )
751 : pazsan 1.59 T here H cfalign+ 0 ?DO bl T c, tchar H +LOOP ;
752 : anton 1.1
753 : jwilke 1.71 : >address dup 0>= IF tbyte / THEN ; \ ?? jaw
754 : pazsan 1.59 : A! swap >address swap dup relon T ! H ;
755 :     : A, ( w -- ) >address T here H relon T , H ;
756 : anton 1.1
757 :     >CROSS
758 :    
759 : jwilke 1.52 : tcmove ( source dest len -- )
760 :     \G cmove in target memory
761 : pazsan 1.57 tchar * bounds
762 : jwilke 1.52 ?DO dup T c@ H I T c! H 1+
763 : pazsan 1.57 tchar +LOOP drop ;
764 : anton 1.1
765 : jwilke 1.67 \ \ Load Assembler
766 :    
767 : anton 1.1 >TARGET
768 : jwilke 1.52 H also Forth definitions \ ." asm: " order
769 : anton 1.1
770 : jwilke 1.52 : X also target bl word find
771 :     IF state @ IF compile,
772 :     ELSE execute THEN
773 :     ELSE previous ABORT" Cross: access method not supported!"
774 :     THEN
775 :     previous ; immediate
776 : anton 1.1
777 : jwilke 1.52 [IFDEF] asm-include asm-include [THEN] hex
778 : anton 1.1
779 : jwilke 1.52 previous
780 :     >CROSS H
781 : anton 1.1
782 : jwilke 1.52 \ \ -------------------- Compiler Plug Ins 01aug97jaw
783 : anton 1.1
784 : pazsan 1.54 \ Compiler States
785 :    
786 :     Variable comp-state
787 :     0 Constant interpreting
788 :     1 Constant compiling
789 :     2 Constant resolving
790 :     3 Constant assembling
791 :    
792 : jwilke 1.52 Defer lit, ( n -- )
793 :     Defer alit, ( n -- )
794 : pazsan 1.54
795 :     Defer branch, ( target-addr -- ) \ compiles a branch
796 :     Defer ?branch, ( target-addr -- ) \ compiles a ?branch
797 :     Defer branchmark, ( -- branch-addr ) \ reserves room for a branch
798 :     Defer ?branchmark, ( -- branch-addr ) \ reserves room for a ?branch
799 :     Defer ?domark, ( -- branch-addr ) \ reserves room for a ?do branch
800 :     Defer branchto, ( -- ) \ actual program position is target of a branch (do e.g. alignment)
801 :     Defer branchtoresolve, ( branch-addr -- ) \ resolves a forward reference from branchmark
802 :     Defer branchfrom, ( -- ) \ ?!
803 :     Defer branchtomark, ( -- target-addr ) \ marks a branch destination
804 :    
805 : jwilke 1.52 Defer colon, ( tcfa -- ) \ compiles call to tcfa at current position
806 : pazsan 1.54 Defer colonmark, ( -- addr ) \ marks a colon call
807 : jwilke 1.52 Defer colon-resolve ( tcfa addr -- )
808 : pazsan 1.54
809 : jwilke 1.52 Defer addr-resolve ( target-addr addr -- )
810 : pazsan 1.54 Defer doer-resolve ( ghost res-pnt target-addr addr -- ghost res-pnt )
811 :    
812 :     Defer do, ( -- do-token )
813 :     Defer ?do, ( -- ?do-token )
814 :     Defer for, ( -- for-token )
815 :     Defer loop, ( do-token / ?do-token -- )
816 :     Defer +loop, ( do-token / ?do-token -- )
817 :     Defer next, ( for-token )
818 : anton 1.1
819 : jwilke 1.52 [IFUNDEF] ca>native
820 :     defer ca>native
821 :     [THEN]
822 : anton 1.1
823 : jwilke 1.52 >TARGET
824 :     DEFER >body \ we need the system >body
825 :     \ and the target >body
826 :     >CROSS
827 :     T 2 cells H VALUE xt>body
828 : pazsan 1.54 DEFER doprim, \ compiles start of a primitive
829 :     DEFER docol, \ compiles start of a colon definition
830 : jwilke 1.52 DEFER doer,
831 :     DEFER fini, \ compiles end of definition ;s
832 :     DEFER doeshandler,
833 :     DEFER dodoes,
834 :    
835 :     DEFER ]comp \ starts compilation
836 :     DEFER comp[ \ ends compilation
837 :    
838 : pazsan 1.54 : (cc) T a, H ; ' (cc) IS colon,
839 :    
840 :     : (cr) >tempdp ]comp colon, comp[ tempdp> ; ' (cr) IS colon-resolve
841 :     : (ar) T ! H ; ' (ar) IS addr-resolve
842 :     : (dr) ( ghost res-pnt target-addr addr )
843 :     >tempdp drop over
844 :     dup >magic @ <do:> =
845 :     IF doer,
846 :     ELSE dodoes,
847 :     THEN
848 :     tempdp> ; ' (dr) IS doer-resolve
849 :    
850 :     : (cm) ( -- addr )
851 :     T here align H
852 :     -1 colon, ; ' (cm) IS colonmark,
853 : anton 1.1
854 : jwilke 1.52 >TARGET
855 :     : compile, colon, ;
856 :     >CROSS
857 : anton 1.1
858 : jwilke 1.53 \ file loading
859 :    
860 : pazsan 1.54 : >fl-id 1 cells + ;
861 :     : >fl-name 2 cells + ;
862 :    
863 : jwilke 1.53 Variable filelist 0 filelist !
864 : jwilke 1.67 Create NoFile ," #load-file#"
865 : pazsan 1.54 0 Value filemem
866 : jwilke 1.67 : loadfile FileMem ?dup IF >fl-name ELSE NoFile THEN ;
867 : jwilke 1.53
868 : pazsan 1.54 1 [IF] \ !! JAW WIP
869 : anton 1.1
870 : jwilke 1.53 : add-included-file ( adr len -- )
871 : pazsan 1.54 dup char+ >fl-name allocate throw >r
872 :     r@ >fl-name place
873 : jwilke 1.53 filelist @ r@ !
874 : pazsan 1.54 r> dup filelist ! to FileMem
875 :     ;
876 : jwilke 1.53
877 :     : included? ( c-addr u -- f )
878 :     filelist
879 :     BEGIN @ dup
880 :     WHILE >r r@ 1 cells + count compare 0=
881 :     IF rdrop 2drop true EXIT THEN
882 :     r>
883 :     REPEAT
884 :     2drop drop false ;
885 :    
886 :     : included
887 : pazsan 1.54 \ cr ." Including: " 2dup type ." ..."
888 :     FileMem >r
889 :     2dup add-included-file included
890 :     r> to FileMem ;
891 : jwilke 1.53
892 :     : include bl word count included ;
893 :    
894 :     : require bl word count included ;
895 :    
896 :     [THEN]
897 : anton 1.1
898 : jwilke 1.52 \ resolve structure
899 : anton 1.1
900 : jwilke 1.52 : >next ; \ link to next field
901 : pazsan 1.54 : >tag cell+ ; \ indecates type of reference: 0: call, 1: address, 2: doer
902 : jwilke 1.53 : >taddr cell+ cell+ ;
903 : jwilke 1.52 : >ghost 3 cells + ;
904 : jwilke 1.53 : >file 4 cells + ;
905 :     : >line 5 cells + ;
906 : anton 1.48
907 : pazsan 1.54 : (refered) ( ghost addr tag -- )
908 :     \G creates a reference to ghost at address taddr
909 :     rot >r here r@ >link @ , r> >link !
910 :     ( taddr tag ) ,
911 :     ( taddr ) ,
912 :     last-header-ghost @ ,
913 :     loadfile ,
914 :     sourceline# ,
915 :     ;
916 :    
917 : jwilke 1.52 : refered ( ghost tag -- )
918 : jwilke 1.53 \G creates a resolve structure
919 : pazsan 1.54 T here aligned H swap (refered)
920 :     ;
921 :    
922 :     : killref ( addr ghost -- )
923 :     \G kills a forward reference to ghost at position addr
924 :     \G this is used to eleminate a :dovar refence after making a DOES>
925 :     dup >magic @ <fwd> <> IF 2drop EXIT THEN
926 :     swap >r >link
927 :     BEGIN dup @ dup ( addr last this )
928 :     WHILE dup >taddr @ r@ =
929 :     IF @ over !
930 :     ELSE nip THEN
931 :     REPEAT rdrop 2drop
932 : jwilke 1.53 ;
933 : anton 1.48
934 : jwilke 1.52 Defer resolve-warning
935 : anton 1.1
936 : jwilke 1.52 : reswarn-test ( ghost res-struct -- ghost res-struct )
937 :     over cr ." Resolving " >ghostname type dup ." in " >ghost @ >ghostname type ;
938 : anton 1.1
939 : jwilke 1.52 : reswarn-forward ( ghost res-struct -- ghost res-struct )
940 :     over warnhead >ghostname type dup ." is referenced in "
941 :     >ghost @ >ghostname type ;
942 : anton 1.1
943 : jwilke 1.52 \ ' reswarn-test IS resolve-warning
944 :    
945 : anton 1.1 \ resolve 14oct92py
946 :    
947 : pazsan 1.54 : resolve-loop ( ghost resolve-list tcfa -- )
948 :     >r
949 :     BEGIN dup WHILE
950 :     \ dup >tag @ 2 = IF reswarn-forward THEN
951 :     resolve-warning
952 :     r@ over >taddr @
953 :     2 pick >tag @
954 :     CASE 0 OF colon-resolve ENDOF
955 :     1 OF addr-resolve ENDOF
956 :     2 OF doer-resolve ENDOF
957 :     ENDCASE
958 :     @ \ next list element
959 :     REPEAT 2drop rdrop
960 :     ;
961 : jwilke 1.52
962 :     \ : resolve-loop ( ghost tcfa -- ghost tcfa )
963 :     \ >r dup >link @
964 :     \ BEGIN dup WHILE dup T @ H r@ rot T ! H REPEAT drop r> ;
965 : anton 1.1
966 :     \ exists 9may93jaw
967 :    
968 : jwilke 1.52 Variable TWarnings
969 :     TWarnings on
970 :     Variable Exists-Warnings
971 :     Exists-Warnings on
972 :    
973 : anton 1.1 : exists ( ghost tcfa -- )
974 :     over GhostNames
975 :     BEGIN @ dup
976 :     WHILE 2dup cell+ @ =
977 :     UNTIL
978 : jwilke 1.52 2 cells + count
979 :     TWarnings @ Exists-Warnings @ and
980 :     IF warnhead type ." exists"
981 :     ELSE 2drop THEN
982 :     drop swap >link !
983 : pazsan 1.24 ELSE true abort" CROSS: Ghostnames inconsistent "
984 : anton 1.1 THEN ;
985 :    
986 :     : resolve ( ghost tcfa -- )
987 : pazsan 1.54 \G resolve referencies to ghost with tcfa
988 :     \ is ghost resolved?, second resolve means another definition with the
989 :     \ same name
990 :     over forward? 0= IF exists EXIT THEN
991 :     \ get linked-list
992 :     swap >r r@ >link @ swap \ ( list tcfa R: ghost )
993 :     \ mark ghost as resolved
994 :     dup r@ >link ! <res> r@ >magic !
995 :     \ loop through forward referencies
996 :     r> -rot
997 :     comp-state @ >r Resolving comp-state !
998 :     resolve-loop
999 :     r> comp-state !
1000 :    
1001 :     ['] noop IS resolve-warning
1002 : jwilke 1.52 ;
1003 : anton 1.1
1004 :     \ gexecute ghost, 01nov92py
1005 :    
1006 : jwilke 1.52 : is-forward ( ghost -- )
1007 : pazsan 1.54 colonmark, 0 (refered) ; \ compile space for call
1008 : jwilke 1.52
1009 :     : is-resolved ( ghost -- )
1010 :     >link @ colon, ; \ compile-call
1011 :    
1012 :     : gexecute ( ghost -- )
1013 :     dup @ <fwd> = IF is-forward ELSE is-resolved THEN ;
1014 :    
1015 :     : addr, ( ghost -- )
1016 :     dup @ <fwd> = IF 1 refered 0 T a, H ELSE >link @ T a, H THEN ;
1017 :    
1018 :     \ !! : ghost, ghost gexecute ;
1019 : anton 1.1
1020 :     \ .unresolved 11may93jaw
1021 :    
1022 :     variable ResolveFlag
1023 :    
1024 :     \ ?touched 11may93jaw
1025 :    
1026 : jwilke 1.52 : ?touched ( ghost -- flag ) dup forward? swap >link @
1027 : anton 1.1 0 <> and ;
1028 :    
1029 : jwilke 1.53 : .forwarddefs ( ghost -- )
1030 :     ." appeared in:"
1031 :     >link
1032 :     BEGIN @ dup
1033 :     WHILE cr 5 spaces
1034 :     dup >ghost @ >ghostname type
1035 :     ." file " dup >file @ ?dup IF count type ELSE ." CON" THEN
1036 :     ." line " dup >line @ .dec
1037 :     REPEAT
1038 :     drop ;
1039 :    
1040 : anton 1.1 : ?resolved ( ghostname -- )
1041 :     dup cell+ @ ?touched
1042 : jwilke 1.53 IF dup
1043 :     cell+ cell+ count cr type ResolveFlag on
1044 :     cell+ @ .forwarddefs
1045 :     ELSE drop
1046 :     THEN ;
1047 : anton 1.1
1048 :     >MINIMAL
1049 :     : .unresolved ( -- )
1050 :     ResolveFlag off cr ." Unresolved: "
1051 :     Ghostnames
1052 :     BEGIN @ dup
1053 :     WHILE dup ?resolved
1054 : anton 1.10 REPEAT drop ResolveFlag @
1055 :     IF
1056 : anton 1.48 -1 abort" Unresolved words!"
1057 : anton 1.10 ELSE
1058 :     ." Nothing!"
1059 :     THEN
1060 :     cr ;
1061 : anton 1.1
1062 : jwilke 1.52 : .stats
1063 :     base @ >r decimal
1064 :     cr ." named Headers: " headers-named @ .
1065 :     r> base ! ;
1066 :    
1067 : anton 1.1 >CROSS
1068 :     \ Header states 12dec92py
1069 :    
1070 :     : flag! ( 8b -- ) tlast @ dup >r T c@ xor r> c! H ;
1071 :    
1072 :     VARIABLE ^imm
1073 :    
1074 :     >TARGET
1075 : anton 1.36 : immediate 40 flag!
1076 : pazsan 1.18 ^imm @ @ dup <imm> = IF drop EXIT THEN
1077 : anton 1.1 <res> <> ABORT" CROSS: Cannot immediate a unresolved word"
1078 :     <imm> ^imm @ ! ;
1079 : anton 1.36 : restrict 20 flag! ;
1080 : jwilke 1.52
1081 : pazsan 1.54 : isdoer
1082 :     \G define a forth word as doer, this makes obviously only sence on
1083 :     \G forth processors such as the PSC1000
1084 :     <do:> last-header-ghost @ >magic ! ;
1085 : anton 1.1 >CROSS
1086 :    
1087 :     \ ALIAS2 ansforth conform alias 9may93jaw
1088 :    
1089 :     : ALIAS2 create here 0 , DOES> @ execute ;
1090 :     \ usage:
1091 : pazsan 1.18 \ ' <name> alias2 bla !
1092 : anton 1.1
1093 :     \ Target Header Creation 01nov92py
1094 :    
1095 : jwilke 1.52 >TARGET
1096 : anton 1.1 : string, ( addr count -- )
1097 : pazsan 1.28 dup T c, H bounds ?DO I c@ T c, H LOOP ;
1098 : jwilke 1.52 : name, ( "name" -- ) bl word count T string, cfalign H ;
1099 : anton 1.1 : view, ( -- ) ( dummy ) ;
1100 : jwilke 1.52 >CROSS
1101 : anton 1.1
1102 : pazsan 1.25 \ Target Document Creation (goes to crossdoc.fd) 05jul95py
1103 :    
1104 : pazsan 1.55 s" ./doc/crossdoc.fd" r/w create-file throw value doc-file-id
1105 : pazsan 1.25 \ contains the file-id of the documentation file
1106 :    
1107 : pazsan 1.40 : T-\G ( -- )
1108 : pazsan 1.25 source >in @ /string doc-file-id write-line throw
1109 : pazsan 1.40 postpone \ ;
1110 : pazsan 1.25
1111 : pazsan 1.39 Variable to-doc to-doc on
1112 : pazsan 1.25
1113 :     : cross-doc-entry ( -- )
1114 :     to-doc @ tlast @ 0<> and \ not an anonymous (i.e. noname) header
1115 :     IF
1116 :     s" " doc-file-id write-line throw
1117 :     s" make-doc " doc-file-id write-file throw
1118 :     tlast @ >image count $1F and doc-file-id write-file throw
1119 :     >in @
1120 :     [char] ( parse 2drop
1121 :     [char] ) parse doc-file-id write-file throw
1122 :     s" )" doc-file-id write-file throw
1123 :     [char] \ parse 2drop
1124 : pazsan 1.40 T-\G
1125 : pazsan 1.25 >in !
1126 : pazsan 1.39 THEN ;
1127 : pazsan 1.25
1128 : pazsan 1.28 \ Target TAGS creation
1129 :    
1130 : pazsan 1.39 s" kernel.TAGS" r/w create-file throw value tag-file-id
1131 : pazsan 1.28 \ contains the file-id of the tags file
1132 :    
1133 :     Create tag-beg 2 c, 7F c, bl c,
1134 :     Create tag-end 2 c, bl c, 01 c,
1135 :     Create tag-bof 1 c, 0C c,
1136 :    
1137 :     2variable last-loadfilename 0 0 last-loadfilename 2!
1138 :    
1139 :     : put-load-file-name ( -- )
1140 :     loadfilename 2@ last-loadfilename 2@ d<>
1141 :     IF
1142 :     tag-bof count tag-file-id write-line throw
1143 : anton 1.31 sourcefilename 2dup
1144 : pazsan 1.28 tag-file-id write-file throw
1145 :     last-loadfilename 2!
1146 :     s" ,0" tag-file-id write-line throw
1147 :     THEN ;
1148 :    
1149 :     : cross-tag-entry ( -- )
1150 :     tlast @ 0<> \ not an anonymous (i.e. noname) header
1151 :     IF
1152 :     put-load-file-name
1153 :     source >in @ min tag-file-id write-file throw
1154 :     tag-beg count tag-file-id write-file throw
1155 :     tlast @ >image count $1F and tag-file-id write-file throw
1156 :     tag-end count tag-file-id write-file throw
1157 : anton 1.31 base @ decimal sourceline# 0 <# #s #> tag-file-id write-file throw
1158 : pazsan 1.28 \ >in @ 0 <# #s [char] , hold #> tag-file-id write-line throw
1159 :     s" ,0" tag-file-id write-line throw
1160 :     base !
1161 :     THEN ;
1162 :    
1163 : pazsan 1.43 \ Check for words
1164 :    
1165 :     Defer skip? ' false IS skip?
1166 :    
1167 :     : defined? ( -- flag ) \ name
1168 : jwilke 1.52 ghost forward? 0= ;
1169 : pazsan 1.43
1170 :     : needed? ( -- flag ) \ name
1171 : anton 1.48 \G returns a false flag when
1172 :     \G a word is not defined
1173 :     \G a forward reference exists
1174 :     \G so the definition is not skipped!
1175 :     bl word gfind
1176 : jwilke 1.52 IF dup forward?
1177 : anton 1.48 nip
1178 :     0=
1179 :     ELSE drop true THEN ;
1180 : pazsan 1.43
1181 : pazsan 1.44 : doer? ( -- flag ) \ name
1182 :     ghost >magic @ <do:> = ;
1183 :    
1184 : pazsan 1.43 : skip-defs ( -- )
1185 :     BEGIN refill WHILE source -trailing nip 0= UNTIL THEN ;
1186 :    
1187 : pazsan 1.28 \ Target header creation
1188 :    
1189 : pazsan 1.54 Variable CreateFlag
1190 :     CreateFlag off
1191 : jwilke 1.52
1192 : pazsan 1.54 Variable NoHeaderFlag
1193 :     NoHeaderFlag off
1194 : anton 1.1
1195 : pazsan 1.54 : 0.r ( n1 n2 -- )
1196 :     base @ >r hex
1197 :     0 swap <# 0 ?DO # LOOP #> type
1198 :     r> base ! ;
1199 : jwilke 1.52 : .sym
1200 :     bounds
1201 :     DO I c@ dup
1202 :     CASE '/ OF drop ." \/" ENDOF
1203 :     '\ OF drop ." \\" ENDOF
1204 :     dup OF emit ENDOF
1205 :     ENDCASE
1206 : pazsan 1.54 LOOP ;
1207 : jwilke 1.52
1208 : pazsan 1.43 : (Theader ( "name" -- ghost )
1209 : pazsan 1.54 \ >in @ bl word count type 2 spaces >in !
1210 :     \ wordheaders will always be compiled to rom
1211 :     switchrom
1212 :     \ build header in target
1213 :     NoHeaderFlag @
1214 :     IF NoHeaderFlag off
1215 :     ELSE
1216 :     T align H view,
1217 : pazsan 1.59 tlast @ dup 0> IF T 1 cells - H THEN T A, H there tlast !
1218 : pazsan 1.54 1 headers-named +! \ Statistic
1219 :     >in @ T name, H >in !
1220 :     THEN
1221 :     T cfalign here H tlastcfa !
1222 :     \ Symbol table
1223 :     \ >in @ cr ." sym:s/CFA=" there 4 0.r ." /" bl word count .sym ." /g" cr >in !
1224 :     CreateFlag @
1225 :     IF
1226 :     >in @ alias2 swap >in ! \ create alias in target
1227 :     >in @ ghost swap >in !
1228 :     swap also ghosts ' previous swap ! \ tick ghost and store in alias
1229 :     CreateFlag off
1230 :     ELSE ghost
1231 :     THEN
1232 :     dup Last-Header-Ghost !
1233 :     dup >magic ^imm ! \ a pointer for immediate
1234 :     Already @
1235 :     IF dup >end tdoes !
1236 :     ELSE 0 tdoes !
1237 :     THEN
1238 :     80 flag!
1239 :     cross-doc-entry cross-tag-entry ;
1240 : anton 1.1
1241 :     VARIABLE ;Resolve 1 cells allot
1242 : jwilke 1.52 \ this is the resolver information from ":"
1243 :     \ resolving is done by ";"
1244 : anton 1.1
1245 : pazsan 1.11 : Theader ( "name" -- ghost )
1246 :     (THeader dup there resolve 0 ;Resolve ! ;
1247 : anton 1.1
1248 :     >TARGET
1249 :     : Alias ( cfa -- ) \ name
1250 : pazsan 1.43 >in @ skip? IF 2drop EXIT THEN >in !
1251 : jwilke 1.53 dup 0< s" prims" T $has? H 0= and
1252 : pazsan 1.43 IF
1253 : jwilke 1.53 .sourcepos ." needs prim: " >in @ bl word count type >in ! cr
1254 : pazsan 1.43 THEN
1255 :     (THeader over resolve T A, H 80 flag! ;
1256 : pazsan 1.42 : Alias: ( cfa -- ) \ name
1257 : pazsan 1.43 >in @ skip? IF 2drop EXIT THEN >in !
1258 : jwilke 1.53 dup 0< s" prims" T $has? H 0= and
1259 : pazsan 1.43 IF
1260 : jwilke 1.53 .sourcepos ." needs doer: " >in @ bl word count type >in ! cr
1261 : pazsan 1.43 THEN
1262 :     ghost tuck swap resolve <do:> swap >magic ! ;
1263 : pazsan 1.64
1264 :     Variable prim#
1265 :     : first-primitive ( n -- ) prim# ! ;
1266 :     : Primitive ( -- ) \ name
1267 :     prim# @ T Alias H -1 prim# +! ;
1268 : anton 1.1 >CROSS
1269 :    
1270 :     \ Conditionals and Comments 11may93jaw
1271 :    
1272 :     : ;Cond
1273 :     postpone ;
1274 :     swap ! ; immediate
1275 :    
1276 :     : Cond: ( -- ) \ name {code } ;
1277 :     atonce on
1278 :     ghost
1279 :     >exec
1280 :     :NONAME ;
1281 :    
1282 :     : restrict? ( -- )
1283 :     \ aborts on interprete state - ae
1284 :     state @ 0= ABORT" CROSS: Restricted" ;
1285 :    
1286 :     : Comment ( -- )
1287 :     >in @ atonce on ghost swap >in ! ' swap >exec ! ;
1288 :    
1289 :     Comment ( Comment \
1290 :    
1291 :     \ compile 10may93jaw
1292 :    
1293 :     : compile ( -- ) \ name
1294 :     restrict?
1295 : pazsan 1.13 bl word gfind dup 0= ABORT" CROSS: Can't compile "
1296 : anton 1.1 0> ( immediate? )
1297 :     IF >exec @ compile,
1298 :     ELSE postpone literal postpone gexecute THEN ;
1299 :     immediate
1300 :    
1301 : jwilke 1.52 : [G']
1302 :     \G ticks a ghost and returns its address
1303 :     bl word gfind 0= ABORT" CROSS: Ghost don't exists"
1304 :     state @
1305 :     IF postpone literal
1306 :     THEN ; immediate
1307 :    
1308 :     : ghost>cfa
1309 :     dup forward? ABORT" CROSS: forward " >link @ ;
1310 :    
1311 :     >TARGET
1312 :    
1313 :     : ' ( -- cfa )
1314 :     \ returns the target-cfa of a ghost
1315 :     bl word gfind 0= ABORT" CROSS: Ghost don't exists"
1316 :     ghost>cfa ;
1317 :    
1318 :     Cond: ['] T ' H alit, ;Cond
1319 :    
1320 :     >CROSS
1321 :    
1322 :     : [T']
1323 :     \ returns the target-cfa of a ghost, or compiles it as literal
1324 :     postpone [G'] state @ IF postpone ghost>cfa ELSE ghost>cfa THEN ; immediate
1325 : pazsan 1.42
1326 : jwilke 1.52 \ \ threading modell 13dec92py
1327 :     \ modularized 14jun97jaw
1328 :    
1329 :     : fillcfa ( usedcells -- )
1330 : pazsan 1.59 T cells H xt>body swap - 0 ?DO 0 T c, tchar H +LOOP ;
1331 : jwilke 1.52
1332 :     : (>body) ( cfa -- pfa ) xt>body + ; ' (>body) T IS >body H
1333 :    
1334 :     : (doer,) ( ghost -- ) ]comp gexecute comp[ 1 fillcfa ; ' (doer,) IS doer,
1335 :    
1336 :     : (docol,) ( -- ) [G'] :docol doer, ; ' (docol,) IS docol,
1337 :    
1338 :     : (doprim,) ( -- )
1339 :     there xt>body + ca>native T a, H 1 fillcfa ; ' (doprim,) IS doprim,
1340 :    
1341 :     : (doeshandler,) ( -- )
1342 :     T cfalign H compile :doesjump T 0 , H ; ' (doeshandler,) IS doeshandler,
1343 :    
1344 :     : (dodoes,) ( does-action-ghost -- )
1345 :     ]comp [G'] :dodoes gexecute comp[
1346 :     addr,
1347 :     T here H tcell - reloff 2 fillcfa ; ' (dodoes,) IS dodoes,
1348 :    
1349 :     : (lit,) ( n -- ) compile lit T , H ; ' (lit,) IS lit,
1350 :    
1351 : jwilke 1.67 \ if we dont produce relocatable code alit, defaults to lit, jaw
1352 :     has? relocate
1353 :     [IF]
1354 : pazsan 1.66 : (alit,) ( n -- ) compile lit T a, H ; ' (alit,) IS alit,
1355 : jwilke 1.67 [ELSE]
1356 :     : (alit,) ( n -- ) lit, ; ' (alit,) IS alit,
1357 :     [THEN]
1358 : jwilke 1.52
1359 :     : (fini,) compile ;s ; ' (fini,) IS fini,
1360 : pazsan 1.42
1361 : pazsan 1.43 [IFUNDEF] (code)
1362 :     Defer (code)
1363 :     Defer (end-code)
1364 :     [THEN]
1365 :    
1366 : anton 1.1 >TARGET
1367 : pazsan 1.43 : Code
1368 : jwilke 1.52 defempty?
1369 : anton 1.48 (THeader there resolve
1370 : jwilke 1.53 [ T e? prims H 0= [IF] T e? ITC H [ELSE] true [THEN] ] [IF]
1371 : jwilke 1.52 doprim,
1372 : anton 1.48 [THEN]
1373 :     depth (code) ;
1374 : pazsan 1.43
1375 :     : Code:
1376 : jwilke 1.52 defempty?
1377 : anton 1.48 ghost dup there ca>native resolve <do:> swap >magic !
1378 : pazsan 1.43 depth (code) ;
1379 :    
1380 :     : end-code
1381 : jwilke 1.52 (end-code)
1382 : pazsan 1.43 depth ?dup IF 1- <> ABORT" CROSS: Stack changed"
1383 :     ELSE true ABORT" CROSS: Stack empty" THEN
1384 : jwilke 1.52 ;
1385 : anton 1.14
1386 : pazsan 1.57 ( Cond ) : chars tchar * ; ( Cond )
1387 : anton 1.1
1388 :     >CROSS
1389 : jwilke 1.52
1390 : anton 1.1 \ tLiteral 12dec92py
1391 :    
1392 :     >TARGET
1393 : pazsan 1.40 Cond: \G T-\G ;Cond
1394 :    
1395 : anton 1.1 Cond: Literal ( n -- ) restrict? lit, ;Cond
1396 :     Cond: ALiteral ( n -- ) restrict? alit, ;Cond
1397 :    
1398 :     : Char ( "<char>" -- ) bl word char+ c@ ;
1399 :     Cond: [Char] ( "<char>" -- ) restrict? Char lit, ;Cond
1400 :    
1401 : pazsan 1.43 \ some special literals 27jan97jaw
1402 :    
1403 : jwilke 1.52 \ !! Known Bug: Special Literals and plug-ins work only correct
1404 :     \ on 16 and 32 Bit Targets and 32 Bit Hosts!
1405 :    
1406 : pazsan 1.43 Cond: MAXU
1407 : jwilke 1.52 restrict?
1408 :     tcell 1 cells u>
1409 :     IF compile lit tcell 0 ?DO FF T c, H LOOP
1410 :     ELSE $ffffffff lit, THEN
1411 :     ;Cond
1412 : pazsan 1.43
1413 :     Cond: MINI
1414 : jwilke 1.52 restrict?
1415 :     tcell 1 cells u>
1416 :     IF compile lit bigendian
1417 :     IF 80 T c, H tcell 1 ?DO 0 T c, H LOOP
1418 :     ELSE tcell 1 ?DO 0 T c, H LOOP 80 T c, H
1419 :     THEN
1420 :     ELSE tcell 2 = IF $8000 ELSE $80000000 THEN lit, THEN
1421 :     ;Cond
1422 : pazsan 1.43
1423 :     Cond: MAXI
1424 : jwilke 1.52 restrict?
1425 :     tcell 1 cells u>
1426 :     IF compile lit bigendian
1427 :     IF 7F T c, H tcell 1 ?DO FF T c, H LOOP
1428 :     ELSE tcell 1 ?DO FF T c, H LOOP 7F T c, H
1429 :     THEN
1430 :     ELSE tcell 2 = IF $7fff ELSE $7fffffff THEN lit, THEN
1431 : pazsan 1.43 ;Cond
1432 :    
1433 : anton 1.1 >CROSS
1434 :     \ Target compiling loop 12dec92py
1435 :     \ ">tib trick thrown out 10may93jaw
1436 :     \ number? defined at the top 11may93jaw
1437 :    
1438 :     \ compiled word might leave items on stack!
1439 :     : tcom ( in name -- )
1440 :     gfind ?dup IF 0> IF nip >exec @ execute
1441 :     ELSE nip gexecute THEN EXIT THEN
1442 :     number? dup IF 0> IF swap lit, THEN lit, drop
1443 :     ELSE 2drop >in !
1444 :     ghost gexecute THEN ;
1445 :    
1446 :     >TARGET
1447 :     \ : ; DOES> 13dec92py
1448 :     \ ] 9may93py/jaw
1449 :    
1450 :     : ] state on
1451 : pazsan 1.54 Compiling comp-state !
1452 : anton 1.1 BEGIN
1453 : pazsan 1.13 BEGIN >in @ bl word
1454 : anton 1.1 dup c@ 0= WHILE 2drop refill 0=
1455 :     ABORT" CROSS: End of file while target compiling"
1456 :     REPEAT
1457 :     tcom
1458 :     state @
1459 :     0=
1460 :     UNTIL ;
1461 :    
1462 :     \ by the way: defining a second interpreter (a compiler-)loop
1463 :     \ is not allowed if a system should be ans conform
1464 :    
1465 :     : : ( -- colon-sys ) \ Name
1466 : jwilke 1.52 defempty?
1467 :     constflag off \ don't let this flag work over colon defs
1468 :     \ just to go sure nothing unwanted happens
1469 : pazsan 1.43 >in @ skip? IF drop skip-defs EXIT THEN >in !
1470 : anton 1.1 (THeader ;Resolve ! there ;Resolve cell+ !
1471 : jwilke 1.52 docol, ]comp depth T ] H ;
1472 : anton 1.1
1473 : pazsan 1.37 : :noname ( -- colon-sys )
1474 : jwilke 1.52 T cfalign H there docol, 0 ;Resolve ! depth T ] H ;
1475 : pazsan 1.37
1476 : pazsan 1.2 Cond: EXIT ( -- ) restrict? compile ;S ;Cond
1477 : anton 1.6
1478 :     Cond: ?EXIT ( -- ) 1 abort" CROSS: using ?exit" ;Cond
1479 : pazsan 1.2
1480 : jwilke 1.52 >CROSS
1481 :     : LastXT ;Resolve @ 0= abort" CROSS: no definition for LastXT"
1482 :     ;Resolve cell+ @ ;
1483 :    
1484 :     >TARGET
1485 :    
1486 :     Cond: recurse ( -- ) Last-Ghost @ gexecute ;Cond
1487 :    
1488 : anton 1.1 Cond: ; ( -- ) restrict?
1489 :     depth ?dup IF 1- <> ABORT" CROSS: Stack changed"
1490 :     ELSE true ABORT" CROSS: Stack empty" THEN
1491 : jwilke 1.52 fini,
1492 :     comp[
1493 :     state off
1494 : anton 1.1 ;Resolve @
1495 :     IF ;Resolve @ ;Resolve cell+ @ resolve THEN
1496 : pazsan 1.54 Interpreting comp-state !
1497 : anton 1.1 ;Cond
1498 : pazsan 1.54 Cond: [ restrict? state off Interpreting comp-state ! ;Cond
1499 : anton 1.1
1500 :     >CROSS
1501 : pazsan 1.54
1502 :     Create GhostDummy ghostheader
1503 :     <res> GhostDummy >magic !
1504 :    
1505 : jwilke 1.52 : !does ( does-action -- )
1506 :     \ !! zusammenziehen und dodoes, machen!
1507 : pazsan 1.54 tlastcfa @ [G'] :dovar killref
1508 :     \ tlastcfa @ dup there >r tdp ! compile :dodoes r> tdp ! T cell+ ! H ;
1509 : jwilke 1.52 \ !! geht so nicht, da dodoes, ghost will!
1510 : pazsan 1.54 GhostDummy >link ! GhostDummy
1511 :     tlastcfa @ >tempdp dodoes, tempdp> ;
1512 : anton 1.1
1513 :     >TARGET
1514 :     Cond: DOES> restrict?
1515 : jwilke 1.52 compile (does>) doeshandler,
1516 :     \ resolve words made by builders
1517 :     tdoes @ ?dup IF @ T here H resolve THEN
1518 : anton 1.1 ;Cond
1519 : jwilke 1.52 : DOES> switchrom doeshandler, T here H !does depth T ] H ;
1520 : anton 1.1
1521 :     >CROSS
1522 :     \ Creation 01nov92py
1523 :    
1524 :     \ Builder 11may93jaw
1525 :    
1526 : jwilke 1.52 : Builder ( Create-xt do:-xt "name" -- )
1527 :     \ builds up a builder in current vocabulary
1528 :     \ create-xt is executed when word is interpreted
1529 :     \ do:-xt is executet when the created word from builder is executed
1530 :     \ for do:-xt an additional entry after the normal ghost-enrys is used
1531 :    
1532 : anton 1.1 >in @ alias2 swap dup >in ! >r >r
1533 : pazsan 1.54 Make-Ghost
1534 :     rot swap >exec dup @ ['] NoExec <>
1535 :     IF 2drop ELSE ! THEN
1536 :     ,
1537 : anton 1.1 r> r> >in !
1538 : pazsan 1.11 also ghosts ' previous swap ! ;
1539 :     \ DOES> dup >exec @ execute ;
1540 : anton 1.1
1541 : jwilke 1.52 : gdoes, ( ghost -- )
1542 :     \ makes the codefield for a word that is built
1543 :     >end @ dup forward? 0=
1544 :     IF
1545 : pazsan 1.42 dup >magic @ <do:> =
1546 : pazsan 1.54 IF doer,
1547 :     ELSE dodoes,
1548 :     THEN
1549 :     EXIT
1550 : jwilke 1.52 THEN
1551 :     \ compile :dodoes gexecute
1552 :     \ T here H tcell - reloff
1553 : pazsan 1.54 2 refered
1554 :     0 fillcfa
1555 :     ;
1556 : anton 1.1
1557 : jwilke 1.52 : TCreate ( <name> -- )
1558 :     executed-ghost @
1559 : anton 1.1 CreateFlag on
1560 : jwilke 1.52 create-forward-warn
1561 :     IF ['] reswarn-forward IS resolve-warning THEN
1562 : pazsan 1.11 Theader >r dup gdoes,
1563 : jwilke 1.52 \ stores execution symantic in the built word
1564 :     >end @ >exec @ r> >exec ! ;
1565 :    
1566 :     : RTCreate ( <name> -- )
1567 :     \ creates a new word with code-field in ram
1568 :     executed-ghost @
1569 :     CreateFlag on
1570 :     create-forward-warn
1571 :     IF ['] reswarn-forward IS resolve-warning THEN
1572 :     \ make Alias
1573 :     (THeader there 0 T a, H 80 flag! ( S executed-ghost new-ghost )
1574 :     \ store poiter to code-field
1575 :     switchram T cfalign H
1576 :     there swap T ! H
1577 :     there tlastcfa !
1578 :     dup there resolve 0 ;Resolve !
1579 :     >r dup gdoes,
1580 : pazsan 1.11 >end @ >exec @ r> >exec ! ;
1581 : anton 1.1
1582 :     : Build: ( -- [xt] [colon-sys] )
1583 : jwilke 1.52 :noname postpone TCreate ;
1584 :    
1585 :     : BuildSmart: ( -- [xt] [colon-sys] )
1586 :     :noname
1587 : jwilke 1.53 [ T has? rom H [IF] ]
1588 : jwilke 1.52 postpone RTCreate
1589 :     [ [ELSE] ]
1590 :     postpone TCreate
1591 :     [ [THEN] ] ;
1592 : anton 1.1
1593 :     : gdoes> ( ghost -- addr flag )
1594 : jwilke 1.52 executed-ghost @
1595 : anton 1.1 state @ IF gexecute true EXIT THEN
1596 : jwilke 1.52 >link @ T >body H false ;
1597 : anton 1.1
1598 :     \ DO: ;DO 11may93jaw
1599 :     \ changed to ?EXIT 10may93jaw
1600 :    
1601 :     : DO: ( -- addr [xt] [colon-sys] )
1602 :     here ghostheader
1603 : pazsan 1.11 :noname postpone gdoes> postpone ?EXIT ;
1604 : anton 1.1
1605 : pazsan 1.42 : by: ( -- addr [xt] [colon-sys] ) \ name
1606 :     ghost
1607 :     :noname postpone gdoes> postpone ?EXIT ;
1608 :    
1609 : jwilke 1.52 : ;DO ( addr [xt] [colon-sys] -- addr )
1610 : anton 1.1 postpone ; ( S addr xt )
1611 :     over >exec ! ; immediate
1612 :    
1613 :     : by ( -- addr ) \ Name
1614 :     ghost >end @ ;
1615 :    
1616 :     >TARGET
1617 :     \ Variables and Constants 05dec92py
1618 :    
1619 : jwilke 1.52 Build: ( n -- ) ;
1620 :     by: :docon ( ghost -- n ) T @ H ;DO
1621 :     Builder (Constant)
1622 :    
1623 :     Build: ( n -- ) T , H ;
1624 :     by (Constant)
1625 :     Builder Constant
1626 :    
1627 :     Build: ( n -- ) T A, H ;
1628 :     by (Constant)
1629 :     Builder AConstant
1630 :    
1631 :     Build: ( d -- ) T , , H ;
1632 :     DO: ( ghost -- d ) T dup cell+ @ swap @ H ;DO
1633 :     Builder 2Constant
1634 :    
1635 :     BuildSmart: ;
1636 : pazsan 1.42 by: :dovar ( ghost -- addr ) ;DO
1637 : anton 1.1 Builder Create
1638 :    
1639 : jwilke 1.53 T has? rom H [IF]
1640 : pazsan 1.54 Build: ( -- ) T here 0 , H switchram T align here swap ! 0 , H ( switchrom ) ;
1641 : jwilke 1.52 by (Constant)
1642 :     Builder Variable
1643 :     [ELSE]
1644 : anton 1.1 Build: T 0 , H ;
1645 :     by Create
1646 :     Builder Variable
1647 : jwilke 1.52 [THEN]
1648 : anton 1.1
1649 : jwilke 1.53 T has? rom H [IF]
1650 : pazsan 1.54 Build: ( -- ) T here 0 , H switchram T align here swap ! 0 , 0 , H ( switchrom ) ;
1651 :     by (Constant)
1652 :     Builder 2Variable
1653 :     [ELSE]
1654 :     Build: T 0 , 0 , H ;
1655 :     by Create
1656 :     Builder 2Variable
1657 :     [THEN]
1658 :    
1659 :     T has? rom H [IF]
1660 :     Build: ( -- ) T here 0 , H switchram T align here swap ! 0 , H ( switchrom ) ;
1661 : jwilke 1.52 by (Constant)
1662 :     Builder AVariable
1663 :     [ELSE]
1664 : anton 1.1 Build: T 0 A, H ;
1665 :     by Create
1666 :     Builder AVariable
1667 : jwilke 1.52 [THEN]
1668 : anton 1.1
1669 : pazsan 1.3 \ User variables 04may94py
1670 :    
1671 :     >CROSS
1672 :     Variable tup 0 tup !
1673 :     Variable tudp 0 tudp !
1674 :     : u, ( n -- udp )
1675 :     tup @ tudp @ + T ! H
1676 : pazsan 1.19 tudp @ dup T cell+ H tudp ! ;
1677 : pazsan 1.3 : au, ( n -- udp )
1678 :     tup @ tudp @ + T A! H
1679 : pazsan 1.19 tudp @ dup T cell+ H tudp ! ;
1680 : pazsan 1.3 >TARGET
1681 :    
1682 :     Build: T 0 u, , H ;
1683 : pazsan 1.42 by: :douser ( ghost -- up-addr ) T @ H tup @ + ;DO
1684 : anton 1.1 Builder User
1685 :    
1686 : pazsan 1.3 Build: T 0 u, , 0 u, drop H ;
1687 :     by User
1688 : anton 1.1 Builder 2User
1689 :    
1690 : pazsan 1.3 Build: T 0 au, , H ;
1691 :     by User
1692 : anton 1.1 Builder AUser
1693 :    
1694 : jwilke 1.52 BuildSmart: T , H ;
1695 : pazsan 1.44 by (Constant)
1696 : anton 1.1 Builder Value
1697 :    
1698 : jwilke 1.52 BuildSmart: T A, H ;
1699 : pazsan 1.44 by (Constant)
1700 : pazsan 1.32 Builder AValue
1701 :    
1702 : jwilke 1.52 BuildSmart: ( -- ) [T'] noop T A, H ;
1703 : pazsan 1.42 by: :dodefer ( ghost -- ) ABORT" CROSS: Don't execute" ;DO
1704 : anton 1.1 Builder Defer
1705 : pazsan 1.37
1706 : jwilke 1.52 BuildSmart: ( inter comp -- ) swap T immediate A, A, H ;
1707 : pazsan 1.37 DO: ( ghost -- ) ABORT" CROSS: Don't execute" ;DO
1708 : anton 1.38 Builder interpret/compile:
1709 : pazsan 1.24
1710 :     \ Sturctures 23feb95py
1711 :    
1712 :     >CROSS
1713 :     : nalign ( addr1 n -- addr2 )
1714 :     \ addr2 is the aligned version of addr1 wrt the alignment size n
1715 :     1- tuck + swap invert and ;
1716 :     >TARGET
1717 :    
1718 : pazsan 1.44 Build: ;
1719 :     by: :dofield T @ H + ;DO
1720 :     Builder (Field)
1721 :    
1722 : anton 1.51 Build: ( align1 offset1 align size "name" -- align2 offset2 )
1723 :     rot dup T , H ( align1 align size offset1 )
1724 :     + >r nalign r> ;
1725 : pazsan 1.44 by (Field)
1726 : pazsan 1.24 Builder Field
1727 :    
1728 : anton 1.51 : struct T 1 chars 0 H ;
1729 : pazsan 1.24 : end-struct T 2Constant H ;
1730 :    
1731 : jwilke 1.52 : cell% ( n -- size align )
1732 : anton 1.51 T 1 cells H dup ;
1733 : pazsan 1.24
1734 :     \ ' 2Constant Alias2 end-struct
1735 :     \ 0 1 T Chars H 2Constant struct
1736 : anton 1.1
1737 : jwilke 1.52 \ structural conditionals 17dec92py
1738 :    
1739 :     >CROSS
1740 :     : ?struc ( flag -- ) ABORT" CROSS: unstructured " ;
1741 :     : sys? ( sys -- sys ) dup 0= ?struc ;
1742 :     : >mark ( -- sys ) T here ( dup ." M" hex. ) 0 , H ;
1743 :    
1744 : jwilke 1.67 : branchoffset ( src dest -- ) - tchar / ; \ ?? jaw
1745 : jwilke 1.52
1746 :     : >resolve ( sys -- ) T here ( dup ." >" hex. ) over branchoffset swap ! H ;
1747 :    
1748 :     : <resolve ( sys -- ) T here ( dup ." <" hex. ) branchoffset , H ;
1749 :    
1750 : pazsan 1.54 :noname compile branch T here branchoffset , H ;
1751 :     IS branch, ( target-addr -- )
1752 :     :noname compile ?branch T here branchoffset , H ;
1753 :     IS ?branch, ( target-addr -- )
1754 :     :noname compile branch T here 0 , H ;
1755 :     IS branchmark, ( -- branchtoken )
1756 :     :noname compile ?branch T here 0 , H ;
1757 :     IS ?branchmark, ( -- branchtoken )
1758 :     :noname T here 0 , H ;
1759 :     IS ?domark, ( -- branchtoken )
1760 :     :noname dup T @ H ?struc T here over branchoffset swap ! H ;
1761 :     IS branchtoresolve, ( branchtoken -- )
1762 :     :noname branchto, T here H ;
1763 :     IS branchtomark, ( -- target-addr )
1764 : jwilke 1.52
1765 :     >TARGET
1766 :    
1767 :     \ Structural Conditionals 12dec92py
1768 :    
1769 :     Cond: BUT restrict? sys? swap ;Cond
1770 :     Cond: YET restrict? sys? dup ;Cond
1771 :    
1772 : pazsan 1.54 0 [IF]
1773 : jwilke 1.52 >CROSS
1774 :     Variable tleavings
1775 :     >TARGET
1776 :    
1777 :     Cond: DONE ( addr -- ) restrict? tleavings @
1778 :     BEGIN 2dup u> 0= WHILE dup T @ H swap >resolve REPEAT
1779 :     tleavings ! drop ;Cond
1780 :    
1781 :     >CROSS
1782 : pazsan 1.54 : (leave) T here H tleavings @ T , H tleavings ! ;
1783 : jwilke 1.52 >TARGET
1784 :    
1785 : pazsan 1.54 Cond: LEAVE restrict? compile branch (leave) ;Cond
1786 :     Cond: ?LEAVE restrict? compile 0= compile ?branch (leave) ;Cond
1787 : jwilke 1.52
1788 : jwilke 1.53 [ELSE]
1789 :     \ !! This is WIP
1790 :     \ The problem is (?DO)!
1791 :     \ perhaps we need a plug-in for (?DO)
1792 :    
1793 :     >CROSS
1794 :     Variable tleavings 0 tleavings !
1795 : pazsan 1.54 : (done) ( addr -- )
1796 :     tleavings @
1797 :     BEGIN dup
1798 :     WHILE
1799 :     >r dup r@ cell+ @ \ address of branch
1800 :     u> 0= \ lower than DO?
1801 :     WHILE
1802 :     r@ 2 cells + @ \ branch token
1803 :     branchtoresolve,
1804 :     r@ @ r> free throw
1805 :     REPEAT r> THEN
1806 :     tleavings ! drop ;
1807 :    
1808 : jwilke 1.53 >TARGET
1809 :    
1810 : pazsan 1.54 Cond: DONE ( addr -- ) restrict? (done) ;Cond
1811 : jwilke 1.53
1812 :     >CROSS
1813 : pazsan 1.54 : (leave) ( branchtoken -- )
1814 : jwilke 1.53 3 cells allocate throw >r
1815 :     T here H r@ cell+ !
1816 :     r@ 2 cells + !
1817 :     tleavings @ r@ !
1818 :     r> tleavings ! ;
1819 :     >TARGET
1820 :    
1821 : pazsan 1.54 Cond: LEAVE restrict? branchmark, (leave) ;Cond
1822 :     Cond: ?LEAVE restrict? compile 0= ?branchmark, (leave) ;Cond
1823 : jwilke 1.53
1824 :     [THEN]
1825 :    
1826 : pazsan 1.54 >CROSS
1827 :     \ !!JW ToDo : Move to general tools section
1828 :    
1829 :     : to1 ( x1 x2 xn n -- addr )
1830 :     \G packs n stack elements in a allocated memory region
1831 :     dup dup 1+ cells allocate throw dup >r swap 1+
1832 :     0 DO tuck ! cell+ LOOP
1833 :     drop r> ;
1834 :     : 1to ( addr -- x1 x2 xn )
1835 :     \G unpacks the elements saved by to1
1836 :     dup @ swap over cells + swap
1837 :     0 DO dup @ swap 1 cells - LOOP
1838 :     free throw ;
1839 :    
1840 :     : loop] branchto, dup <resolve tcell - (done) ;
1841 :    
1842 :     : skiploop] ?dup IF branchto, branchtoresolve, THEN ;
1843 :    
1844 :     >TARGET
1845 :    
1846 : jwilke 1.52 \ Structural Conditionals 12dec92py
1847 :    
1848 : jwilke 1.53 >TARGET
1849 : jwilke 1.52 Cond: AHEAD restrict? branchmark, ;Cond
1850 :     Cond: IF restrict? ?branchmark, ;Cond
1851 :     Cond: THEN restrict? sys? branchto, branchtoresolve, ;Cond
1852 :     Cond: ELSE restrict? sys? compile AHEAD swap compile THEN ;Cond
1853 :    
1854 :     Cond: BEGIN restrict? branchtomark, ;Cond
1855 :     Cond: WHILE restrict? sys? compile IF swap ;Cond
1856 :     Cond: AGAIN restrict? sys? branch, ;Cond
1857 :     Cond: UNTIL restrict? sys? ?branch, ;Cond
1858 :     Cond: REPEAT restrict? over 0= ?struc compile AGAIN compile THEN ;Cond
1859 :    
1860 :     Cond: CASE restrict? 0 ;Cond
1861 :     Cond: OF restrict? 1+ >r compile over compile =
1862 :     compile IF compile drop r> ;Cond
1863 : pazsan 1.45 Cond: ENDOF restrict? >r compile ELSE r> ;Cond
1864 :     Cond: ENDCASE restrict? compile drop 0 ?DO compile THEN LOOP ;Cond
1865 : anton 1.1
1866 :     \ Structural Conditionals 12dec92py
1867 :    
1868 : jwilke 1.67 :noname \ ?? i think 0 is too much! jaw
1869 : pazsan 1.54 0 compile (do)
1870 :     branchtomark, 2 to1 ;
1871 :     IS do, ( -- target-addr )
1872 :    
1873 :     \ :noname
1874 :     \ compile 2dup compile = compile IF
1875 :     \ compile 2drop compile ELSE
1876 :     \ compile (do) branchtomark, 2 to1 ;
1877 :     \ IS ?do,
1878 :    
1879 :     :noname
1880 :     0 compile (?do) ?domark, (leave)
1881 :     branchtomark, 2 to1 ;
1882 :     IS ?do, ( -- target-addr )
1883 :     :noname compile (for) branchtomark, ;
1884 :     IS for, ( -- target-addr )
1885 :     :noname 1to compile (loop) loop] compile unloop skiploop] ;
1886 :     IS loop, ( target-addr -- )
1887 :     :noname 1to compile (+loop) loop] compile unloop skiploop] ;
1888 :     IS +loop, ( target-addr -- )
1889 :     :noname compile (next) loop] compile unloop ;
1890 :     IS next, ( target-addr -- )
1891 :    
1892 :     Cond: DO restrict? do, ;Cond
1893 :     Cond: ?DO restrict? ?do, ;Cond
1894 :     Cond: FOR restrict? for, ;Cond
1895 :    
1896 :     Cond: LOOP restrict? sys? loop, ;Cond
1897 :     Cond: +LOOP restrict? sys? +loop, ;Cond
1898 :     Cond: NEXT restrict? sys? next, ;Cond
1899 : jwilke 1.52
1900 : anton 1.1 \ String words 23feb93py
1901 :    
1902 : jwilke 1.52 : ," [char] " parse T string, align H ;
1903 : anton 1.1
1904 :     Cond: ." restrict? compile (.") T ," H ;Cond
1905 :     Cond: S" restrict? compile (S") T ," H ;Cond
1906 :     Cond: ABORT" restrict? compile (ABORT") T ," H ;Cond
1907 :    
1908 :     Cond: IS T ' >body H compile ALiteral compile ! ;Cond
1909 : pazsan 1.66 : IS T >address ' >body ! H ;
1910 : pazsan 1.9 Cond: TO T ' >body H compile ALiteral compile ! ;Cond
1911 :     : TO T ' >body ! H ;
1912 : anton 1.1
1913 : jwilke 1.52 Cond: defers T ' >body @ compile, H ;Cond
1914 :     : on T -1 swap ! H ;
1915 :     : off T 0 swap ! H ;
1916 :    
1917 : anton 1.1 \ LINKED ERR" ENV" 2ENV" 18may93jaw
1918 :    
1919 :     \ linked list primitive
1920 :     : linked T here over @ A, swap ! H ;
1921 : jwilke 1.52 : chained T linked A, H ;
1922 : anton 1.1
1923 :     : err" s" ErrLink linked" evaluate T , H
1924 : jwilke 1.52 [char] " parse T string, align H ;
1925 : anton 1.1
1926 :     : env" [char] " parse s" EnvLink linked" evaluate
1927 : jwilke 1.52 T string, align , H ;
1928 : anton 1.1
1929 :     : 2env" [char] " parse s" EnvLink linked" evaluate
1930 : jwilke 1.52 here >r T string, align , , H
1931 : anton 1.1 r> dup T c@ H 80 and swap T c! H ;
1932 :    
1933 :     \ compile must be last 22feb93py
1934 :    
1935 :     Cond: compile ( -- ) restrict? \ name
1936 : pazsan 1.13 bl word gfind dup 0= ABORT" CROSS: Can't compile"
1937 : anton 1.1 0> IF gexecute
1938 :     ELSE dup >magic @ <imm> =
1939 :     IF gexecute
1940 : pazsan 1.54 ELSE compile (compile) addr, THEN THEN ;Cond
1941 : anton 1.1
1942 :     Cond: postpone ( -- ) restrict? \ name
1943 : pazsan 1.13 bl word gfind dup 0= ABORT" CROSS: Can't compile"
1944 : anton 1.1 0> IF gexecute
1945 :     ELSE dup >magic @ <imm> =
1946 :     IF gexecute
1947 : pazsan 1.54 ELSE compile (compile) addr, THEN THEN ;Cond
1948 :    
1949 :     \ \ minimal definitions
1950 :    
1951 : anton 1.1 >MINIMAL
1952 :     also minimal
1953 :     \ Usefull words 13feb93py
1954 :    
1955 :     : KB 400 * ;
1956 :    
1957 : pazsan 1.54 \ \ [IF] [ELSE] [THEN] ... 14sep97jaw
1958 :    
1959 :     \ it is useful to define our own structures and not to rely
1960 :     \ on the words in the compiler
1961 :     \ The words in the compiler might be defined with vocabularies
1962 :     \ this doesn't work with our self-made compile-loop
1963 :    
1964 :     Create parsed 20 chars allot \ store word we parsed
1965 :    
1966 :     : upcase
1967 :     parsed count bounds
1968 :     ?DO I c@ toupper I c! LOOP ;
1969 :    
1970 :     : [ELSE]
1971 :     1 BEGIN
1972 :     BEGIN bl word count dup WHILE
1973 :     comment? parsed place upcase parsed count
1974 :     2dup s" [IF]" compare 0= >r
1975 :     2dup s" [IFUNDEF]" compare 0= >r
1976 :     2dup s" [IFDEF]" compare 0= r> or r> or
1977 :     IF 2drop 1+
1978 :     ELSE 2dup s" [ELSE]" compare 0=
1979 :     IF 2drop 1- dup
1980 :     IF 1+
1981 :     THEN
1982 :     ELSE
1983 :     2dup s" [ENDIF]" compare 0= >r
1984 :     s" [THEN]" compare 0= r> or
1985 :     IF 1- THEN
1986 :     THEN
1987 :     THEN
1988 :     ?dup 0= ?EXIT
1989 :     REPEAT
1990 :     2drop refill 0=
1991 :     UNTIL drop ; immediate
1992 :    
1993 :     : [THEN] ( -- ) ; immediate
1994 :    
1995 :     : [ENDIF] ( -- ) ; immediate
1996 :    
1997 :     : [IF] ( flag -- )
1998 :     0= IF postpone [ELSE] THEN ; immediate
1999 :    
2000 :     Cond: [IF] postpone [IF] ;Cond
2001 :     Cond: [THEN] postpone [THEN] ;Cond
2002 :     Cond: [ELSE] postpone [ELSE] ;Cond
2003 :    
2004 : anton 1.1 \ define new [IFDEF] and [IFUNDEF] 20may93jaw
2005 :    
2006 : pazsan 1.43 : defined? defined? ;
2007 : pazsan 1.44 : needed? needed? ;
2008 :     : doer? doer? ;
2009 : anton 1.1
2010 : jwilke 1.52 \ we want to use IFDEF on compiler directives (e.g. E?) in the source, too
2011 :    
2012 :     : directive?
2013 :     bl word count [ ' target >wordlist ] aliteral search-wordlist
2014 :     dup IF nip THEN ;
2015 :    
2016 :     : [IFDEF] >in @ directive? swap >in !
2017 :     0= IF defined? ELSE name 2drop true THEN
2018 :     postpone [IF] ;
2019 :    
2020 : pazsan 1.43 : [IFUNDEF] defined? 0= postpone [IF] ;
2021 : anton 1.1
2022 : pazsan 1.54 Cond: [IFDEF] postpone [IFDEF] ;Cond
2023 :    
2024 :     Cond: [IFUNDEF] postpone [IFUNDEF] ;Cond
2025 :    
2026 : anton 1.1 \ C: \- \+ Conditional Compiling 09jun93jaw
2027 :    
2028 : pazsan 1.43 : C: >in @ defined? 0=
2029 : anton 1.1 IF >in ! T : H
2030 :     ELSE drop
2031 :     BEGIN bl word dup c@
2032 :     IF count comment? s" ;" compare 0= ?EXIT
2033 :     ELSE refill 0= ABORT" CROSS: Out of Input while C:"
2034 :     THEN
2035 :     AGAIN
2036 :     THEN ;
2037 :    
2038 :     also minimal
2039 :    
2040 : jwilke 1.52 \G doesn't skip line when bit is set in debugmask
2041 :     : \D name evaluate debugmasksource @ and 0= IF postpone \ THEN ;
2042 :    
2043 : anton 1.48 \G interprets the line if word is not defined
2044 : pazsan 1.43 : \- defined? IF postpone \ THEN ;
2045 : anton 1.48
2046 :     \G interprets the line if word is defined
2047 : pazsan 1.43 : \+ defined? 0= IF postpone \ THEN ;
2048 : anton 1.1
2049 : anton 1.48 Cond: \- \- ;Cond
2050 :     Cond: \+ \+ ;Cond
2051 : jwilke 1.52 Cond: \D \D ;Cond
2052 : anton 1.48
2053 :     : ?? bl word find IF execute ELSE drop 0 THEN ;
2054 :    
2055 :     : needed:
2056 :     \G defines ghost for words that we want to be compiled
2057 :     BEGIN >in @ bl word c@ WHILE >in ! ghost drop REPEAT drop ;
2058 :    
2059 :     previous
2060 :    
2061 : anton 1.1 \ save-cross 17mar93py
2062 :    
2063 : anton 1.48 >CROSS
2064 : pazsan 1.62 Create magic s" Gforth2x" here over allot swap move
2065 : pazsan 1.26
2066 : anton 1.63 bigendian 1+ \ strangely, in magic big=0, little=1
2067 :     tcell 1 = 0 and or
2068 : pazsan 1.62 tcell 2 = 2 and or
2069 :     tcell 4 = 4 and or
2070 :     tcell 8 = 6 and or
2071 : pazsan 1.65 tchar 1 = $00 and or
2072 :     tchar 2 = $28 and or
2073 :     tchar 4 = $50 and or
2074 :     tchar 8 = $78 and or
2075 : pazsan 1.62 magic 7 + c!
2076 : pazsan 1.26
2077 : anton 1.34 : save-cross ( "image-name" "binary-name" -- )
2078 :     bl parse ." Saving to " 2dup type cr
2079 : anton 1.1 w/o bin create-file throw >r
2080 : anton 1.48 TNIL IF
2081 : pazsan 1.43 s" #! " r@ write-file throw
2082 :     bl parse r@ write-file throw
2083 :     s" -i" r@ write-file throw
2084 :     #lf r@ emit-file throw
2085 :     r@ dup file-position throw drop 8 mod 8 swap ( file-id limit index )
2086 :     ?do
2087 :     bl over emit-file throw
2088 :     loop
2089 :     drop
2090 :     magic 8 r@ write-file throw \ write magic
2091 :     ELSE
2092 :     bl parse 2drop
2093 :     THEN
2094 : jwilke 1.52 image @ there
2095 :     r@ write-file throw \ write image
2096 : anton 1.48 TNIL IF
2097 :     bit$ @ there 1- tcell>bit rshift 1+
2098 : pazsan 1.16 r@ write-file throw \ write tags
2099 : pazsan 1.43 THEN
2100 : anton 1.1 r> close-file throw ;
2101 :    
2102 : jwilke 1.52 : save-region ( addr len -- )
2103 :     bl parse w/o bin create-file throw >r
2104 : jwilke 1.67 swap >image swap r@ write-file throw
2105 : jwilke 1.52 r> close-file throw ;
2106 :    
2107 : anton 1.1 \ words that should be in minimal
2108 : jwilke 1.52
2109 :     create s-buffer 50 chars allot
2110 :    
2111 : anton 1.48 >MINIMAL
2112 :     also minimal
2113 : anton 1.1
2114 : anton 1.48 bigendian Constant bigendian
2115 : jwilke 1.52 : here there ;
2116 : jwilke 1.67 : equ constant ;
2117 :     : mark there constant ;
2118 : pazsan 1.54
2119 :     \ compiler directives
2120 : jwilke 1.52 : >ram >ram ;
2121 :     : >rom >rom ;
2122 :     : >auto >auto ;
2123 :     : >tempdp >tempdp ;
2124 :     : tempdp> tempdp> ;
2125 :     : const constflag on ;
2126 :     : warnings name 3 = 0= twarnings ! drop ;
2127 : anton 1.60 : | ;
2128 :     \ : | NoHeaderFlag on ; \ This is broken (damages the last word)
2129 : jwilke 1.52
2130 : anton 1.48 : save-cross save-cross ;
2131 : jwilke 1.52 : save-region save-region ;
2132 :     : tdump swap >image swap dump ;
2133 :    
2134 : anton 1.48 also forth
2135 : jwilke 1.52 [IFDEF] Label : Label defempty? Label ; [THEN]
2136 :     [IFDEF] start-macros : start-macros defempty? start-macros ; [THEN]
2137 :     [IFDEF] builttag : builttag builttag ; [THEN]
2138 : anton 1.48 previous
2139 :    
2140 : jwilke 1.52 : s" [char] " parse s-buffer place s-buffer count ; \ for environment?
2141 : pazsan 1.43 : + + ;
2142 : jwilke 1.52 : 1+ 1 + ;
2143 :     : 2+ 2 + ;
2144 : pazsan 1.43 : or or ;
2145 :     : 1- 1- ;
2146 :     : - - ;
2147 : jwilke 1.52 : and and ;
2148 :     : or or ;
2149 : pazsan 1.43 : 2* 2* ;
2150 :     : * * ;
2151 :     : / / ;
2152 :     : dup dup ;
2153 :     : over over ;
2154 :     : swap swap ;
2155 :     : rot rot ;
2156 :     : drop drop ;
2157 :     : = = ;
2158 :     : 0= 0= ;
2159 :     : lshift lshift ;
2160 :     : 2/ 2/ ;
2161 : pazsan 1.19 : . . ;
2162 : anton 1.1
2163 : pazsan 1.43 : all-words ['] false IS skip? ;
2164 :     : needed-words ['] needed? IS skip? ;
2165 :     : undef-words ['] defined? IS skip? ;
2166 : anton 1.1
2167 : pazsan 1.40 : \ postpone \ ; immediate
2168 : pazsan 1.47 : \G T-\G ; immediate
2169 : pazsan 1.40 : ( postpone ( ; immediate
2170 : anton 1.1 : include bl word count included ;
2171 : jwilke 1.52 : require require ;
2172 : anton 1.1 : .( [char] ) parse type ;
2173 : jwilke 1.52 : ." [char] " parse type ;
2174 : anton 1.1 : cr cr ;
2175 :    
2176 :     : times 0 ?DO dup T c, H LOOP drop ; \ used for space table creation
2177 :     only forth also minimal definitions
2178 :    
2179 :     \ cross-compiler words
2180 :    
2181 :     : decimal decimal ;
2182 :     : hex hex ;
2183 :    
2184 : pazsan 1.3 : tudp T tudp H ;
2185 : pazsan 1.39 : tup T tup H ;
2186 :    
2187 :     : doc-off false T to-doc H ! ;
2188 :     : doc-on true T to-doc H ! ;
2189 : jwilke 1.52 [IFDEF] dbg : dbg dbg ; [THEN]
2190 : pazsan 1.39
2191 :     minimal
2192 : anton 1.1
2193 :     \ for debugging...
2194 :     : order order ;
2195 : jwilke 1.52 : hwords words ;
2196 :     : words also ghosts words previous ;
2197 : anton 1.1 : .s .s ;
2198 :     : bye bye ;
2199 :    
2200 :     \ turnkey direction
2201 :     : H forth ; immediate
2202 :     : T minimal ; immediate
2203 :     : G ghosts ; immediate
2204 :    
2205 :     : turnkey 0 set-order also Target definitions
2206 :     also Minimal also ;
2207 :    
2208 :     \ these ones are pefered:
2209 :    
2210 :     : lock turnkey ;
2211 :     : unlock forth also cross ;
2212 : jwilke 1.52
2213 :     : [[ also unlock ;
2214 :     : ]] previous previous ;
2215 : anton 1.1
2216 :     unlock definitions also minimal
2217 :     : lock lock ;
2218 :     lock

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help