[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.86 \ Copyright (C) 1995,1996,1997,1998,1999,2000 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 : anton 1.87 \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, 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 : jwilke 1.77 hex
35 :    
36 :     \ debugging for compiling
37 :    
38 :     \ print stack at each colon definition
39 :     \ : : save-input cr bl word count type restore-input throw .s : ;
40 :    
41 :     \ print stack at each created word
42 :     \ : create save-input cr bl word count type restore-input throw .s create ;
43 :    
44 :    
45 :     \ \ ------------- Setup Vocabularies
46 :    
47 :     \ Remark: Vocabulary is not ANS, but it should work...
48 :    
49 :     Vocabulary Cross
50 :     Vocabulary Target
51 :     Vocabulary Ghosts
52 :     Vocabulary Minimal
53 :     only Forth also Target also also
54 :     definitions Forth
55 :    
56 : jwilke 1.78 : T previous Ghosts also Target ; immediate
57 : jwilke 1.77 : G Ghosts ; immediate
58 :     : H previous Forth also Cross ; immediate
59 :    
60 :     forth definitions
61 :    
62 : jwilke 1.78 : T previous Ghosts also Target ; immediate
63 : jwilke 1.77 : G Ghosts ; immediate
64 :    
65 :     : >cross also Cross definitions previous ;
66 :     : >target also Target definitions previous ;
67 :     : >minimal also Minimal definitions previous ;
68 :    
69 :     H
70 :    
71 :     >CROSS
72 :    
73 :     \ find out whether we are compiling with gforth
74 :    
75 :     : defined? bl word find nip ;
76 :     defined? emit-file defined? toupper and \ drop 0
77 :     [IF]
78 :     \ use this in a gforth system
79 :     : \GFORTH ; immediate
80 :     : \ANSI postpone \ ; immediate
81 :     [ELSE]
82 :     : \GFORTH postpone \ ; immediate
83 :     : \ANSI ; immediate
84 :     [THEN]
85 :    
86 :     \ANSI : [IFUNDEF] defined? 0= postpone [IF] ; immediate
87 :     \ANSI : [IFDEF] defined? postpone [IF] ; immediate
88 :     0 \ANSI drop 1
89 :     [IF]
90 :     : \G postpone \ ; immediate
91 :     : rdrop postpone r> postpone drop ; immediate
92 :     : name bl word count ;
93 :     : bounds over + swap ;
94 :     : scan >r BEGIN dup WHILE over c@ r@ <> WHILE 1 /string REPEAT THEN rdrop ;
95 :     : linked here over @ , swap ! ;
96 :     : alias create , DOES> @ EXECUTE ;
97 :     : defer ['] noop alias ;
98 :     : is state @
99 :     IF ' >body postpone literal postpone !
100 :     ELSE ' >body ! THEN ; immediate
101 :     : 0>= 0< 0= ;
102 :     : d<> rot <> -rot <> or ;
103 :     : toupper dup [char] a [char] z 1+ within IF [char] A [char] a - + THEN ;
104 :     Variable ebuf
105 :     : emit-file ( c fd -- ior ) swap ebuf c! ebuf 1 chars rot write-file ;
106 :     0a Constant #lf
107 :     0d Constant #cr
108 :    
109 :     [IFUNDEF] Warnings Variable Warnings [THEN]
110 :    
111 :     \ \ Number parsing 23feb93py
112 :    
113 :     \ number? number 23feb93py
114 :    
115 :     Variable dpl
116 :    
117 :     hex
118 :     Create bases 10 , 2 , A , 100 ,
119 :     \ 16 2 10 character
120 :    
121 :     \ !! protect BASE saving wrapper against exceptions
122 :     : getbase ( addr u -- addr' u' )
123 :     over c@ [char] $ - dup 4 u<
124 :     IF
125 :     cells bases + @ base ! 1 /string
126 :     ELSE
127 :     drop
128 :     THEN ;
129 :    
130 :     : sign? ( addr u -- addr u flag )
131 :     over c@ [char] - = dup >r
132 :     IF
133 :     1 /string
134 :     THEN
135 :     r> ;
136 :    
137 :     : s>unumber? ( addr u -- ud flag )
138 : jwilke 1.78 over [char] ' =
139 :     IF \ a ' alone is rather unusual :-)
140 :     drop char+ c@ 0 true EXIT
141 :     THEN
142 : jwilke 1.77 base @ >r dpl on getbase
143 :     0. 2swap
144 :     BEGIN ( d addr len )
145 :     dup >r >number dup
146 :     WHILE \ there are characters left
147 :     dup r> -
148 :     WHILE \ the last >number parsed something
149 :     dup 1- dpl ! over c@ [char] . =
150 :     WHILE \ the current char is '.'
151 :     1 /string
152 :     REPEAT THEN \ there are unparseable characters left
153 :     2drop false
154 :     ELSE
155 :     rdrop 2drop true
156 :     THEN
157 :     r> base ! ;
158 :    
159 :     \ ouch, this is complicated; there must be a simpler way - anton
160 :     : s>number? ( addr len -- d f )
161 :     \ converts string addr len into d, flag indicates success
162 :     sign? >r
163 :     s>unumber?
164 :     0= IF
165 :     rdrop false
166 :     ELSE \ no characters left, all ok
167 :     r>
168 :     IF
169 :     dnegate
170 :     THEN
171 :     true
172 :     THEN ;
173 :    
174 :     : s>number ( addr len -- d )
175 :     \ don't use this, there is no way to tell success
176 :     s>number? drop ;
177 :    
178 :     : snumber? ( c-addr u -- 0 / n -1 / d 0> )
179 :     s>number? 0=
180 :     IF
181 :     2drop false EXIT
182 :     THEN
183 :     dpl @ dup 0< IF
184 :     nip
185 :     ELSE
186 :     1+
187 :     THEN ;
188 :    
189 :     : number? ( string -- string 0 / n -1 / d 0> )
190 :     dup >r count snumber? dup if
191 :     rdrop
192 :     else
193 :     r> swap
194 :     then ;
195 :    
196 :     : number ( string -- d )
197 :     number? ?dup 0= abort" ?" 0<
198 :     IF
199 :     s>d
200 :     THEN ;
201 :    
202 :     [THEN]
203 : anton 1.48
204 : jwilke 1.52 hex \ the defualt base for the cross-compiler is hex !!
205 : jwilke 1.78 \ Warnings off
206 : jwilke 1.52
207 :     \ words that are generaly useful
208 :    
209 : pazsan 1.59 : KB 400 * ;
210 : jwilke 1.52 : >wordlist ( vocabulary-xt -- wordlist-struct )
211 :     also execute get-order swap >r 1- set-order r> ;
212 :    
213 :     : umax 2dup u< IF swap THEN drop ;
214 :     : umin 2dup u> IF swap THEN drop ;
215 : anton 1.1
216 : pazsan 1.23 : string, ( c-addr u -- )
217 :     \ puts down string as cstring
218 :     dup c, here swap chars dup allot move ;
219 : pazsan 1.5
220 : jwilke 1.77 : ," [char] " parse string, ;
221 :    
222 : jwilke 1.52 : SetValue ( n -- <name> )
223 : pazsan 1.54 \G Same behaviour as "Value" if the <name> is not defined
224 :     \G Same behaviour as "to" if <name> is defined
225 : jwilke 1.52 \G SetValue searches in the current vocabulary
226 : jwilke 1.68 save-input bl word >r restore-input throw r> count
227 :     get-current search-wordlist
228 :     IF drop >r
229 :     \ we have to set current to be topmost context wordlist
230 :     get-order get-order get-current swap 1+ set-order
231 :     r> ['] to execute
232 : jwilke 1.74 set-order
233 : jwilke 1.68 ELSE Value THEN ;
234 : jwilke 1.52
235 :     : DefaultValue ( n -- <name> )
236 : pazsan 1.54 \G Same behaviour as "Value" if the <name> is not defined
237 :     \G DefaultValue searches in the current vocabulary
238 : jwilke 1.52 save-input bl word >r restore-input throw r> count
239 :     get-current search-wordlist
240 : pazsan 1.56 IF bl word drop 2drop ELSE Value THEN ;
241 : anton 1.1
242 :     hex
243 :    
244 : jwilke 1.52 \ 1 Constant Cross-Flag \ to check whether assembler compiler plug-ins are
245 :     \ for cross-compiling
246 :     \ No! we use "[IFUNDEF]" there to find out whether we are target compiling!!!
247 :    
248 :     : comment? ( c-addr u -- c-addr u )
249 :     2dup s" (" compare 0=
250 :     IF postpone (
251 :     ELSE 2dup s" \" compare 0= IF postpone \ THEN
252 :     THEN ;
253 :    
254 :     \ Begin CROSS COMPILER:
255 :    
256 : jwilke 1.74 \ debugging
257 : jwilke 1.52
258 : jwilke 1.74 0 [IF]
259 :    
260 :     This implements debugflags for the cross compiler and the compiled
261 :     images. It works identical to the has-flags in the environment.
262 :     The debugflags are defined in a vocabluary. If the word exists and
263 :     its value is true, the flag is switched on.
264 :    
265 :     [THEN]
266 :    
267 : jwilke 1.77 >CROSS
268 :    
269 : jwilke 1.74 Vocabulary debugflags \ debug flags for cross
270 :     also debugflags get-order over
271 :     Constant debugflags-wl
272 :     set-order previous
273 :    
274 :     : DebugFlag
275 :     get-current >r debugflags-wl set-current
276 :     SetValue
277 :     r> set-current ;
278 :    
279 :     : Debug? ( adr u -- flag )
280 :     \G return true if debug flag is defined or switched on
281 :     debugflags-wl search-wordlist
282 :     IF EXECUTE
283 :     ELSE false THEN ;
284 :    
285 :     : D? ( <name> -- flag )
286 :     \G return true if debug flag is defined or switched on
287 :     \G while compiling we do not return the current value but
288 :     bl word count debug? ;
289 :    
290 :     : [d?]
291 :     \G compile the value-xt so the debug flag can be switched
292 :     \G the flag must exist!
293 :     bl word count debugflags-wl search-wordlist
294 :     IF compile,
295 :     ELSE -1 ABORT" unknown debug flag"
296 :     \ POSTPONE false
297 :     THEN ; immediate
298 : pazsan 1.54
299 : jwilke 1.77 \ \ -------------------- source file
300 :    
301 :     decimal
302 :    
303 :     Variable cross-file-list
304 :     0 cross-file-list !
305 :     Variable target-file-list
306 :     0 target-file-list !
307 :     Variable host-file-list
308 :     0 host-file-list !
309 :    
310 :     cross-file-list Value file-list
311 :     0 Value source-desc
312 :    
313 :     \ file loading
314 :    
315 :     : >fl-id 1 cells + ;
316 :     : >fl-name 2 cells + ;
317 :    
318 :     Variable filelist 0 filelist !
319 :     Create NoFile ," #load-file#"
320 :    
321 :     : loadfile ( -- adr )
322 :     source-desc ?dup IF >fl-name ELSE NoFile THEN ;
323 :    
324 :     : sourcefilename ( -- adr len )
325 :     loadfile count ;
326 :    
327 :     \ANSI : sourceline# 0 ;
328 :    
329 :     \ \ -------------------- path handling from kernel/paths.fs
330 :    
331 :     \ paths.fs path file handling 03may97jaw
332 :    
333 :     \ -Changing the search-path:
334 :     \ fpath+ <path> adds a directory to the searchpath
335 :     \ fpath= <path>|<path> makes complete now searchpath
336 :     \ seperator is |
337 :     \ .fpath displays the search path
338 :     \ remark I:
339 :     \ a ./ in the beginning of filename is expanded to the directory the
340 :     \ current file comes from. ./ can also be included in the search-path!
341 :     \ ~+/ loads from the current working directory
342 :    
343 :     \ remark II:
344 :     \ if there is no sufficient space for the search path increase it!
345 :    
346 :    
347 :     \ -Creating custom paths:
348 :    
349 :     \ It is possible to use the search mechanism on yourself.
350 :    
351 :     \ Make a buffer for the path:
352 :     \ create mypath 100 chars , \ maximum length (is checked)
353 :     \ 0 , \ real len
354 :     \ 100 chars allot \ space for path
355 :     \ use the same functions as above with:
356 :     \ mypath path+
357 :     \ mypath path=
358 :     \ mypath .path
359 :    
360 :     \ do a open with the search path:
361 :     \ open-path-file ( adr len path -- fd adr len ior )
362 :     \ the file is opened read-only; if the file is not found an error is generated
363 :    
364 :     \ questions to: wilke@jwdt.com
365 :    
366 :     [IFUNDEF] +place
367 :     : +place ( adr len adr )
368 :     2dup >r >r
369 :     dup c@ char+ + swap move
370 :     r> r> dup c@ rot + swap c! ;
371 :     [THEN]
372 :    
373 :     [IFUNDEF] place
374 :     : place ( c-addr1 u c-addr2 )
375 :     2dup c! char+ swap move ;
376 :     [THEN]
377 :    
378 :     \ if we have path handling, use this and the setup of it
379 :     [IFUNDEF] open-fpath-file
380 :    
381 :     create sourcepath 1024 chars , 0 , 1024 chars allot \ !! make this dynamic
382 :     sourcepath value fpath
383 :    
384 :     : also-path ( adr len path^ -- )
385 :     >r
386 :     \ len check
387 :     r@ cell+ @ over + r@ @ u> ABORT" path buffer too small!"
388 :     \ copy into
389 :     tuck r@ cell+ dup @ cell+ + swap cmove
390 :     \ make delimiter
391 :     0 r@ cell+ dup @ cell+ + 2 pick + c! 1 + r> cell+ +!
392 :     ;
393 :    
394 :     : only-path ( adr len path^ -- )
395 :     dup 0 swap cell+ ! also-path ;
396 :    
397 :     : path+ ( path-addr "dir" -- ) \ gforth
398 :     \G Add the directory @var{dir} to the search path @var{path-addr}.
399 :     name rot also-path ;
400 :    
401 :     : fpath+ ( "dir" ) \ gforth
402 :     \G Add directory @var{dir} to the Forth search path.
403 :     fpath path+ ;
404 :    
405 :     : path= ( path-addr "dir1|dir2|dir3" ) \ gforth
406 :     \G Make a complete new search path; the path separator is |.
407 :     name 2dup bounds ?DO i c@ [char] | = IF 0 i c! THEN LOOP
408 :     rot only-path ;
409 :    
410 :     : fpath= ( "dir1|dir2|dir3" ) \ gforth
411 :     \G Make a complete new Forth search path; the path separator is |.
412 :     fpath path= ;
413 :    
414 :     : path>counted cell+ dup cell+ swap @ ;
415 :    
416 :     : next-path ( adr len -- adr2 len2 )
417 :     2dup 0 scan
418 :     dup 0= IF 2drop 0 -rot 0 -rot EXIT THEN
419 :     >r 1+ -rot r@ 1- -rot
420 :     r> - ;
421 :    
422 :     : previous-path ( path^ -- )
423 :     dup path>counted
424 :     BEGIN tuck dup WHILE repeat ;
425 :    
426 :     : .path ( path-addr -- ) \ gforth
427 :     \G Display the contents of the search path @var{path-addr}.
428 :     path>counted
429 :     BEGIN next-path dup WHILE type space REPEAT 2drop 2drop ;
430 :    
431 :     : .fpath ( -- ) \ gforth
432 :     \G Display the contents of the Forth search path.
433 :     fpath .path ;
434 :    
435 :     : absolut-path? ( addr u -- flag ) \ gforth
436 :     \G A path is absolute if it starts with a / or a ~ (~ expansion),
437 :     \G or if it is in the form ./*, extended regexp: ^[/~]|./, or if
438 :     \G it has a colon as second character ("C:..."). Paths simply
439 :     \G containing a / are not absolute!
440 :     2dup 2 u> swap 1+ c@ [char] : = and >r \ dos absoulte: c:/....
441 :     over c@ [char] / = >r
442 :     over c@ [char] ~ = >r
443 :     \ 2dup 3 min S" ../" compare 0= r> or >r \ not catered for in expandtopic
444 :     2 min S" ./" compare 0=
445 :     r> r> r> or or or ;
446 :    
447 :     Create ofile 0 c, 255 chars allot
448 :     Create tfile 0 c, 255 chars allot
449 :    
450 :     : pathsep? dup [char] / = swap [char] \ = or ;
451 :    
452 :     : need/ ofile dup c@ + c@ pathsep? 0= IF s" /" ofile +place THEN ;
453 :    
454 :     : extractpath ( adr len -- adr len2 )
455 :     BEGIN dup WHILE 1-
456 :     2dup + c@ pathsep? IF EXIT THEN
457 :     REPEAT ;
458 :    
459 :     : remove~+ ( -- )
460 :     ofile count 3 min s" ~+/" compare 0=
461 :     IF
462 :     ofile count 3 /string ofile place
463 :     THEN ;
464 :    
465 :     : expandtopic ( -- ) \ stack effect correct? - anton
466 :     \ expands "./" into an absolute name
467 :     ofile count 2 min s" ./" compare 0=
468 :     IF
469 :     ofile count 1 /string tfile place
470 :     0 ofile c! sourcefilename extractpath ofile place
471 :     ofile c@ IF need/ THEN
472 :     tfile count over c@ pathsep? IF 1 /string THEN
473 :     ofile +place
474 :     THEN ;
475 :    
476 :     : compact.. ( adr len -- adr2 len2 )
477 : pazsan 1.85 \ deletes phrases like "xy/.." out of our directory name 2dec97jaw
478 :     over swap
479 :     BEGIN dup WHILE
480 :     dup >r '/ scan 2dup 4 min s" /../" compare 0=
481 :     IF
482 :     dup r> - >r 4 /string over r> + 4 -
483 :     swap 2dup + >r move dup r> over -
484 :     ELSE
485 :     rdrop dup 1 min /string
486 :     THEN
487 :     REPEAT drop over - ;
488 : jwilke 1.77
489 :     : reworkdir ( -- )
490 :     remove~+
491 :     ofile count compact..
492 :     nip ofile c! ;
493 :    
494 :     : open-ofile ( -- fid ior )
495 :     \G opens the file whose name is in ofile
496 :     expandtopic reworkdir
497 :     ofile count r/o open-file ;
498 :    
499 :     : check-path ( adr1 len1 adr2 len2 -- fd 0 | 0 <>0 )
500 :     0 ofile ! >r >r ofile place need/
501 :     r> r> ofile +place
502 :     open-ofile ;
503 :    
504 :     : open-path-file ( addr1 u1 path-addr -- wfileid addr2 u2 0 | ior ) \ gforth
505 :     \G Look in path @var{path-addr} for the file specified by @var{addr1 u1}.
506 :     \G If found, the resulting path and an open file descriptor
507 :     \G are returned. If the file is not found, @var{ior} is non-zero.
508 :     >r
509 :     2dup absolut-path?
510 :     IF rdrop
511 :     ofile place open-ofile
512 :     dup 0= IF >r ofile count r> THEN EXIT
513 :     ELSE r> path>counted
514 :     BEGIN next-path dup
515 :     WHILE 5 pick 5 pick check-path
516 :     0= IF >r 2drop 2drop r> ofile count 0 EXIT ELSE drop THEN
517 :     REPEAT
518 :     2drop 2drop 2drop -38
519 :     THEN ;
520 :    
521 :     : open-fpath-file ( addr1 u1 -- wfileid addr2 u2 0 | ior ) \ gforth
522 :     \G Look in the Forth search path for the file specified by @var{addr1 u1}.
523 :     \G If found, the resulting path and an open file descriptor
524 :     \G are returned. If the file is not found, @var{ior} is non-zero.
525 :     fpath open-path-file ;
526 :    
527 :     fpath= ~+
528 :    
529 :     [THEN]
530 :    
531 :     \ \ -------------------- include require 13may99jaw
532 :    
533 :     >CROSS
534 :    
535 :     : add-included-file ( adr len -- adr )
536 :     dup >fl-name char+ allocate throw >r
537 :     file-list @ r@ ! r@ file-list !
538 :     r@ >fl-name place r> ;
539 :    
540 :     : included? ( c-addr u -- f )
541 :     file-list
542 :     BEGIN @ dup
543 :     WHILE >r 2dup r@ >fl-name count compare 0=
544 :     IF rdrop 2drop true EXIT THEN
545 :     r>
546 :     REPEAT
547 :     2drop drop false ;
548 :    
549 :     false DebugFlag showincludedfiles
550 :    
551 :     : included1 ( fd adr u -- )
552 :     \ include file adr u / fd
553 :     \ we don't use fd with include-file, because the forth system
554 :     \ doesn't know the name of the file to get a nice error report
555 :     [d?] showincludedfiles
556 :     IF cr ." Including: " 2dup type ." ..." THEN
557 :     rot close-file throw
558 :     source-desc >r
559 :     add-included-file to source-desc
560 :     sourcefilename
561 :     ['] included catch
562 :     r> to source-desc
563 :     throw ;
564 :    
565 :     : included ( adr len -- )
566 :     cross-file-list to file-list
567 :     open-fpath-file throw
568 :     included1 ;
569 :    
570 :     : required ( adr len -- )
571 :     cross-file-list to file-list
572 :     open-fpath-file throw \ 2dup cr ." R:" type
573 :     2dup included?
574 :     IF 2drop close-file throw
575 :     ELSE included1
576 :     THEN ;
577 :    
578 :     : include bl word count included ;
579 :    
580 :     : require bl word count required ;
581 :    
582 : jwilke 1.78 0 [IF]
583 :    
584 : jwilke 1.77 also forth definitions previous
585 :    
586 :     : included ( adr len -- ) included ;
587 :    
588 :     : required ( adr len -- ) required ;
589 :    
590 :     : include include ;
591 :    
592 :     : require require ;
593 :    
594 : jwilke 1.78 [THEN]
595 :    
596 : jwilke 1.77 >CROSS
597 :     hex
598 :    
599 :     \ \ -------------------- Error Handling 05aug97jaw
600 :    
601 :     \ Flags
602 :    
603 :     also forth definitions \ these values may be predefined before
604 :     \ the cross-compiler is loaded
605 :    
606 :     false DefaultValue stack-warn \ check on empty stack at any definition
607 :     false DefaultValue create-forward-warn \ warn on forward declaration of created words
608 :    
609 :     previous >CROSS
610 :    
611 :     : .dec
612 :     base @ decimal swap . base ! ;
613 :    
614 :     : .sourcepos
615 :     cr sourcefilename type ." :"
616 :     sourceline# .dec ;
617 :    
618 :     : warnhead
619 :     \G display error-message head
620 :     \G perhaps with linenumber and filename
621 :     .sourcepos ." Warning: " ;
622 :    
623 :     : empty? depth IF .sourcepos ." Stack not empty!" THEN ;
624 :    
625 :     stack-warn [IF]
626 :     : defempty? empty? ;
627 :     [ELSE]
628 :     : defempty? ; immediate
629 :     [THEN]
630 :    
631 : jwilke 1.52 \ \ GhostNames Ghosts 9may93jaw
632 :    
633 :     \ second name source to search trough list
634 :    
635 :     VARIABLE GhostNames
636 :     0 GhostNames !
637 :    
638 :     : GhostName ( -- addr )
639 : jwilke 1.79 align here GhostNames @ , GhostNames ! here 0 ,
640 : jwilke 1.52 bl word count
641 :     \ 2dup type space
642 :     string, \ !! cfalign ?
643 :     align ;
644 :    
645 :     \ Ghost Builder 06oct92py
646 :    
647 :     \ <T T> new version with temp variable 10may93jaw
648 :    
649 :     VARIABLE VocTemp
650 :    
651 :     : <T get-current VocTemp ! also Ghosts definitions ;
652 :     : T> previous VocTemp @ set-current ;
653 :    
654 :     hex
655 :     4711 Constant <fwd> 4712 Constant <res>
656 :     4713 Constant <imm> 4714 Constant <do:>
657 : jwilke 1.75 4715 Constant <skip>
658 : jwilke 1.52
659 : pazsan 1.93 \ Compiler States
660 :    
661 :     Variable comp-state
662 :     0 Constant interpreting
663 :     1 Constant compiling
664 :     2 Constant resolving
665 :     3 Constant assembling
666 :    
667 :     Defer lit, ( n -- )
668 :     Defer alit, ( n -- )
669 :    
670 :     Defer branch, ( target-addr -- ) \ compiles a branch
671 :     Defer ?branch, ( target-addr -- ) \ compiles a ?branch
672 :     Defer branchmark, ( -- branch-addr ) \ reserves room for a branch
673 :     Defer ?branchmark, ( -- branch-addr ) \ reserves room for a ?branch
674 :     Defer ?domark, ( -- branch-addr ) \ reserves room for a ?do branch
675 :     Defer branchto, ( -- ) \ actual program position is target of a branch (do e.g. alignment)
676 :     Defer branchtoresolve, ( branch-addr -- ) \ resolves a forward reference from branchmark
677 :     Defer branchfrom, ( -- ) \ ?!
678 :     Defer branchtomark, ( -- target-addr ) \ marks a branch destination
679 :    
680 :     Defer colon, ( tcfa -- ) \ compiles call to tcfa at current position
681 : pazsan 1.94 Defer prim, ( tcfa -- ) \ compiles a primitive invocation
682 :     \ at current position
683 : pazsan 1.93 Defer colonmark, ( -- addr ) \ marks a colon call
684 :     Defer colon-resolve ( tcfa addr -- )
685 :    
686 :     Defer addr-resolve ( target-addr addr -- )
687 :     Defer doer-resolve ( ghost res-pnt target-addr addr -- ghost res-pnt )
688 : jwilke 1.52
689 : pazsan 1.93 Defer do, ( -- do-token )
690 :     Defer ?do, ( -- ?do-token )
691 :     Defer for, ( -- for-token )
692 :     Defer loop, ( do-token / ?do-token -- )
693 :     Defer +loop, ( do-token / ?do-token -- )
694 :     Defer next, ( for-token )
695 : jwilke 1.52
696 : pazsan 1.93 [IFUNDEF] ca>native
697 :     defer ca>native
698 :     [THEN]
699 : jwilke 1.52
700 : pazsan 1.93 \ ghost structure
701 : jwilke 1.52
702 :     : >magic ; \ type of ghost
703 :     : >link cell+ ; \ pointer where ghost is in target, or if unresolved
704 :     \ points to the where we have to resolve (linked-list)
705 :     : >exec cell+ cell+ ; \ execution symantics (while target compiling) of ghost
706 : pazsan 1.93 : >comp 3 cells + ; \ compilation semantics
707 :     : >end 4 cells + ; \ room for additional tags
708 : jwilke 1.52 \ for builder (create, variable...) words the
709 :     \ execution symantics of words built are placed here
710 :    
711 : pazsan 1.93 \ resolve structure
712 :    
713 :     : >next ; \ link to next field
714 :     : >tag cell+ ; \ indecates type of reference: 0: call, 1: address, 2: doer
715 :     : >taddr cell+ cell+ ;
716 :     : >ghost 3 cells + ;
717 :     : >file 4 cells + ;
718 :     : >line 5 cells + ;
719 :    
720 :     \ refer variables
721 :    
722 : jwilke 1.52 Variable executed-ghost \ last executed ghost, needed in tcreate and gdoes>
723 :     Variable last-ghost \ last ghost that is created
724 :     Variable last-header-ghost \ last ghost definitions with header
725 :    
726 : pazsan 1.93 : (refered) ( ghost addr tag -- )
727 :     \G creates a reference to ghost at address taddr
728 :     rot >r here r@ >link @ , r> >link !
729 :     ( taddr tag ) ,
730 :     ( taddr ) ,
731 :     last-header-ghost @ ,
732 :     loadfile ,
733 :     sourceline# ,
734 :     ;
735 :    
736 :     \ iForth makes only immediate directly after create
737 :     \ make atonce trick! ?
738 :    
739 :     Variable atonce atonce off
740 :    
741 :     : NoExec true ABORT" CROSS: Don't execute ghost, or immediate target word" ;
742 :    
743 :     : is-forward ( ghost -- )
744 :     colonmark, 0 (refered) ; \ compile space for call
745 :    
746 :     : GhostHeader <fwd> , 0 , ['] NoExec , ['] is-forward , ;
747 :    
748 : jwilke 1.52 : Make-Ghost ( "name" -- ghost )
749 :     >in @ GhostName swap >in !
750 :     <T Create atonce @ IF immediate atonce off THEN
751 :     here tuck swap ! ghostheader T>
752 :     dup last-ghost !
753 :     DOES> dup executed-ghost ! >exec @ execute ;
754 :    
755 :     \ ghost words 14oct92py
756 :     \ changed: 10may93py/jaw
757 :    
758 :     : gfind ( string -- ghost true/1 / string false )
759 :     \ searches for string in word-list ghosts
760 : jwilke 1.77 dup count [ ' ghosts >wordlist ] Literal search-wordlist
761 : jwilke 1.52 dup IF >r >body nip r> THEN ;
762 :    
763 :     : gdiscover ( xt -- ghost true | xt false )
764 :     GhostNames
765 :     BEGIN @ dup
766 :     WHILE 2dup
767 :     cell+ @ dup >magic @ <fwd> <>
768 :     >r >link @ = r> and
769 :     IF cell+ @ nip true EXIT THEN
770 :     REPEAT
771 :     drop false ;
772 :    
773 :     VARIABLE Already
774 :    
775 :     : ghost ( "name" -- ghost )
776 :     Already off
777 : jwilke 1.76 >in @ bl word gfind IF atonce off Already on nip EXIT THEN
778 : jwilke 1.52 drop >in ! Make-Ghost ;
779 :    
780 :     : >ghostname ( ghost -- adr len )
781 :     GhostNames
782 :     BEGIN @ dup
783 :     WHILE 2dup cell+ @ =
784 :     UNTIL nip 2 cells + count
785 : pazsan 1.54 ELSE 2drop
786 :     \ true abort" CROSS: Ghostnames inconsistent"
787 :     s" ?!?!?!"
788 : jwilke 1.52 THEN ;
789 :    
790 : jwilke 1.78 : .ghost ( ghost -- ) >ghostname type ;
791 :    
792 : jwilke 1.77 \ ' >ghostname ALIAS @name
793 : jwilke 1.52
794 :     : forward? ( ghost -- flag )
795 :     >magic @ <fwd> = ;
796 :    
797 : jwilke 1.75 : undefined? ( ghost -- flag )
798 :     >magic @ dup <fwd> = swap <skip> = or ;
799 :    
800 : jwilke 1.52 \ Predefined ghosts 12dec92py
801 :    
802 :     ghost 0= drop
803 :     ghost branch ghost ?branch 2drop
804 :     ghost (do) ghost (?do) 2drop
805 :     ghost (for) drop
806 :     ghost (loop) ghost (+loop) 2drop
807 :     ghost (next) drop
808 :     ghost unloop ghost ;S 2drop
809 :     ghost lit ghost (compile) ghost ! 2drop drop
810 :     ghost (does>) ghost noop 2drop
811 : pazsan 1.97 ghost (.") ghost (S") ghost (ABORT") 2drop drop
812 : jwilke 1.52 ghost ' drop
813 :     ghost :docol ghost :doesjump ghost :dodoes 2drop drop
814 : pazsan 1.93 ghost :dovar ghost :dodefer ghost :dofield 2drop drop
815 : jwilke 1.52 ghost over ghost = ghost drop 2drop drop
816 : pazsan 1.93 ghost call ghost useraddr ghost execute 2drop drop
817 :     ghost + ghost - ghost @ 2drop drop
818 : pazsan 1.54 ghost 2drop drop
819 :     ghost 2dup drop
820 : jwilke 1.52
821 :     \ \ Parameter for target systems 06oct92py
822 :    
823 :     \ we define it ans like...
824 :     wordlist Constant target-environment
825 :    
826 :     VARIABLE env-current \ save information of current dictionary to restore with environ>
827 :    
828 :     : >ENVIRON get-current env-current ! target-environment set-current ;
829 :     : ENVIRON> env-current @ set-current ;
830 : pazsan 1.43
831 : anton 1.48 >TARGET
832 : pazsan 1.43
833 : jwilke 1.67 : environment? ( adr len -- [ x ] true | false )
834 : jwilke 1.52 target-environment search-wordlist
835 :     IF execute true ELSE false THEN ;
836 :    
837 : jwilke 1.67 : e? bl word count T environment? H 0= ABORT" environment variable not defined!" ;
838 : jwilke 1.52
839 : jwilke 1.67 : has? bl word count T environment? H
840 : jwilke 1.53 IF \ environment variable is present, return its value
841 :     ELSE \ environment variable is not present, return false
842 : jwilke 1.75 false \ debug true ABORT" arg"
843 : jwilke 1.53 THEN ;
844 : jwilke 1.52
845 :     : $has? T environment? H IF ELSE false THEN ;
846 : anton 1.48
847 : pazsan 1.54 >ENVIRON get-order get-current swap 1+ set-order
848 :     true SetValue compiler
849 : pazsan 1.83 true SetValue cross
850 : pazsan 1.54 true SetValue standard-threading
851 :     >TARGET previous
852 : jwilke 1.52
853 : jwilke 1.77 0
854 :     [IFDEF] mach-file mach-file count 1 [THEN]
855 :     [IFDEF] machine-file machine-file 1 [THEN]
856 :     [IF] included hex drop
857 :     [ELSE] cr ." No machine description!" ABORT
858 :     [THEN]
859 : pazsan 1.43
860 : jwilke 1.53 >ENVIRON
861 :    
862 : pazsan 1.54 T has? ec H
863 :     [IF]
864 :     false DefaultValue relocate
865 :     false DefaultValue file
866 :     false DefaultValue OS
867 :     false DefaultValue prims
868 :     false DefaultValue floating
869 :     false DefaultValue glocals
870 :     false DefaultValue dcomps
871 :     false DefaultValue hash
872 :     false DefaultValue xconds
873 :     false DefaultValue header
874 : pazsan 1.92 false DefaultValue backtrace
875 : pazsan 1.88 false DefaultValue new-input
876 : pazsan 1.54 [THEN]
877 :    
878 :     true DefaultValue interpreter
879 :     true DefaultValue ITC
880 :     false DefaultValue rom
881 : jwilke 1.73 true DefaultValue standardthreading
882 : jwilke 1.53
883 : jwilke 1.52 >TARGET
884 : jwilke 1.53 s" relocate" T environment? H
885 :     [IF] SetValue NIL
886 :     [ELSE] >ENVIRON T NIL H SetValue relocate
887 :     [THEN]
888 : pazsan 1.43
889 :     >CROSS
890 :    
891 : jwilke 1.52 \ \ Create additional parameters 19jan95py
892 : pazsan 1.19
893 : jwilke 1.71 \ currently cross only works for host machines with address-unit-bits
894 :     \ eual to 8 because of s! and sc!
895 :     \ but I start to query the environment just to modularize a little bit
896 :    
897 :     : check-address-unit-bits ( -- )
898 :     \ s" ADDRESS-UNIT-BITS" environment?
899 :     \ IF 8 <> ELSE true THEN
900 :     \ ABORT" ADDRESS-UNIT-BITS unknown or not equal to 8!"
901 :    
902 :     \ shit, this doesn't work because environment? is only defined for
903 :     \ gforth.fi and not kernl???.fi
904 :     ;
905 :    
906 :     check-address-unit-bits
907 :     8 Constant bits/byte \ we define: byte is address-unit
908 :    
909 :     1 bits/byte lshift Constant maxbyte
910 : jwilke 1.77 \ this sets byte size for the target machine, (probably right guess) jaw
911 : jwilke 1.67
912 : pazsan 1.19 T
913 : jwilke 1.71 NIL Constant TNIL
914 :     cell Constant tcell
915 :     cell<< Constant tcell<<
916 :     cell>bit Constant tcell>bit
917 :     bits/char Constant tbits/char
918 :     bits/char H bits/byte T /
919 :     Constant tchar
920 :     float Constant tfloat
921 :     1 bits/char lshift Constant tmaxchar
922 :     [IFUNDEF] bits/byte
923 :     8 Constant tbits/byte
924 :     [ELSE]
925 :     bits/byte Constant tbits/byte
926 :     [THEN]
927 : pazsan 1.19 H
928 : pazsan 1.81 tbits/char bits/byte / Constant tbyte
929 : jwilke 1.71
930 : pazsan 1.19
931 : anton 1.48 \ Variables 06oct92py
932 :    
933 :     Variable image
934 :     Variable tlast TNIL tlast ! \ Last name field
935 :     Variable tlastcfa \ Last code field
936 :     Variable tdoes \ Resolve does> calls
937 :     Variable bit$
938 : jwilke 1.52
939 :     \ statistics 10jun97jaw
940 :    
941 :     Variable headers-named 0 headers-named !
942 :     Variable user-vars 0 user-vars !
943 :    
944 : jwilke 1.67 : target>bitmask-size ( u1 -- u2 )
945 :     1- tcell>bit rshift 1+ ;
946 :    
947 : crook 1.100 : allocatetarget ( size -- adr )
948 : jwilke 1.67 dup allocate ABORT" CROSS: No memory for target"
949 :     swap over swap erase ;
950 : jwilke 1.52
951 : pazsan 1.54 \ \ memregion.fs
952 : jwilke 1.52
953 :    
954 :     Variable last-defined-region \ pointer to last defined region
955 :     Variable region-link \ linked list with all regions
956 :     Variable mirrored-link \ linked list for mirrored regions
957 :     0 dup mirrored-link ! region-link !
958 :    
959 :    
960 : jwilke 1.67 : >rname 6 cells + ;
961 :     : >rbm 5 cells + ;
962 :     : >rmem 4 cells + ;
963 :     : >rlink 3 cells + ;
964 : jwilke 1.52 : >rdp 2 cells + ;
965 :     : >rlen cell+ ;
966 :     : >rstart ;
967 :    
968 :    
969 :     : region ( addr len -- ) \G create a new region
970 :     \ check whether predefined region exists
971 :     save-input bl word find >r >r restore-input throw r> r> 0=
972 :     IF \ make region
973 :     drop
974 :     save-input create restore-input throw
975 :     here last-defined-region !
976 :     over ( startaddr ) , ( length ) , ( dp ) ,
977 : jwilke 1.67 region-link linked 0 , 0 , bl word count string,
978 : jwilke 1.52 ELSE \ store new parameters in region
979 :     bl word drop
980 :     >body >r r@ last-defined-region !
981 : jwilke 1.67 r@ >rlen ! dup r@ >rstart ! r> >rdp !
982 : jwilke 1.52 THEN ;
983 :    
984 :     : borders ( region -- startaddr endaddr ) \G returns lower and upper region border
985 : jwilke 1.67 dup >rstart @ swap >rlen @ over + ;
986 : jwilke 1.52
987 :     : extent ( region -- startaddr len ) \G returns the really used area
988 : jwilke 1.67 dup >rstart @ swap >rdp @ over - ;
989 : jwilke 1.52
990 :     : area ( region -- startaddr totallen ) \G returns the total area
991 : jwilke 1.79 dup >rstart @ swap >rlen @ ;
992 : jwilke 1.52
993 :     : mirrored \G mark a region as mirrored
994 :     mirrored-link
995 : jwilke 1.68 align linked last-defined-region @ , ;
996 : jwilke 1.52
997 : jwilke 1.67 : .addr ( u -- )
998 :     \G prints a 16 or 32 Bit nice hex value
999 : jwilke 1.52 base @ >r hex
1000 :     tcell 2 u>
1001 : jwilke 1.77 IF s>d <# # # # # [char] . hold # # # # #> type
1002 : jwilke 1.52 ELSE s>d <# # # # # # #> type
1003 :     THEN r> base ! ;
1004 :    
1005 :     : .regions \G display region statistic
1006 :    
1007 :     \ we want to list the regions in the right order
1008 :     \ so first collect all regions on stack
1009 :     0 region-link @
1010 :     BEGIN dup WHILE dup @ REPEAT drop
1011 :     BEGIN dup
1012 : jwilke 1.67 WHILE cr
1013 :     0 >rlink - >r
1014 :     r@ >rname count tuck type
1015 : jwilke 1.52 12 swap - 0 max spaces space
1016 : jwilke 1.67 ." Start: " r@ >rstart @ dup .addr space
1017 :     ." End: " r@ >rlen @ + .addr space
1018 :     ." DP: " r> >rdp @ .addr
1019 : jwilke 1.52 REPEAT drop
1020 : jwilke 1.53 s" rom" T $has? H 0= ?EXIT
1021 : jwilke 1.52 cr ." Mirrored:"
1022 :     mirrored-link @
1023 :     BEGIN dup
1024 : jwilke 1.67 WHILE space dup cell+ @ >rname count type @
1025 : jwilke 1.52 REPEAT drop cr
1026 :     ;
1027 :    
1028 :     \ -------- predefined regions
1029 :    
1030 :     0 0 region address-space
1031 :     \ total memory addressed and used by the target system
1032 :    
1033 :     0 0 region dictionary
1034 :     \ rom area for the compiler
1035 :    
1036 : jwilke 1.53 T has? rom H
1037 : jwilke 1.52 [IF]
1038 :     0 0 region ram-dictionary mirrored
1039 :     \ ram area for the compiler
1040 :     [ELSE]
1041 :     ' dictionary ALIAS ram-dictionary
1042 :     [THEN]
1043 :    
1044 :     0 0 region return-stack
1045 :    
1046 :     0 0 region data-stack
1047 :    
1048 :     0 0 region tib-region
1049 :    
1050 :     ' dictionary ALIAS rom-dictionary
1051 :    
1052 :    
1053 : crook 1.100 : setup-target ( -- ) \G initialize target's memory space
1054 : jwilke 1.53 s" rom" T $has? H
1055 : jwilke 1.52 IF \ check for ram and rom...
1056 : jwilke 1.72 \ address-space area nip 0<>
1057 : jwilke 1.67 ram-dictionary area nip 0<>
1058 :     rom-dictionary area nip 0<>
1059 : jwilke 1.72 and 0=
1060 : jwilke 1.52 ABORT" CROSS: define address-space, rom- , ram-dictionary, with rom-support!"
1061 :     THEN
1062 :     address-space area nip
1063 :     IF
1064 :     address-space area
1065 :     ELSE
1066 :     dictionary area
1067 :     THEN
1068 : jwilke 1.67 nip 0=
1069 : jwilke 1.52 ABORT" CROSS: define at least address-space or dictionary!!"
1070 : jwilke 1.67
1071 :     \ allocate target for each region
1072 :     region-link
1073 :     BEGIN @ dup
1074 :     WHILE dup
1075 :     0 >rlink - >r
1076 :     r@ >rlen @
1077 :     IF \ allocate mem
1078 :     r@ >rlen @ dup
1079 :    
1080 :     allocatetarget dup image !
1081 :     r@ >rmem !
1082 :    
1083 :     target>bitmask-size allocatetarget
1084 : jwilke 1.72 dup bit$ !
1085 : jwilke 1.67 r> >rbm !
1086 :    
1087 :     ELSE r> drop THEN
1088 : jwilke 1.72 REPEAT drop ;
1089 :    
1090 : crook 1.100 \ MakeKernel 22feb99jaw
1091 : jwilke 1.72
1092 :     : makekernel ( targetsize -- targetsize )
1093 :     dup dictionary >rlen ! setup-target ;
1094 :    
1095 :     >MINIMAL
1096 :     : makekernel makekernel ;
1097 :     >CROSS
1098 : jwilke 1.52
1099 : pazsan 1.54 \ \ switched tdp for rom support 03jun97jaw
1100 : jwilke 1.52
1101 :     \ second value is here to store some maximal value for statistics
1102 :     \ tempdp is also embedded here but has nothing to do with rom support
1103 :     \ (needs switched dp)
1104 :    
1105 :     variable tempdp 0 , \ temporary dp for resolving
1106 :     variable tempdp-save
1107 :    
1108 :     0 [IF]
1109 :     variable romdp 0 , \ Dictionary-Pointer for ramarea
1110 :     variable ramdp 0 , \ Dictionary-Pointer for romarea
1111 :    
1112 :     \
1113 :     variable sramdp \ start of ram-area for forth
1114 :     variable sromdp \ start of rom-area for forth
1115 :    
1116 :     [THEN]
1117 :    
1118 :    
1119 :     0 value tdp
1120 :     variable fixed \ flag: true: no automatic switching
1121 :     \ false: switching is done automatically
1122 :    
1123 :     \ Switch-Policy:
1124 :     \
1125 :     \ a header is always compiled into rom
1126 :     \ after a created word (create and variable) compilation goes to ram
1127 :     \
1128 :     \ Be careful: If you want to make the data behind create into rom
1129 :     \ you have to put >rom before create!
1130 :    
1131 :     variable constflag constflag off
1132 :    
1133 : jwilke 1.67 : activate ( region -- )
1134 :     \G next code goes to this region
1135 :     >rdp to tdp ;
1136 :    
1137 : jwilke 1.52 : (switchram)
1138 : jwilke 1.53 fixed @ ?EXIT s" rom" T $has? H 0= ?EXIT
1139 : jwilke 1.67 ram-dictionary activate ;
1140 : jwilke 1.52
1141 :     : switchram
1142 :     constflag @
1143 :     IF constflag off ELSE (switchram) THEN ;
1144 :    
1145 :     : switchrom
1146 : jwilke 1.67 fixed @ ?EXIT rom-dictionary activate ;
1147 : jwilke 1.52
1148 :     : >tempdp ( addr -- )
1149 :     tdp tempdp-save ! tempdp to tdp tdp ! ;
1150 :     : tempdp> ( -- )
1151 :     tempdp-save @ to tdp ;
1152 :    
1153 :     : >ram fixed off (switchram) fixed on ;
1154 :     : >rom fixed off switchrom fixed on ;
1155 :     : >auto fixed off switchrom ;
1156 :    
1157 :    
1158 :    
1159 :     \ : romstart dup sromdp ! romdp ! ;
1160 :     \ : ramstart dup sramdp ! ramdp ! ;
1161 :    
1162 : jwilke 1.67 \ default compilation goes to rom
1163 : jwilke 1.52 \ when romable support is off, only the rom switch is used (!!)
1164 :     >auto
1165 :    
1166 : anton 1.48 : there tdp @ ;
1167 :    
1168 : jwilke 1.52 >TARGET
1169 : anton 1.48
1170 : jwilke 1.52 \ \ Target Memory Handling
1171 : anton 1.1
1172 :     \ Byte ordering and cell size 06oct92py
1173 :    
1174 : pazsan 1.19 : cell+ tcell + ;
1175 :     : cells tcell<< lshift ;
1176 : jwilke 1.71 : chars tchar * ;
1177 :     : char+ tchar + ;
1178 : pazsan 1.19 : floats tfloat * ;
1179 : anton 1.6
1180 : anton 1.1 >CROSS
1181 : pazsan 1.19 : cell/ tcell<< rshift ;
1182 : anton 1.1 >TARGET
1183 :     20 CONSTANT bl
1184 : jwilke 1.52 \ TNIL Constant NIL
1185 : anton 1.1
1186 :     >CROSS
1187 :    
1188 : pazsan 1.20 bigendian
1189 :     [IF]
1190 : jwilke 1.52 : S! ( n addr -- ) >r s>d r> tcell bounds swap 1-
1191 : pazsan 1.20 DO maxbyte ud/mod rot I c! -1 +LOOP 2drop ;
1192 : jwilke 1.52 : S@ ( addr -- n ) >r 0 0 r> tcell bounds
1193 : pazsan 1.20 DO maxbyte * swap maxbyte um* rot + swap I c@ + swap LOOP d>s ;
1194 : pazsan 1.57 : Sc! ( n addr -- ) >r s>d r> tchar bounds swap 1-
1195 :     DO maxbyte ud/mod rot I c! -1 +LOOP 2drop ;
1196 :     : Sc@ ( addr -- n ) >r 0 0 r> tchar bounds
1197 :     DO maxbyte * swap maxbyte um* rot + swap I c@ + swap LOOP d>s ;
1198 : pazsan 1.19 [ELSE]
1199 : jwilke 1.52 : S! ( n addr -- ) >r s>d r> tcell bounds
1200 : pazsan 1.20 DO maxbyte ud/mod rot I c! LOOP 2drop ;
1201 : jwilke 1.52 : S@ ( addr -- n ) >r 0 0 r> tcell bounds swap 1-
1202 : pazsan 1.20 DO maxbyte * swap maxbyte um* rot + swap I c@ + swap -1 +LOOP d>s ;
1203 : pazsan 1.57 : Sc! ( n addr -- ) >r s>d r> tchar bounds
1204 :     DO maxbyte ud/mod rot I c! LOOP 2drop ;
1205 :     : Sc@ ( addr -- n ) >r 0 0 r> tchar bounds swap 1-
1206 :     DO maxbyte * swap maxbyte um* rot + swap I c@ + swap -1 +LOOP d>s ;
1207 : anton 1.1 [THEN]
1208 :    
1209 : jwilke 1.67 : taddr>region ( taddr -- region | 0 )
1210 :     \G finds for a target-address the correct region
1211 :     \G returns 0 if taddr is not in range of a target memory region
1212 :     region-link
1213 :     BEGIN @ dup
1214 :     WHILE dup >r
1215 :     0 >rlink - >r
1216 :     r@ >rlen @
1217 :     IF dup r@ borders within
1218 :     IF r> r> drop nip EXIT THEN
1219 :     THEN
1220 :     r> drop
1221 :     r>
1222 :     REPEAT
1223 :     2drop 0 ;
1224 :    
1225 :     : (>regionimage) ( taddr -- 'taddr )
1226 :     dup
1227 :     \ find region we want to address
1228 :     taddr>region dup 0= ABORT" Address out of range!"
1229 :     >r
1230 :     \ calculate offset in region
1231 :     r@ >rstart @ -
1232 :     \ add regions real address in our memory
1233 :     r> >rmem @ + ;
1234 :    
1235 : anton 1.1 \ Bit string manipulation 06oct92py
1236 :     \ 9may93jaw
1237 :     CREATE Bittable 80 c, 40 c, 20 c, 10 c, 8 c, 4 c, 2 c, 1 c,
1238 :     : bits ( n -- n ) chars Bittable + c@ ;
1239 :    
1240 :     : >bit ( addr n -- c-addr mask ) 8 /mod rot + swap bits ;
1241 :     : +bit ( addr n -- ) >bit over c@ or swap c! ;
1242 : pazsan 1.4 : -bit ( addr n -- ) >bit invert over c@ and swap c! ;
1243 : jwilke 1.67
1244 : jwilke 1.84 : (relon) ( taddr -- )
1245 :     [ [IFDEF] fd-relocation-table ]
1246 :     s" +" fd-relocation-table write-file throw
1247 :     dup s>d <# #s #> fd-relocation-table write-line throw
1248 :     [ [THEN] ]
1249 :     bit$ @ swap cell/ +bit ;
1250 :    
1251 :     : (reloff) ( taddr -- )
1252 :     [ [IFDEF] fd-relocation-table ]
1253 :     s" -" fd-relocation-table write-file throw
1254 :     dup s>d <# #s #> fd-relocation-table write-line throw
1255 :     [ [THEN] ]
1256 :     bit$ @ swap cell/ -bit ;
1257 : jwilke 1.67
1258 :     : (>image) ( taddr -- absaddr ) image @ + ;
1259 :    
1260 :     DEFER >image
1261 :     DEFER relon
1262 :     DEFER reloff
1263 :     DEFER correcter
1264 :    
1265 :     T has? relocate H
1266 :     [IF]
1267 :     ' (relon) IS relon
1268 :     ' (reloff) IS reloff
1269 :     ' (>image) IS >image
1270 :     [ELSE]
1271 :     ' drop IS relon
1272 :     ' drop IS reloff
1273 : jwilke 1.68 ' (>regionimage) IS >image
1274 : jwilke 1.67 [THEN]
1275 : anton 1.1
1276 :     \ Target memory access 06oct92py
1277 :    
1278 :     : align+ ( taddr -- rest )
1279 : anton 1.48 tcell tuck 1- and - [ tcell 1- ] Literal and ;
1280 : anton 1.22 : cfalign+ ( taddr -- rest )
1281 : pazsan 1.39 \ see kernel.fs:cfaligned
1282 : pazsan 1.43 /maxalign tuck 1- and - [ /maxalign 1- ] Literal and ;
1283 : anton 1.1
1284 :     >TARGET
1285 :     : aligned ( taddr -- ta-addr ) dup align+ + ;
1286 :     \ assumes cell alignment granularity (as GNU C)
1287 :    
1288 : anton 1.22 : cfaligned ( taddr1 -- taddr2 )
1289 : pazsan 1.39 \ see kernel.fs
1290 : anton 1.22 dup cfalign+ + ;
1291 :    
1292 : jwilke 1.52 : @ ( taddr -- w ) >image S@ ;
1293 :     : ! ( w taddr -- ) >image S! ;
1294 : pazsan 1.57 : c@ ( taddr -- char ) >image Sc@ ;
1295 :     : c! ( char taddr -- ) >image Sc! ;
1296 : anton 1.7 : 2@ ( taddr -- x1 x2 ) T dup cell+ @ swap @ H ;
1297 : pazsan 1.82 : 2! ( x1 x2 taddr -- ) T tuck ! cell+ ! H ;
1298 : anton 1.1
1299 :     \ Target compilation primitives 06oct92py
1300 :     \ included A! 16may93jaw
1301 :    
1302 :     : here ( -- there ) there ;
1303 :     : allot ( n -- ) tdp +! ;
1304 : jwilke 1.78 : , ( w -- ) T here H tcell T allot ! H ;
1305 :     : c, ( char -- ) T here H tchar T allot c! H ;
1306 :     : align ( -- ) T here H align+ 0 ?DO bl T c, H tchar +LOOP ;
1307 : anton 1.22 : cfalign ( -- )
1308 : jwilke 1.78 T here H cfalign+ 0 ?DO bl T c, H tchar +LOOP ;
1309 : anton 1.1
1310 : jwilke 1.71 : >address dup 0>= IF tbyte / THEN ; \ ?? jaw
1311 : pazsan 1.59 : A! swap >address swap dup relon T ! H ;
1312 :     : A, ( w -- ) >address T here H relon T , H ;
1313 : anton 1.1
1314 :     >CROSS
1315 :    
1316 : jwilke 1.52 : tcmove ( source dest len -- )
1317 :     \G cmove in target memory
1318 : pazsan 1.57 tchar * bounds
1319 : jwilke 1.52 ?DO dup T c@ H I T c! H 1+
1320 : pazsan 1.57 tchar +LOOP drop ;
1321 : anton 1.1
1322 : jwilke 1.67 \ \ Load Assembler
1323 :    
1324 : anton 1.1 >TARGET
1325 : jwilke 1.74 H also Forth definitions
1326 : anton 1.1
1327 : jwilke 1.77 : X bl word count [ ' target >wordlist ] Literal search-wordlist
1328 : jwilke 1.52 IF state @ IF compile,
1329 :     ELSE execute THEN
1330 : jwilke 1.77 ELSE -1 ABORT" Cross: access method not supported!"
1331 :     THEN ; immediate
1332 : anton 1.1
1333 : jwilke 1.52 [IFDEF] asm-include asm-include [THEN] hex
1334 : anton 1.1
1335 : jwilke 1.52 previous
1336 :     >CROSS H
1337 : anton 1.1
1338 : jwilke 1.52 \ \ -------------------- Compiler Plug Ins 01aug97jaw
1339 : anton 1.1
1340 : jwilke 1.52 >TARGET
1341 :     DEFER >body \ we need the system >body
1342 :     \ and the target >body
1343 :     >CROSS
1344 :     T 2 cells H VALUE xt>body
1345 : pazsan 1.54 DEFER doprim, \ compiles start of a primitive
1346 :     DEFER docol, \ compiles start of a colon definition
1347 : jwilke 1.52 DEFER doer,
1348 :     DEFER fini, \ compiles end of definition ;s
1349 :     DEFER doeshandler,
1350 :     DEFER dodoes,
1351 :    
1352 :     DEFER ]comp \ starts compilation
1353 :     DEFER comp[ \ ends compilation
1354 :    
1355 : pazsan 1.94 : (prim) T a, H ; ' (prim) IS prim,
1356 : pazsan 1.54
1357 : pazsan 1.94 : (cr) >tempdp ]comp prim, comp[ tempdp> ; ' (cr) IS colon-resolve
1358 : pazsan 1.54 : (ar) T ! H ; ' (ar) IS addr-resolve
1359 :     : (dr) ( ghost res-pnt target-addr addr )
1360 :     >tempdp drop over
1361 :     dup >magic @ <do:> =
1362 :     IF doer,
1363 :     ELSE dodoes,
1364 :     THEN
1365 :     tempdp> ; ' (dr) IS doer-resolve
1366 :    
1367 :     : (cm) ( -- addr )
1368 :     T here align H
1369 : pazsan 1.94 -1 prim, ; ' (cm) IS colonmark,
1370 : anton 1.1
1371 : jwilke 1.52 >TARGET
1372 : pazsan 1.94 : compile, prim, ;
1373 : jwilke 1.52 >CROSS
1374 : anton 1.1
1375 : jwilke 1.52 : refered ( ghost tag -- )
1376 : jwilke 1.53 \G creates a resolve structure
1377 : pazsan 1.54 T here aligned H swap (refered)
1378 :     ;
1379 :    
1380 :     : killref ( addr ghost -- )
1381 :     \G kills a forward reference to ghost at position addr
1382 :     \G this is used to eleminate a :dovar refence after making a DOES>
1383 :     dup >magic @ <fwd> <> IF 2drop EXIT THEN
1384 :     swap >r >link
1385 :     BEGIN dup @ dup ( addr last this )
1386 :     WHILE dup >taddr @ r@ =
1387 :     IF @ over !
1388 :     ELSE nip THEN
1389 :     REPEAT rdrop 2drop
1390 : jwilke 1.53 ;
1391 : anton 1.48
1392 : jwilke 1.52 Defer resolve-warning
1393 : anton 1.1
1394 : jwilke 1.52 : reswarn-test ( ghost res-struct -- ghost res-struct )
1395 : jwilke 1.78 over cr ." Resolving " .ghost dup ." in " >ghost @ .ghost ;
1396 : anton 1.1
1397 : jwilke 1.52 : reswarn-forward ( ghost res-struct -- ghost res-struct )
1398 : jwilke 1.78 over warnhead .ghost dup ." is referenced in "
1399 :     >ghost @ .ghost ;
1400 : anton 1.1
1401 : jwilke 1.52 \ ' reswarn-test IS resolve-warning
1402 :    
1403 : anton 1.1 \ resolve 14oct92py
1404 :    
1405 : pazsan 1.54 : resolve-loop ( ghost resolve-list tcfa -- )
1406 :     >r
1407 :     BEGIN dup WHILE
1408 :     \ dup >tag @ 2 = IF reswarn-forward THEN
1409 :     resolve-warning
1410 :     r@ over >taddr @
1411 :     2 pick >tag @
1412 :     CASE 0 OF colon-resolve ENDOF
1413 :     1 OF addr-resolve ENDOF
1414 :     2 OF doer-resolve ENDOF
1415 :     ENDCASE
1416 :     @ \ next list element
1417 :     REPEAT 2drop rdrop
1418 :     ;
1419 : jwilke 1.52
1420 :     \ : resolve-loop ( ghost tcfa -- ghost tcfa )
1421 :     \ >r dup >link @
1422 :     \ BEGIN dup WHILE dup T @ H r@ rot T ! H REPEAT drop r> ;
1423 : anton 1.1
1424 :     \ exists 9may93jaw
1425 :    
1426 : jwilke 1.52 Variable TWarnings
1427 :     TWarnings on
1428 :     Variable Exists-Warnings
1429 :     Exists-Warnings on
1430 :    
1431 : anton 1.1 : exists ( ghost tcfa -- )
1432 :     over GhostNames
1433 :     BEGIN @ dup
1434 :     WHILE 2dup cell+ @ =
1435 :     UNTIL
1436 : jwilke 1.52 2 cells + count
1437 :     TWarnings @ Exists-Warnings @ and
1438 :     IF warnhead type ." exists"
1439 :     ELSE 2drop THEN
1440 :     drop swap >link !
1441 : pazsan 1.24 ELSE true abort" CROSS: Ghostnames inconsistent "
1442 : anton 1.1 THEN ;
1443 :    
1444 : pazsan 1.94 : colon-resolved ( ghost -- )
1445 :     >link @ colon, ; \ compile-call
1446 :     : prim-resolved ( ghost -- )
1447 :     >link @ prim, ;
1448 : pazsan 1.93
1449 : anton 1.1 : resolve ( ghost tcfa -- )
1450 : pazsan 1.54 \G resolve referencies to ghost with tcfa
1451 :     \ is ghost resolved?, second resolve means another definition with the
1452 :     \ same name
1453 : jwilke 1.75 over undefined? 0= IF exists EXIT THEN
1454 : pazsan 1.54 \ get linked-list
1455 :     swap >r r@ >link @ swap \ ( list tcfa R: ghost )
1456 :     \ mark ghost as resolved
1457 :     dup r@ >link ! <res> r@ >magic !
1458 : pazsan 1.94 r@ >comp @ ['] is-forward = IF
1459 :     ['] prim-resolved r@ >comp ! THEN
1460 : pazsan 1.54 \ loop through forward referencies
1461 :     r> -rot
1462 :     comp-state @ >r Resolving comp-state !
1463 :     resolve-loop
1464 :     r> comp-state !
1465 :    
1466 :     ['] noop IS resolve-warning
1467 : jwilke 1.52 ;
1468 : anton 1.1
1469 :     \ gexecute ghost, 01nov92py
1470 :    
1471 : jwilke 1.52 : gexecute ( ghost -- )
1472 : pazsan 1.93 dup >comp @ execute ;
1473 : jwilke 1.52
1474 :     : addr, ( ghost -- )
1475 : pazsan 1.93 dup forward? IF 1 refered 0 T a, H ELSE >link @ T a, H THEN ;
1476 : jwilke 1.52
1477 :     \ !! : ghost, ghost gexecute ;
1478 : anton 1.1
1479 :     \ .unresolved 11may93jaw
1480 :    
1481 :     variable ResolveFlag
1482 :    
1483 :     \ ?touched 11may93jaw
1484 :    
1485 : jwilke 1.52 : ?touched ( ghost -- flag ) dup forward? swap >link @
1486 : anton 1.1 0 <> and ;
1487 :    
1488 : jwilke 1.53 : .forwarddefs ( ghost -- )
1489 :     ." appeared in:"
1490 :     >link
1491 :     BEGIN @ dup
1492 :     WHILE cr 5 spaces
1493 : jwilke 1.78 dup >ghost @ .ghost
1494 : jwilke 1.53 ." file " dup >file @ ?dup IF count type ELSE ." CON" THEN
1495 :     ." line " dup >line @ .dec
1496 :     REPEAT
1497 :     drop ;
1498 :    
1499 : anton 1.1 : ?resolved ( ghostname -- )
1500 :     dup cell+ @ ?touched
1501 : jwilke 1.53 IF dup
1502 :     cell+ cell+ count cr type ResolveFlag on
1503 :     cell+ @ .forwarddefs
1504 :     ELSE drop
1505 :     THEN ;
1506 : anton 1.1
1507 :     : .unresolved ( -- )
1508 :     ResolveFlag off cr ." Unresolved: "
1509 :     Ghostnames
1510 :     BEGIN @ dup
1511 :     WHILE dup ?resolved
1512 : anton 1.10 REPEAT drop ResolveFlag @
1513 :     IF
1514 : anton 1.48 -1 abort" Unresolved words!"
1515 : anton 1.10 ELSE
1516 :     ." Nothing!"
1517 :     THEN
1518 :     cr ;
1519 : anton 1.1
1520 : jwilke 1.52 : .stats
1521 :     base @ >r decimal
1522 :     cr ." named Headers: " headers-named @ .
1523 :     r> base ! ;
1524 :    
1525 : jwilke 1.79 >MINIMAL
1526 :    
1527 :     : .unresolved .unresolved ;
1528 :    
1529 : anton 1.1 >CROSS
1530 :     \ Header states 12dec92py
1531 :    
1532 : pazsan 1.90 bigendian [IF] 0 [ELSE] tcell 1- [THEN] Constant flag+
1533 :     : flag! ( w -- ) tlast @ flag+ + dup >r T c@ xor r> c! H ;
1534 : anton 1.1
1535 :     VARIABLE ^imm
1536 :    
1537 : anton 1.89 \ !! should be target wordsize specific
1538 : pazsan 1.90 $80 constant alias-mask
1539 :     $40 constant immediate-mask
1540 :     $20 constant restrict-mask
1541 : anton 1.89
1542 : anton 1.1 >TARGET
1543 : anton 1.89 : immediate immediate-mask flag!
1544 : pazsan 1.18 ^imm @ @ dup <imm> = IF drop EXIT THEN
1545 : anton 1.1 <res> <> ABORT" CROSS: Cannot immediate a unresolved word"
1546 :     <imm> ^imm @ ! ;
1547 : anton 1.89 : restrict restrict-mask flag! ;
1548 : jwilke 1.52
1549 : pazsan 1.54 : isdoer
1550 :     \G define a forth word as doer, this makes obviously only sence on
1551 :     \G forth processors such as the PSC1000
1552 :     <do:> last-header-ghost @ >magic ! ;
1553 : anton 1.1 >CROSS
1554 :    
1555 :     \ Target Header Creation 01nov92py
1556 :    
1557 : jwilke 1.52 >TARGET
1558 : anton 1.1 : string, ( addr count -- )
1559 : anton 1.89 dup T c, H bounds ?DO I c@ T c, H LOOP ;
1560 :     : lstring, ( addr count -- )
1561 :     dup T , H bounds ?DO I c@ T c, H LOOP ;
1562 :     : name, ( "name" -- ) bl word count T lstring, cfalign H ;
1563 : anton 1.1 : view, ( -- ) ( dummy ) ;
1564 : jwilke 1.52 >CROSS
1565 : anton 1.1
1566 : pazsan 1.25 \ Target Document Creation (goes to crossdoc.fd) 05jul95py
1567 :    
1568 : pazsan 1.55 s" ./doc/crossdoc.fd" r/w create-file throw value doc-file-id
1569 : pazsan 1.25 \ contains the file-id of the documentation file
1570 :    
1571 : pazsan 1.40 : T-\G ( -- )
1572 : pazsan 1.25 source >in @ /string doc-file-id write-line throw
1573 : pazsan 1.40 postpone \ ;
1574 : pazsan 1.25
1575 : pazsan 1.39 Variable to-doc to-doc on
1576 : pazsan 1.25
1577 :     : cross-doc-entry ( -- )
1578 :     to-doc @ tlast @ 0<> and \ not an anonymous (i.e. noname) header
1579 :     IF
1580 :     s" " doc-file-id write-line throw
1581 :     s" make-doc " doc-file-id write-file throw
1582 : jwilke 1.98 Last-Header-Ghost @ >ghostname doc-file-id write-file throw
1583 : pazsan 1.25 >in @
1584 :     [char] ( parse 2drop
1585 :     [char] ) parse doc-file-id write-file throw
1586 :     s" )" doc-file-id write-file throw
1587 :     [char] \ parse 2drop
1588 : pazsan 1.40 T-\G
1589 : pazsan 1.25 >in !
1590 : pazsan 1.39 THEN ;
1591 : pazsan 1.25
1592 : pazsan 1.28 \ Target TAGS creation
1593 :    
1594 : pazsan 1.39 s" kernel.TAGS" r/w create-file throw value tag-file-id
1595 : pazsan 1.28 \ contains the file-id of the tags file
1596 :    
1597 :     Create tag-beg 2 c, 7F c, bl c,
1598 :     Create tag-end 2 c, bl c, 01 c,
1599 :     Create tag-bof 1 c, 0C c,
1600 :    
1601 :     2variable last-loadfilename 0 0 last-loadfilename 2!
1602 :    
1603 :     : put-load-file-name ( -- )
1604 : jwilke 1.77 sourcefilename last-loadfilename 2@ d<>
1605 : pazsan 1.28 IF
1606 :     tag-bof count tag-file-id write-line throw
1607 : anton 1.31 sourcefilename 2dup
1608 : pazsan 1.28 tag-file-id write-file throw
1609 :     last-loadfilename 2!
1610 :     s" ,0" tag-file-id write-line throw
1611 :     THEN ;
1612 :    
1613 :     : cross-tag-entry ( -- )
1614 :     tlast @ 0<> \ not an anonymous (i.e. noname) header
1615 :     IF
1616 :     put-load-file-name
1617 :     source >in @ min tag-file-id write-file throw
1618 :     tag-beg count tag-file-id write-file throw
1619 : jwilke 1.77 tlast @ >image count 1F and tag-file-id write-file throw
1620 : pazsan 1.28 tag-end count tag-file-id write-file throw
1621 : anton 1.31 base @ decimal sourceline# 0 <# #s #> tag-file-id write-file throw
1622 : pazsan 1.28 \ >in @ 0 <# #s [char] , hold #> tag-file-id write-line throw
1623 :     s" ,0" tag-file-id write-line throw
1624 :     base !
1625 :     THEN ;
1626 :    
1627 : pazsan 1.43 \ Check for words
1628 :    
1629 :     Defer skip? ' false IS skip?
1630 :    
1631 : jwilke 1.75 : skipdef ( <name> -- )
1632 : jwilke 1.79 \G skip definition of an undefined word in undef-words and
1633 :     \G all-words mode
1634 : jwilke 1.75 ghost dup forward?
1635 :     IF >magic <skip> swap !
1636 :     ELSE drop THEN ;
1637 :    
1638 : jwilke 1.77 : tdefined? ( -- flag ) \ name
1639 : jwilke 1.75 ghost undefined? 0= ;
1640 :    
1641 :     : defined2? ( -- flag ) \ name
1642 :     \G return true for anything else than forward, even for <skip>
1643 :     \G that's what we want
1644 : jwilke 1.52 ghost forward? 0= ;
1645 : pazsan 1.43
1646 : jwilke 1.79 : forced? ( -- flag ) \ name
1647 :     \G return ture if it is a foreced skip with defskip
1648 :     ghost >magic @ <skip> = ;
1649 :    
1650 : pazsan 1.43 : needed? ( -- flag ) \ name
1651 : anton 1.48 \G returns a false flag when
1652 :     \G a word is not defined
1653 :     \G a forward reference exists
1654 :     \G so the definition is not skipped!
1655 :     bl word gfind
1656 : jwilke 1.75 IF dup undefined?
1657 : anton 1.48 nip
1658 :     0=
1659 :     ELSE drop true THEN ;
1660 : pazsan 1.43
1661 : pazsan 1.44 : doer? ( -- flag ) \ name
1662 :     ghost >magic @ <do:> = ;
1663 :    
1664 : pazsan 1.43 : skip-defs ( -- )
1665 :     BEGIN refill WHILE source -trailing nip 0= UNTIL THEN ;
1666 :    
1667 : pazsan 1.28 \ Target header creation
1668 :    
1669 : pazsan 1.54 Variable NoHeaderFlag
1670 :     NoHeaderFlag off
1671 : anton 1.1
1672 : pazsan 1.54 : 0.r ( n1 n2 -- )
1673 :     base @ >r hex
1674 :     0 swap <# 0 ?DO # LOOP #> type
1675 :     r> base ! ;
1676 : jwilke 1.84
1677 :     : .sym ( adr len -- )
1678 :     \G escapes / and \ to produce sed output
1679 : jwilke 1.52 bounds
1680 :     DO I c@ dup
1681 : jwilke 1.77 CASE [char] / OF drop ." \/" ENDOF
1682 :     [char] \ OF drop ." \\" ENDOF
1683 : jwilke 1.52 dup OF emit ENDOF
1684 :     ENDCASE
1685 : pazsan 1.54 LOOP ;
1686 : jwilke 1.52
1687 : pazsan 1.43 : (Theader ( "name" -- ghost )
1688 : pazsan 1.54 \ >in @ bl word count type 2 spaces >in !
1689 :     \ wordheaders will always be compiled to rom
1690 :     switchrom
1691 :     \ build header in target
1692 :     NoHeaderFlag @
1693 :     IF NoHeaderFlag off
1694 :     ELSE
1695 :     T align H view,
1696 : jwilke 1.78 tlast @ dup 0> IF tcell - THEN T A, H there tlast !
1697 : pazsan 1.54 1 headers-named +! \ Statistic
1698 :     >in @ T name, H >in !
1699 :     THEN
1700 :     T cfalign here H tlastcfa !
1701 : jwilke 1.84 \ Old Symbol table sed-script
1702 : pazsan 1.54 \ >in @ cr ." sym:s/CFA=" there 4 0.r ." /" bl word count .sym ." /g" cr >in !
1703 : jwilke 1.78 ghost
1704 : jwilke 1.84 \ output symbol table to extra file
1705 :     [ [IFDEF] fd-symbol-table ]
1706 :     base @ hex there s>d <# 8 0 DO # LOOP #> fd-symbol-table write-file throw base !
1707 :     s" :" fd-symbol-table write-file throw
1708 :     dup >ghostname fd-symbol-table write-line throw
1709 :     [ [THEN] ]
1710 : pazsan 1.54 dup Last-Header-Ghost !
1711 :     dup >magic ^imm ! \ a pointer for immediate
1712 :     Already @
1713 :     IF dup >end tdoes !
1714 :     ELSE 0 tdoes !
1715 :     THEN
1716 : anton 1.89 alias-mask flag!
1717 : pazsan 1.54 cross-doc-entry cross-tag-entry ;
1718 : anton 1.1
1719 :     VARIABLE ;Resolve 1 cells allot
1720 : jwilke 1.52 \ this is the resolver information from ":"
1721 :     \ resolving is done by ";"
1722 : anton 1.1
1723 : pazsan 1.11 : Theader ( "name" -- ghost )
1724 :     (THeader dup there resolve 0 ;Resolve ! ;
1725 : anton 1.1
1726 :     >TARGET
1727 :     : Alias ( cfa -- ) \ name
1728 : pazsan 1.43 >in @ skip? IF 2drop EXIT THEN >in !
1729 : jwilke 1.53 dup 0< s" prims" T $has? H 0= and
1730 : pazsan 1.43 IF
1731 : jwilke 1.53 .sourcepos ." needs prim: " >in @ bl word count type >in ! cr
1732 : pazsan 1.43 THEN
1733 : anton 1.89 (THeader over resolve T A, H alias-mask flag! ;
1734 : pazsan 1.42 : Alias: ( cfa -- ) \ name
1735 : pazsan 1.43 >in @ skip? IF 2drop EXIT THEN >in !
1736 : jwilke 1.53 dup 0< s" prims" T $has? H 0= and
1737 : pazsan 1.43 IF
1738 : jwilke 1.53 .sourcepos ." needs doer: " >in @ bl word count type >in ! cr
1739 : pazsan 1.43 THEN
1740 :     ghost tuck swap resolve <do:> swap >magic ! ;
1741 : pazsan 1.64
1742 :     Variable prim#
1743 :     : first-primitive ( n -- ) prim# ! ;
1744 :     : Primitive ( -- ) \ name
1745 :     prim# @ T Alias H -1 prim# +! ;
1746 : anton 1.1 >CROSS
1747 :    
1748 :     \ Conditionals and Comments 11may93jaw
1749 :    
1750 :     : ;Cond
1751 :     postpone ;
1752 :     swap ! ; immediate
1753 :    
1754 :     : Cond: ( -- ) \ name {code } ;
1755 :     atonce on
1756 :     ghost
1757 :     >exec
1758 :     :NONAME ;
1759 :    
1760 :     : restrict? ( -- )
1761 :     \ aborts on interprete state - ae
1762 :     state @ 0= ABORT" CROSS: Restricted" ;
1763 :    
1764 :     : Comment ( -- )
1765 :     >in @ atonce on ghost swap >in ! ' swap >exec ! ;
1766 :    
1767 :     Comment ( Comment \
1768 :    
1769 :     \ compile 10may93jaw
1770 :    
1771 :     : compile ( -- ) \ name
1772 :     restrict?
1773 : pazsan 1.13 bl word gfind dup 0= ABORT" CROSS: Can't compile "
1774 : anton 1.1 0> ( immediate? )
1775 :     IF >exec @ compile,
1776 :     ELSE postpone literal postpone gexecute THEN ;
1777 :     immediate
1778 :    
1779 : pazsan 1.96 T has? peephole H [IF]
1780 : pazsan 1.95 : (cc) compile call T >body a, H ; ' (cc) IS colon,
1781 : pazsan 1.96 [ELSE]
1782 :     ' (prim) IS colon,
1783 :     [THEN]
1784 : pazsan 1.94
1785 : jwilke 1.52 : [G']
1786 :     \G ticks a ghost and returns its address
1787 :     bl word gfind 0= ABORT" CROSS: Ghost don't exists"
1788 :     state @
1789 :     IF postpone literal
1790 :     THEN ; immediate
1791 :    
1792 :     : ghost>cfa
1793 : jwilke 1.75 dup undefined? ABORT" CROSS: forward " >link @ ;
1794 : jwilke 1.52
1795 :     >TARGET
1796 :    
1797 :     : ' ( -- cfa )
1798 :     \ returns the target-cfa of a ghost
1799 :     bl word gfind 0= ABORT" CROSS: Ghost don't exists"
1800 :     ghost>cfa ;
1801 :    
1802 :     Cond: ['] T ' H alit, ;Cond
1803 :    
1804 :     >CROSS
1805 :    
1806 :     : [T']
1807 :     \ returns the target-cfa of a ghost, or compiles it as literal
1808 :     postpone [G'] state @ IF postpone ghost>cfa ELSE ghost>cfa THEN ; immediate
1809 : pazsan 1.42
1810 : jwilke 1.52 \ \ threading modell 13dec92py
1811 :     \ modularized 14jun97jaw
1812 :    
1813 :     : fillcfa ( usedcells -- )
1814 : jwilke 1.78 T cells H xt>body swap - 0 ?DO 0 X c, tchar +LOOP ;
1815 : jwilke 1.52
1816 :     : (>body) ( cfa -- pfa ) xt>body + ; ' (>body) T IS >body H
1817 :    
1818 : pazsan 1.94 : (doer,) ( ghost -- ) ]comp addr, comp[ 1 fillcfa ; ' (doer,) IS doer,
1819 : jwilke 1.52
1820 :     : (docol,) ( -- ) [G'] :docol doer, ; ' (docol,) IS docol,
1821 :    
1822 :     : (doprim,) ( -- )
1823 :     there xt>body + ca>native T a, H 1 fillcfa ; ' (doprim,) IS doprim,
1824 :    
1825 :     : (doeshandler,) ( -- )
1826 :     T cfalign H compile :doesjump T 0 , H ; ' (doeshandler,) IS doeshandler,
1827 :    
1828 :     : (dodoes,) ( does-action-ghost -- )
1829 :     ]comp [G'] :dodoes gexecute comp[
1830 :     addr,
1831 :     T here H tcell - reloff 2 fillcfa ; ' (dodoes,) IS dodoes,
1832 :    
1833 :     : (lit,) ( n -- ) compile lit T , H ; ' (lit,) IS lit,
1834 :    
1835 : jwilke 1.67 \ if we dont produce relocatable code alit, defaults to lit, jaw
1836 : jwilke 1.84 \ this is just for convenience, so we don't have to define alit,
1837 :     \ seperately for embedded systems....
1838 :     T has? relocate H
1839 : jwilke 1.67 [IF]
1840 : pazsan 1.66 : (alit,) ( n -- ) compile lit T a, H ; ' (alit,) IS alit,
1841 : jwilke 1.67 [ELSE]
1842 :     : (alit,) ( n -- ) lit, ; ' (alit,) IS alit,
1843 :     [THEN]
1844 : jwilke 1.52
1845 :     : (fini,) compile ;s ; ' (fini,) IS fini,
1846 : pazsan 1.42
1847 : pazsan 1.43 [IFUNDEF] (code)
1848 :     Defer (code)
1849 :     Defer (end-code)
1850 :     [THEN]
1851 :    
1852 : anton 1.1 >TARGET
1853 : pazsan 1.43 : Code
1854 : jwilke 1.52 defempty?
1855 : anton 1.48 (THeader there resolve
1856 : jwilke 1.53 [ T e? prims H 0= [IF] T e? ITC H [ELSE] true [THEN] ] [IF]
1857 : jwilke 1.52 doprim,
1858 : anton 1.48 [THEN]
1859 :     depth (code) ;
1860 : pazsan 1.43
1861 :     : Code:
1862 : jwilke 1.52 defempty?
1863 : anton 1.48 ghost dup there ca>native resolve <do:> swap >magic !
1864 : pazsan 1.43 depth (code) ;
1865 :    
1866 :     : end-code
1867 : jwilke 1.52 (end-code)
1868 : pazsan 1.43 depth ?dup IF 1- <> ABORT" CROSS: Stack changed"
1869 :     ELSE true ABORT" CROSS: Stack empty" THEN
1870 : jwilke 1.52 ;
1871 : anton 1.14
1872 : anton 1.1 >CROSS
1873 : jwilke 1.52
1874 : anton 1.1 \ tLiteral 12dec92py
1875 :    
1876 :     >TARGET
1877 : pazsan 1.40 Cond: \G T-\G ;Cond
1878 :    
1879 : anton 1.1 Cond: Literal ( n -- ) restrict? lit, ;Cond
1880 :     Cond: ALiteral ( n -- ) restrict? alit, ;Cond
1881 :    
1882 :     : Char ( "<char>" -- ) bl word char+ c@ ;
1883 :     Cond: [Char] ( "<char>" -- ) restrict? Char lit, ;Cond
1884 :    
1885 : pazsan 1.43 \ some special literals 27jan97jaw
1886 :    
1887 : jwilke 1.52 \ !! Known Bug: Special Literals and plug-ins work only correct
1888 : pazsan 1.93 \ on targets with char = 8 bit
1889 : jwilke 1.52
1890 : pazsan 1.43 Cond: MAXU
1891 : jwilke 1.52 restrict?
1892 : pazsan 1.93 compile lit tcell 0 ?DO FF T c, H LOOP
1893 : jwilke 1.52 ;Cond
1894 : pazsan 1.43
1895 :     Cond: MINI
1896 : jwilke 1.52 restrict?
1897 : pazsan 1.93 compile lit bigendian
1898 :     IF 80 T c, H tcell 1 ?DO 0 T c, H LOOP
1899 :     ELSE tcell 1 ?DO 0 T c, H LOOP 80 T c, H
1900 :     THEN
1901 : jwilke 1.52 ;Cond
1902 : pazsan 1.43
1903 :     Cond: MAXI
1904 : jwilke 1.52 restrict?
1905 : pazsan 1.93 compile lit bigendian
1906 :     IF 7F T c, H tcell 1 ?DO FF T c, H LOOP
1907 :     ELSE tcell 1 ?DO FF T c, H LOOP 7F T c, H
1908 :     THEN
1909 : pazsan 1.43 ;Cond
1910 :    
1911 : anton 1.1 >CROSS
1912 :     \ Target compiling loop 12dec92py
1913 :     \ ">tib trick thrown out 10may93jaw
1914 :     \ number? defined at the top 11may93jaw
1915 : jwilke 1.77 \ replaced >in by save-input
1916 :    
1917 :     : discard 0 ?DO drop LOOP ;
1918 : anton 1.1
1919 :     \ compiled word might leave items on stack!
1920 : jwilke 1.77 : tcom ( x1 .. xn n name -- )
1921 :     \ dup count type space
1922 :     gfind ?dup
1923 :     IF >r >r discard r> r>
1924 :     0> IF >exec @ execute
1925 :     ELSE gexecute THEN
1926 :     EXIT
1927 :     THEN
1928 :     number? dup
1929 :     IF 0> IF swap lit, THEN lit, discard
1930 :     ELSE 2drop restore-input throw ghost gexecute THEN ;
1931 : anton 1.1
1932 :     >TARGET
1933 :     \ : ; DOES> 13dec92py
1934 :     \ ] 9may93py/jaw
1935 :    
1936 :     : ] state on
1937 : pazsan 1.54 Compiling comp-state !
1938 : anton 1.1 BEGIN
1939 : jwilke 1.77 BEGIN save-input bl word
1940 :     dup c@ 0= WHILE drop discard refill 0=
1941 : anton 1.1 ABORT" CROSS: End of file while target compiling"
1942 :     REPEAT
1943 :     tcom
1944 :     state @
1945 :     0=
1946 :     UNTIL ;
1947 :    
1948 :     \ by the way: defining a second interpreter (a compiler-)loop
1949 :     \ is not allowed if a system should be ans conform
1950 :    
1951 :     : : ( -- colon-sys ) \ Name
1952 : jwilke 1.52 defempty?
1953 :     constflag off \ don't let this flag work over colon defs
1954 :     \ just to go sure nothing unwanted happens
1955 : pazsan 1.43 >in @ skip? IF drop skip-defs EXIT THEN >in !
1956 : anton 1.1 (THeader ;Resolve ! there ;Resolve cell+ !
1957 : jwilke 1.52 docol, ]comp depth T ] H ;
1958 : anton 1.1
1959 : pazsan 1.37 : :noname ( -- colon-sys )
1960 : jwilke 1.52 T cfalign H there docol, 0 ;Resolve ! depth T ] H ;
1961 : pazsan 1.37
1962 : pazsan 1.2 Cond: EXIT ( -- ) restrict? compile ;S ;Cond
1963 : anton 1.6
1964 :     Cond: ?EXIT ( -- ) 1 abort" CROSS: using ?exit" ;Cond
1965 : pazsan 1.2
1966 : jwilke 1.52 >CROSS
1967 :     : LastXT ;Resolve @ 0= abort" CROSS: no definition for LastXT"
1968 :     ;Resolve cell+ @ ;
1969 :    
1970 :     >TARGET
1971 :    
1972 :     Cond: recurse ( -- ) Last-Ghost @ gexecute ;Cond
1973 :    
1974 : anton 1.1 Cond: ; ( -- ) restrict?
1975 :     depth ?dup IF 1- <> ABORT" CROSS: Stack changed"
1976 :     ELSE true ABORT" CROSS: Stack empty" THEN
1977 : jwilke 1.52 fini,
1978 :     comp[
1979 :     state off
1980 : anton 1.1 ;Resolve @
1981 : pazsan 1.94 IF ;Resolve @ ;Resolve cell+ @ resolve
1982 : pazsan 1.95 ['] colon-resolved ;Resolve @ >comp ! THEN
1983 : pazsan 1.54 Interpreting comp-state !
1984 : anton 1.1 ;Cond
1985 : pazsan 1.54 Cond: [ restrict? state off Interpreting comp-state ! ;Cond
1986 : anton 1.1
1987 :     >CROSS
1988 : pazsan 1.54
1989 :     Create GhostDummy ghostheader
1990 :     <res> GhostDummy >magic !
1991 :    
1992 : jwilke 1.52 : !does ( does-action -- )
1993 :     \ !! zusammenziehen und dodoes, machen!
1994 : pazsan 1.54 tlastcfa @ [G'] :dovar killref
1995 :     \ tlastcfa @ dup there >r tdp ! compile :dodoes r> tdp ! T cell+ ! H ;
1996 : jwilke 1.52 \ !! geht so nicht, da dodoes, ghost will!
1997 : pazsan 1.54 GhostDummy >link ! GhostDummy
1998 :     tlastcfa @ >tempdp dodoes, tempdp> ;
1999 : anton 1.1
2000 : pazsan 1.95 : g>body ( ghost -- body )
2001 :     >link @ T >body H ;
2002 :     : does-resolved ( ghost -- )
2003 :     dup g>body alit, >end @ g>body colon, ;
2004 :    
2005 : anton 1.1 >TARGET
2006 :     Cond: DOES> restrict?
2007 : jwilke 1.52 compile (does>) doeshandler,
2008 :     \ resolve words made by builders
2009 : pazsan 1.95 tdoes @ ?dup IF @ dup T here H resolve
2010 :     ['] prim-resolved swap >comp ! THEN
2011 : anton 1.1 ;Cond
2012 : jwilke 1.52 : DOES> switchrom doeshandler, T here H !does depth T ] H ;
2013 : anton 1.1
2014 :     >CROSS
2015 :     \ Creation 01nov92py
2016 :    
2017 :     \ Builder 11may93jaw
2018 :    
2019 : pazsan 1.94 : Builder ( Create-xt do-ghost "name" -- )
2020 : jwilke 1.52 \ builds up a builder in current vocabulary
2021 :     \ create-xt is executed when word is interpreted
2022 :     \ do:-xt is executet when the created word from builder is executed
2023 :     \ for do:-xt an additional entry after the normal ghost-enrys is used
2024 :    
2025 : pazsan 1.94 Make-Ghost ( Create-xt do-ghost ghost )
2026 :     rot swap ( do-ghost Create-xt ghost )
2027 : jwilke 1.78 >exec ! , ;
2028 : anton 1.1
2029 : jwilke 1.52 : gdoes, ( ghost -- )
2030 :     \ makes the codefield for a word that is built
2031 : jwilke 1.75 >end @ dup undefined? 0=
2032 : jwilke 1.52 IF
2033 : pazsan 1.42 dup >magic @ <do:> =
2034 : pazsan 1.54 IF doer,
2035 :     ELSE dodoes,
2036 :     THEN
2037 :     EXIT
2038 : jwilke 1.52 THEN
2039 :     \ compile :dodoes gexecute
2040 :     \ T here H tcell - reloff
2041 : pazsan 1.54 2 refered
2042 :     0 fillcfa
2043 :     ;
2044 : anton 1.1
2045 : jwilke 1.52 : TCreate ( <name> -- )
2046 :     executed-ghost @
2047 :     create-forward-warn
2048 :     IF ['] reswarn-forward IS resolve-warning THEN
2049 : pazsan 1.96 Theader >r dup , dup gdoes,
2050 : jwilke 1.77 \ stores execution semantic in the built word
2051 : jwilke 1.78 \ if the word already has a semantic (concerns S", IS, .", DOES>)
2052 :     \ then keep it
2053 : pazsan 1.93 >end @
2054 :     dup >exec @ r@ >exec dup @ ['] NoExec = IF ! ELSE 2drop THEN
2055 :     >comp @ r> >comp ! ;
2056 : jwilke 1.52
2057 :     : RTCreate ( <name> -- )
2058 :     \ creates a new word with code-field in ram
2059 :     executed-ghost @
2060 :     create-forward-warn
2061 :     IF ['] reswarn-forward IS resolve-warning THEN
2062 :     \ make Alias
2063 : anton 1.89 (THeader there 0 T a, H alias-mask flag! ( S executed-ghost new-ghost )
2064 : jwilke 1.52 \ store poiter to code-field
2065 :     switchram T cfalign H
2066 :     there swap T ! H
2067 :     there tlastcfa !
2068 :     dup there resolve 0 ;Resolve !
2069 :     >r dup gdoes,
2070 : jwilke 1.78 \ stores execution semantic in the built word
2071 :     \ if the word already has a semantic (concerns S", IS, .", DOES>)
2072 :     \ then keep it
2073 :     >end @ >exec @ r> >exec dup @ ['] NoExec =
2074 :     IF ! ELSE 2drop THEN ;
2075 : anton 1.1
2076 :     : Build: ( -- [xt] [colon-sys] )
2077 : jwilke 1.52 :noname postpone TCreate ;
2078 :    
2079 :     : BuildSmart: ( -- [xt] [colon-sys] )
2080 :     :noname
2081 : jwilke 1.53 [ T has? rom H [IF] ]
2082 : jwilke 1.52 postpone RTCreate
2083 :     [ [ELSE] ]
2084 :     postpone TCreate
2085 :     [ [THEN] ] ;
2086 : anton 1.1
2087 :     : gdoes> ( ghost -- addr flag )
2088 : jwilke 1.52 executed-ghost @
2089 : anton 1.1 state @ IF gexecute true EXIT THEN
2090 : pazsan 1.93 g>body false ;
2091 : anton 1.1
2092 :     \ DO: ;DO 11may93jaw
2093 :     \ changed to ?EXIT 10may93jaw
2094 :    
2095 : pazsan 1.93 : DO: ( -- ghost [xt] [colon-sys] )
2096 : anton 1.1 here ghostheader
2097 : pazsan 1.11 :noname postpone gdoes> postpone ?EXIT ;
2098 : anton 1.1
2099 : pazsan 1.93 : by: ( -- ghost [xt] [colon-sys] ) \ name
2100 : pazsan 1.42 ghost
2101 :     :noname postpone gdoes> postpone ?EXIT ;
2102 :    
2103 : pazsan 1.93 : ;DO ( ghost [xt] [colon-sys] -- ghost )
2104 : anton 1.1 postpone ; ( S addr xt )
2105 :     over >exec ! ; immediate
2106 :    
2107 : pazsan 1.96 T has? peephole H [IF]
2108 : pazsan 1.93 : compile: ( ghost -- ghost [xt] [colon-sys] )
2109 :     :noname postpone g>body ;
2110 :     : ;compile ( ghost [xt] [colon-sys] -- ghost )
2111 : pazsan 1.94 postpone ; over >comp ! ; immediate
2112 : pazsan 1.96 [ELSE]
2113 :     : compile: ( ghost -- ghost xt colon-sys ) :noname ;
2114 :     : ;compile ( ghost xt colon-sys -- ghost )
2115 : pazsan 1.99 postpone ; drop ['] prim-resolved over >comp ! ; immediate
2116 : pazsan 1.96 [THEN]
2117 : pazsan 1.93
2118 :     : by ( -- ghost ) \ Name
2119 : anton 1.1 ghost >end @ ;
2120 :    
2121 :     >TARGET
2122 :     \ Variables and Constants 05dec92py
2123 :    
2124 : jwilke 1.52 Build: ( n -- ) ;
2125 :     by: :docon ( ghost -- n ) T @ H ;DO
2126 : pazsan 1.94 compile: alit, compile @ ;compile
2127 : jwilke 1.52 Builder (Constant)
2128 :    
2129 :     Build: ( n -- ) T , H ;
2130 :     by (Constant)
2131 :     Builder Constant
2132 :    
2133 :     Build: ( n -- ) T A, H ;
2134 :     by (Constant)
2135 :     Builder AConstant
2136 :    
2137 :     Build: ( d -- ) T , , H ;
2138 :     DO: ( ghost -- d ) T dup cell+ @ swap @ H ;DO
2139 :     Builder 2Constant
2140 :    
2141 :     BuildSmart: ;
2142 : pazsan 1.42 by: :dovar ( ghost -- addr ) ;DO
2143 : pazsan 1.95 \ compile: alit, ;compile
2144 : anton 1.1 Builder Create
2145 :    
2146 : jwilke 1.53 T has? rom H [IF]
2147 : pazsan 1.54 Build: ( -- ) T here 0 , H switchram T align here swap ! 0 , H ( switchrom ) ;
2148 : jwilke 1.52 by (Constant)
2149 :     Builder Variable
2150 :     [ELSE]
2151 : anton 1.1 Build: T 0 , H ;
2152 :     by Create
2153 : pazsan 1.96 \ compile: alit, ;compile
2154 : anton 1.1 Builder Variable
2155 : jwilke 1.52 [THEN]
2156 : anton 1.1
2157 : jwilke 1.53 T has? rom H [IF]
2158 : pazsan 1.54 Build: ( -- ) T here 0 , H switchram T align here swap ! 0 , 0 , H ( switchrom ) ;
2159 :     by (Constant)
2160 :     Builder 2Variable
2161 :     [ELSE]
2162 :     Build: T 0 , 0 , H ;
2163 :     by Create
2164 : pazsan 1.96 \ compile: alit, ;compile
2165 : pazsan 1.54 Builder 2Variable
2166 :     [THEN]
2167 :    
2168 :     T has? rom H [IF]
2169 :     Build: ( -- ) T here 0 , H switchram T align here swap ! 0 , H ( switchrom ) ;
2170 : jwilke 1.52 by (Constant)
2171 :     Builder AVariable
2172 :     [ELSE]
2173 : anton 1.1 Build: T 0 A, H ;
2174 :     by Create
2175 : pazsan 1.96 \ compile: alit, ;compile
2176 : anton 1.1 Builder AVariable
2177 : jwilke 1.52 [THEN]
2178 : anton 1.1
2179 : pazsan 1.3 \ User variables 04may94py
2180 :    
2181 :     >CROSS
2182 : jwilke 1.78
2183 : pazsan 1.3 Variable tup 0 tup !
2184 :     Variable tudp 0 tudp !
2185 : jwilke 1.78
2186 : pazsan 1.3 : u, ( n -- udp )
2187 :     tup @ tudp @ + T ! H
2188 : pazsan 1.19 tudp @ dup T cell+ H tudp ! ;
2189 : jwilke 1.78
2190 : pazsan 1.3 : au, ( n -- udp )
2191 :     tup @ tudp @ + T A! H
2192 : pazsan 1.19 tudp @ dup T cell+ H tudp ! ;
2193 : jwilke 1.78
2194 : pazsan 1.3 >TARGET
2195 :    
2196 : jwilke 1.78 Build: 0 u, X , ;
2197 :     by: :douser ( ghost -- up-addr ) X @ tup @ + ;DO
2198 : pazsan 1.94 compile: compile useraddr T @ , H ;compile
2199 : anton 1.1 Builder User
2200 :    
2201 : jwilke 1.78 Build: 0 u, X , 0 u, drop ;
2202 : pazsan 1.3 by User
2203 : anton 1.1 Builder 2User
2204 :    
2205 : jwilke 1.78 Build: 0 au, X , ;
2206 : pazsan 1.3 by User
2207 : anton 1.1 Builder AUser
2208 :    
2209 : jwilke 1.52 BuildSmart: T , H ;
2210 : pazsan 1.44 by (Constant)
2211 : anton 1.1 Builder Value
2212 :    
2213 : jwilke 1.52 BuildSmart: T A, H ;
2214 : pazsan 1.44 by (Constant)
2215 : pazsan 1.32 Builder AValue
2216 :    
2217 : jwilke 1.52 BuildSmart: ( -- ) [T'] noop T A, H ;
2218 : pazsan 1.42 by: :dodefer ( ghost -- ) ABORT" CROSS: Don't execute" ;DO
2219 : pazsan 1.94 compile: alit, compile @ compile execute ;compile
2220 : anton 1.1 Builder Defer
2221 : pazsan 1.37
2222 : jwilke 1.78 Build: ( inter comp -- ) swap T immediate A, A, H ;
2223 : pazsan 1.37 DO: ( ghost -- ) ABORT" CROSS: Don't execute" ;DO
2224 : anton 1.38 Builder interpret/compile:
2225 : pazsan 1.24
2226 :     \ Sturctures 23feb95py
2227 :    
2228 :     >CROSS
2229 :     : nalign ( addr1 n -- addr2 )
2230 :     \ addr2 is the aligned version of addr1 wrt the alignment size n
2231 :     1- tuck + swap invert and ;
2232 :     >TARGET
2233 :    
2234 : pazsan 1.44 Build: ;
2235 :     by: :dofield T @ H + ;DO
2236 : pazsan 1.94 compile: T @ H lit, compile + ;compile
2237 : pazsan 1.44 Builder (Field)
2238 :    
2239 : anton 1.51 Build: ( align1 offset1 align size "name" -- align2 offset2 )
2240 :     rot dup T , H ( align1 align size offset1 )
2241 :     + >r nalign r> ;
2242 : pazsan 1.44 by (Field)
2243 : pazsan 1.24 Builder Field
2244 :    
2245 : anton 1.51 : struct T 1 chars 0 H ;
2246 : pazsan 1.24 : end-struct T 2Constant H ;
2247 :    
2248 : jwilke 1.52 : cell% ( n -- size align )
2249 : anton 1.51 T 1 cells H dup ;
2250 : pazsan 1.88
2251 : pazsan 1.91 Build: ( m v -- m' v ) dup T , cell+ H ;
2252 : pazsan 1.88 DO: abort" Not in cross mode" ;DO
2253 :     Builder input-method
2254 :    
2255 :     Build: ( m v size -- m v' ) over T , H + ;
2256 :     DO: abort" Not in cross mode" ;DO
2257 :     Builder input-var
2258 : pazsan 1.24
2259 : jwilke 1.52 \ structural conditionals 17dec92py
2260 :    
2261 :     >CROSS
2262 :     : ?struc ( flag -- ) ABORT" CROSS: unstructured " ;
2263 :     : sys? ( sys -- sys ) dup 0= ?struc ;
2264 :     : >mark ( -- sys ) T here ( dup ." M" hex. ) 0 , H ;
2265 :    
2266 : jwilke 1.78 : branchoffset ( src dest -- ) - tchar / ; \ ?? jaw
2267 : jwilke 1.52
2268 : jwilke 1.78 : >resolve ( sys -- )
2269 :     X here ( dup ." >" hex. ) over branchoffset swap X ! ;
2270 : jwilke 1.52
2271 : jwilke 1.78 : <resolve ( sys -- )
2272 :     X here ( dup ." <" hex. ) branchoffset X , ;
2273 : jwilke 1.52
2274 : jwilke 1.78 :noname compile branch X here branchoffset X , ;
2275 : pazsan 1.54 IS branch, ( target-addr -- )
2276 : jwilke 1.78 :noname compile ?branch X here branchoffset X , ;
2277 : pazsan 1.54 IS ?branch, ( target-addr -- )
2278 :     :noname compile branch T here 0 , H ;
2279 :     IS branchmark, ( -- branchtoken )
2280 :     :noname compile ?branch T here 0 , H ;
2281 :     IS ?branchmark, ( -- branchtoken )
2282 :     :noname T here 0 , H ;
2283 :     IS ?domark, ( -- branchtoken )
2284 : jwilke 1.78 :noname dup X @ ?struc X here over branchoffset swap X ! ;
2285 : pazsan 1.54 IS branchtoresolve, ( branchtoken -- )
2286 : jwilke 1.78 :noname branchto, X here ;
2287 : pazsan 1.54 IS branchtomark, ( -- target-addr )
2288 : jwilke 1.52
2289 :     >TARGET
2290 :    
2291 :     \ Structural Conditionals 12dec92py
2292 :    
2293 :     Cond: BUT restrict? sys? swap ;Cond
2294 :     Cond: YET restrict? sys? dup ;Cond
2295 :    
2296 :     >CROSS
2297 :    
2298 : jwilke 1.78 Variable tleavings 0 tleavings !
2299 : jwilke 1.52
2300 : pazsan 1.54 : (done) ( addr -- )
2301 :     tleavings @
2302 :     BEGIN dup
2303 :     WHILE
2304 :     >r dup r@ cell+ @ \ address of branch
2305 :     u> 0= \ lower than DO?
2306 :     WHILE
2307 :     r@ 2 cells + @ \ branch token
2308 :     branchtoresolve,
2309 :     r@ @ r> free throw
2310 :     REPEAT r> THEN
2311 :     tleavings ! drop ;
2312 :    
2313 : jwilke 1.53 >TARGET
2314 :    
2315 : pazsan 1.54 Cond: DONE ( addr -- ) restrict? (done) ;Cond
2316 : jwilke 1.53
2317 :     >CROSS
2318 : pazsan 1.54 : (leave) ( branchtoken -- )
2319 : jwilke 1.53 3 cells allocate throw >r
2320 :     T here H r@ cell+ !
2321 :     r@ 2 cells + !
2322 :     tleavings @ r@ !
2323 :     r> tleavings ! ;
2324 :     >TARGET
2325 :    
2326 : pazsan 1.54 Cond: LEAVE restrict? branchmark, (leave) ;Cond
2327 :     Cond: ?LEAVE restrict? compile 0= ?branchmark, (leave) ;Cond
2328 : jwilke 1.53
2329 : pazsan 1.54 >CROSS
2330 :     \ !!JW ToDo : Move to general tools section
2331 :    
2332 :     : to1 ( x1 x2 xn n -- addr )
2333 :     \G packs n stack elements in a allocated memory region
2334 :     dup dup 1+ cells allocate throw dup >r swap 1+
2335 :     0 DO tuck ! cell+ LOOP
2336 :     drop r> ;
2337 :     : 1to ( addr -- x1 x2 xn )
2338 :     \G unpacks the elements saved by to1
2339 :     dup @ swap over cells + swap
2340 :     0 DO dup @ swap 1 cells - LOOP
2341 :     free throw ;
2342 :    
2343 :     : loop] branchto, dup <resolve tcell - (done) ;
2344 :    
2345 :     : skiploop] ?dup IF branchto, branchtoresolve, THEN ;
2346 :    
2347 :     >TARGET
2348 :    
2349 : jwilke 1.52 \ Structural Conditionals 12dec92py
2350 :    
2351 : jwilke 1.53 >TARGET
2352 : jwilke 1.52 Cond: AHEAD restrict? branchmark, ;Cond
2353 :     Cond: IF restrict? ?branchmark, ;Cond
2354 :     Cond: THEN restrict? sys? branchto, branchtoresolve, ;Cond
2355 :     Cond: ELSE restrict? sys? compile AHEAD swap compile THEN ;Cond
2356 :    
2357 :     Cond: BEGIN restrict? branchtomark, ;Cond
2358 :     Cond: WHILE restrict? sys? compile IF swap ;Cond
2359 :     Cond: AGAIN restrict? sys? branch, ;Cond
2360 :     Cond: UNTIL restrict? sys? ?branch, ;Cond
2361 :     Cond: REPEAT restrict? over 0= ?struc compile AGAIN compile THEN ;Cond
2362 :    
2363 :     Cond: CASE restrict? 0 ;Cond
2364 :     Cond: OF restrict? 1+ >r compile over compile =
2365 :     compile IF compile drop r> ;Cond
2366 : pazsan 1.45 Cond: ENDOF restrict? >r compile ELSE r> ;Cond
2367 :     Cond: ENDCASE restrict? compile drop 0 ?DO compile THEN LOOP ;Cond
2368 : anton 1.1
2369 :     \ Structural Conditionals 12dec92py
2370 :    
2371 : jwilke 1.67 :noname \ ?? i think 0 is too much! jaw
2372 : pazsan 1.54 0 compile (do)
2373 :     branchtomark, 2 to1 ;
2374 :     IS do, ( -- target-addr )
2375 :    
2376 :     \ :noname
2377 :     \ compile 2dup compile = compile IF
2378 :     \ compile 2drop compile ELSE
2379 :     \ compile (do) branchtomark, 2 to1 ;
2380 :     \ IS ?do,
2381 :    
2382 :     :noname
2383 :     0 compile (?do) ?domark, (leave)
2384 :     branchtomark, 2 to1 ;
2385 :     IS ?do, ( -- target-addr )
2386 :     :noname compile (for) branchtomark, ;
2387 :     IS for, ( -- target-addr )
2388 :     :noname 1to compile (loop) loop] compile unloop skiploop] ;
2389 :     IS loop, ( target-addr -- )
2390 :     :noname 1to compile (+loop) loop] compile unloop skiploop] ;
2391 :     IS +loop, ( target-addr -- )
2392 :     :noname compile (next) loop] compile unloop ;
2393 :     IS next, ( target-addr -- )
2394 :    
2395 :     Cond: DO restrict? do, ;Cond
2396 :     Cond: ?DO restrict? ?do, ;Cond
2397 :     Cond: FOR restrict? for, ;Cond
2398 :    
2399 :     Cond: LOOP restrict? sys? loop, ;Cond
2400 :     Cond: +LOOP restrict? sys? +loop, ;Cond
2401 :     Cond: NEXT restrict? sys? next, ;Cond
2402 : jwilke 1.52
2403 : anton 1.1 \ String words 23feb93py
2404 :    
2405 : jwilke 1.52 : ," [char] " parse T string, align H ;
2406 : anton 1.1
2407 : pazsan 1.97 Cond: ." restrict? compile (.") T ," H ;Cond
2408 :     Cond: S" restrict? compile (S") T ," H ;Cond
2409 :     Cond: ABORT" restrict? compile (ABORT") T ," H ;Cond
2410 : anton 1.1
2411 :     Cond: IS T ' >body H compile ALiteral compile ! ;Cond
2412 : pazsan 1.66 : IS T >address ' >body ! H ;
2413 : pazsan 1.9 Cond: TO T ' >body H compile ALiteral compile ! ;Cond
2414 :     : TO T ' >body ! H ;
2415 : anton 1.1
2416 : jwilke 1.52 Cond: defers T ' >body @ compile, H ;Cond
2417 :     : on T -1 swap ! H ;
2418 :     : off T 0 swap ! H ;
2419 :    
2420 : anton 1.1 \ LINKED ERR" ENV" 2ENV" 18may93jaw
2421 :    
2422 :     \ linked list primitive
2423 : jwilke 1.79 : linked X here over X @ X A, swap X ! ;
2424 : jwilke 1.52 : chained T linked A, H ;
2425 : anton 1.1
2426 :     : err" s" ErrLink linked" evaluate T , H
2427 : jwilke 1.52 [char] " parse T string, align H ;
2428 : anton 1.1
2429 :     : env" [char] " parse s" EnvLink linked" evaluate
2430 : jwilke 1.52 T string, align , H ;
2431 : anton 1.1
2432 :     : 2env" [char] " parse s" EnvLink linked" evaluate
2433 : jwilke 1.52 here >r T string, align , , H
2434 : anton 1.1 r> dup T c@ H 80 and swap T c! H ;
2435 :    
2436 :     \ compile must be last 22feb93py
2437 :    
2438 :     Cond: compile ( -- ) restrict? \ name
2439 : pazsan 1.13 bl word gfind dup 0= ABORT" CROSS: Can't compile"
2440 : anton 1.1 0> IF gexecute
2441 :     ELSE dup >magic @ <imm> =
2442 :     IF gexecute
2443 : pazsan 1.54 ELSE compile (compile) addr, THEN THEN ;Cond
2444 : anton 1.1
2445 : jwilke 1.101 Cond: [compile] ( -- ) restrict? \ name
2446 :     bl word gfind dup 0= ABORT" CROSS: Can't compile"
2447 :     0> IF gexecute
2448 :     ELSE dup >magic @ <imm> =
2449 :     IF gexecute
2450 :     ELSE compile (compile) addr, THEN THEN ;Cond
2451 :    
2452 : anton 1.1 Cond: postpone ( -- ) restrict? \ name
2453 : pazsan 1.13 bl word gfind dup 0= ABORT" CROSS: Can't compile"
2454 : anton 1.1 0> IF gexecute
2455 :     ELSE dup >magic @ <imm> =
2456 :     IF gexecute
2457 : pazsan 1.54 ELSE compile (compile) addr, THEN THEN ;Cond
2458 :    
2459 : jwilke 1.77 \ save-cross 17mar93py
2460 :    
2461 :     hex
2462 :    
2463 :     >CROSS
2464 :     Create magic s" Gforth2x" here over allot swap move
2465 :    
2466 :     bigendian 1+ \ strangely, in magic big=0, little=1
2467 :     tcell 1 = 0 and or
2468 :     tcell 2 = 2 and or
2469 :     tcell 4 = 4 and or
2470 :     tcell 8 = 6 and or
2471 :     tchar 1 = 00 and or
2472 :     tchar 2 = 28 and or
2473 :     tchar 4 = 50 and or
2474 :     tchar 8 = 78 and or
2475 :     magic 7 + c!
2476 :    
2477 :     : save-cross ( "image-name" "binary-name" -- )
2478 :     bl parse ." Saving to " 2dup type cr
2479 :     w/o bin create-file throw >r
2480 :     TNIL IF
2481 : anton 1.80 s" #! " r@ write-file throw
2482 :     bl parse r@ write-file throw
2483 :     s" --image-file" r@ write-file throw
2484 : jwilke 1.77 #lf r@ emit-file throw
2485 :     r@ dup file-position throw drop 8 mod 8 swap ( file-id limit index )
2486 :     ?do
2487 :     bl over emit-file throw
2488 :     loop
2489 :     drop
2490 :     magic 8 r@ write-file throw \ write magic
2491 :     ELSE
2492 :     bl parse 2drop
2493 :     THEN
2494 :     image @ there
2495 :     r@ write-file throw \ write image
2496 :     TNIL IF
2497 :     bit$ @ there 1- tcell>bit rshift 1+
2498 :     r@ write-file throw \ write tags
2499 :     THEN
2500 :     r> close-file throw ;
2501 :    
2502 :     : save-region ( addr len -- )
2503 :     bl parse w/o bin create-file throw >r
2504 :     swap >image swap r@ write-file throw
2505 :     r> close-file throw ;
2506 :    
2507 : pazsan 1.54 \ \ minimal definitions
2508 :    
2509 : jwilke 1.77 >MINIMAL also minimal
2510 :    
2511 : anton 1.1 \ Usefull words 13feb93py
2512 :    
2513 :     : KB 400 * ;
2514 :    
2515 : pazsan 1.54 \ \ [IF] [ELSE] [THEN] ... 14sep97jaw
2516 :    
2517 :     \ it is useful to define our own structures and not to rely
2518 :     \ on the words in the compiler
2519 :     \ The words in the compiler might be defined with vocabularies
2520 :     \ this doesn't work with our self-made compile-loop
2521 :    
2522 :     Create parsed 20 chars allot \ store word we parsed
2523 :    
2524 :     : upcase
2525 :     parsed count bounds
2526 :     ?DO I c@ toupper I c! LOOP ;
2527 :    
2528 :     : [ELSE]
2529 :     1 BEGIN
2530 :     BEGIN bl word count dup WHILE
2531 : jwilke 1.77 comment? 20 umin parsed place upcase parsed count
2532 : pazsan 1.54 2dup s" [IF]" compare 0= >r
2533 :     2dup s" [IFUNDEF]" compare 0= >r
2534 :     2dup s" [IFDEF]" compare 0= r> or r> or
2535 :     IF 2drop 1+
2536 :     ELSE 2dup s" [ELSE]" compare 0=
2537 :     IF 2drop 1- dup
2538 :     IF 1+
2539 :     THEN
2540 :     ELSE
2541 :     2dup s" [ENDIF]" compare 0= >r
2542 :     s" [THEN]" compare 0= r> or
2543 :     IF 1- THEN
2544 :     THEN
2545 :     THEN
2546 :     ?dup 0= ?EXIT
2547 :     REPEAT
2548 :     2drop refill 0=
2549 :     UNTIL drop ; immediate
2550 :    
2551 :     : [THEN] ( -- ) ; immediate
2552 :    
2553 :     : [ENDIF] ( -- ) ; immediate
2554 :    
2555 :     : [IF] ( flag -- )
2556 :     0= IF postpone [ELSE] THEN ; immediate
2557 :    
2558 :     Cond: [IF] postpone [IF] ;Cond
2559 :     Cond: [THEN] postpone [THEN] ;Cond
2560 :     Cond: [ELSE] postpone [ELSE] ;Cond
2561 :    
2562 : anton 1.1 \ define new [IFDEF] and [IFUNDEF] 20may93jaw
2563 :    
2564 : jwilke 1.77 : defined? tdefined? ;
2565 : pazsan 1.44 : needed? needed? ;
2566 :     : doer? doer? ;
2567 : anton 1.1
2568 : jwilke 1.52 \ we want to use IFDEF on compiler directives (e.g. E?) in the source, too
2569 :    
2570 :     : directive?
2571 : jwilke 1.77 bl word count [ ' target >wordlist ] literal search-wordlist
2572 : jwilke 1.52 dup IF nip THEN ;
2573 :    
2574 :     : [IFDEF] >in @ directive? swap >in !
2575 : jwilke 1.77 0= IF tdefined? ELSE name 2drop true THEN
2576 : jwilke 1.52 postpone [IF] ;
2577 :    
2578 : jwilke 1.77 : [IFUNDEF] tdefined? 0= postpone [IF] ;
2579 : anton 1.1
2580 : pazsan 1.54 Cond: [IFDEF] postpone [IFDEF] ;Cond
2581 :    
2582 :     Cond: [IFUNDEF] postpone [IFUNDEF] ;Cond
2583 :    
2584 : anton 1.1 \ C: \- \+ Conditional Compiling 09jun93jaw
2585 :    
2586 : jwilke 1.77 : C: >in @ tdefined? 0=
2587 :     IF >in ! X :
2588 : anton 1.1 ELSE drop
2589 :     BEGIN bl word dup c@
2590 :     IF count comment? s" ;" compare 0= ?EXIT
2591 :     ELSE refill 0= ABORT" CROSS: Out of Input while C:"
2592 :     THEN
2593 :     AGAIN
2594 :     THEN ;
2595 :    
2596 : jwilke 1.74 : d? d? ;
2597 :    
2598 :     \G doesn't skip line when debug switch is on
2599 :     : \D D? 0= IF postpone \ THEN ;
2600 : jwilke 1.52
2601 : anton 1.48 \G interprets the line if word is not defined
2602 : jwilke 1.77 : \- tdefined? IF postpone \ THEN ;
2603 : anton 1.48
2604 :     \G interprets the line if word is defined
2605 : jwilke 1.77 : \+ tdefined? 0= IF postpone \ THEN ;
2606 : anton 1.1
2607 : anton 1.48 Cond: \- \- ;Cond
2608 :     Cond: \+ \+ ;Cond
2609 : jwilke 1.52 Cond: \D \D ;Cond
2610 : anton 1.48
2611 :     : ?? bl word find IF execute ELSE drop 0 THEN ;
2612 :    
2613 :     : needed:
2614 :     \G defines ghost for words that we want to be compiled
2615 :     BEGIN >in @ bl word c@ WHILE >in ! ghost drop REPEAT drop ;
2616 :    
2617 : anton 1.1 \ words that should be in minimal
2618 : jwilke 1.52
2619 :     create s-buffer 50 chars allot
2620 :    
2621 : jwilke 1.77 bigendian Constant bigendian
2622 : anton 1.1
2623 : jwilke 1.52 : here there ;
2624 : jwilke 1.67 : equ constant ;
2625 :     : mark there constant ;
2626 : pazsan 1.54
2627 :     \ compiler directives
2628 : jwilke 1.52 : >ram >ram ;
2629 :     : >rom >rom ;
2630 :     : >auto >auto ;
2631 :     : >tempdp >tempdp ;
2632 :     : tempdp> tempdp> ;
2633 :     : const constflag on ;
2634 :     : warnings name 3 = 0= twarnings ! drop ;
2635 : anton 1.60 : | ;
2636 :     \ : | NoHeaderFlag on ; \ This is broken (damages the last word)
2637 : jwilke 1.52
2638 : anton 1.48 : save-cross save-cross ;
2639 : jwilke 1.52 : save-region save-region ;
2640 :     : tdump swap >image swap dump ;
2641 :    
2642 : anton 1.48 also forth
2643 : jwilke 1.52 [IFDEF] Label : Label defempty? Label ; [THEN]
2644 :     [IFDEF] start-macros : start-macros defempty? start-macros ; [THEN]
2645 : jwilke 1.77 \ [IFDEF] builttag : builttag builttag ; [THEN]
2646 : anton 1.48 previous
2647 :    
2648 : jwilke 1.52 : s" [char] " parse s-buffer place s-buffer count ; \ for environment?
2649 : pazsan 1.43 : + + ;
2650 : jwilke 1.52 : 1+ 1 + ;
2651 :     : 2+ 2 + ;
2652 : pazsan 1.43 : 1- 1- ;
2653 :     : - - ;
2654 : jwilke 1.52 : and and ;
2655 :     : or or ;
2656 : pazsan 1.43 : 2* 2* ;
2657 :     : * * ;
2658 :     : / / ;
2659 :     : dup dup ;
2660 :     : over over ;
2661 :     : swap swap ;
2662 :     : rot rot ;
2663 :     : drop drop ;
2664 :     : = = ;
2665 :     : 0= 0= ;
2666 :     : lshift lshift ;
2667 :     : 2/ 2/ ;
2668 : pazsan 1.19 : . . ;
2669 : anton 1.1
2670 : jwilke 1.79 : all-words ['] forced? IS skip? ;
2671 : pazsan 1.43 : needed-words ['] needed? IS skip? ;
2672 : jwilke 1.75 : undef-words ['] defined2? IS skip? ;
2673 :     : skipdef skipdef ;
2674 : anton 1.1
2675 : pazsan 1.40 : \ postpone \ ; immediate
2676 : pazsan 1.47 : \G T-\G ; immediate
2677 : pazsan 1.40 : ( postpone ( ; immediate
2678 : anton 1.1 : include bl word count included ;
2679 : jwilke 1.52 : require require ;
2680 : anton 1.1 : .( [char] ) parse type ;
2681 : jwilke 1.52 : ." [char] " parse type ;
2682 : anton 1.1 : cr cr ;
2683 :    
2684 : jwilke 1.77 : times 0 ?DO dup X c, LOOP drop ; \ used for space table creation
2685 :    
2686 :     \ only forth also cross also minimal definitions order
2687 : anton 1.1
2688 :     \ cross-compiler words
2689 :    
2690 :     : decimal decimal ;
2691 :     : hex hex ;
2692 :    
2693 : jwilke 1.77 \ : tudp X tudp ;
2694 :     \ : tup X tup ;
2695 :    
2696 :     : doc-off false to-doc ! ;
2697 :     : doc-on true to-doc ! ;
2698 : pazsan 1.39
2699 : jwilke 1.52 [IFDEF] dbg : dbg dbg ; [THEN]
2700 : pazsan 1.39
2701 : anton 1.1 \ for debugging...
2702 :     : order order ;
2703 : jwilke 1.52 : hwords words ;
2704 :     : words also ghosts words previous ;
2705 : anton 1.1 : .s .s ;
2706 :     : bye bye ;
2707 : pazsan 1.99
2708 :     \ dummy
2709 :    
2710 :     : group source >in ! drop ;
2711 : anton 1.1
2712 :     \ turnkey direction
2713 :     : H forth ; immediate
2714 :     : T minimal ; immediate
2715 :     : G ghosts ; immediate
2716 :    
2717 : jwilke 1.77 : turnkey
2718 : jwilke 1.78 \GFORTH 0 set-order also ghosts
2719 :     \ANSI [ ' ghosts >wordlist ] Literal 1 set-order
2720 :     also target definitions
2721 : jwilke 1.77 also Minimal also ;
2722 : anton 1.1
2723 :     \ these ones are pefered:
2724 :    
2725 :     : lock turnkey ;
2726 : jwilke 1.74 : unlock previous forth also cross ;
2727 : jwilke 1.52
2728 : jwilke 1.77 \ also minimal
2729 : jwilke 1.101 : [[+++ also unlock ;
2730 :     : +++]] previous previous also also ;
2731 : anton 1.1
2732 :     unlock definitions also minimal
2733 :     : lock lock ;
2734 :     lock
2735 : jwilke 1.77
2736 :     \ load cross compiler extension defined in mach file
2737 :    
2738 :     UNLOCK >CROSS
2739 :    
2740 :     [IFDEF] extend-cross extend-cross [THEN]
2741 :    
2742 :     LOCK

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help