--- gforth/cross.fs 1996/08/21 14:58:38 1.38 +++ gforth/cross.fs 1997/02/06 21:22:58 1.42 @@ -104,7 +104,7 @@ Variable tdp \ Parameter for target systems 06oct92py -included +mach-file count included \ Create additional parameters 19jan95py @@ -131,14 +131,6 @@ H >TARGET 20 CONSTANT bl -1 Constant NIL --2 Constant :docol --3 Constant :docon --4 Constant :dovar --5 Constant :douser --6 Constant :dodefer --7 Constant :dofield --8 Constant :dodoes --9 Constant :doesjump >CROSS @@ -173,7 +165,7 @@ bigendian \ MakeKernal 12dec92py >MINIMAL -: makekernal ( targetsize -- targetsize ) +: makekernel ( targetsize -- targetsize ) bit$ over 1- cell>bit rshift 1+ initmem image over initmem tdp off ; @@ -194,7 +186,7 @@ CREATE Bittable 80 c, 40 c, 20 c, 10 c, : align+ ( taddr -- rest ) cell tuck 1- and - [ cell 1- ] Literal and ; : cfalign+ ( taddr -- rest ) - \ see kernal.fs:cfaligned + \ see kernel.fs:cfaligned float tuck 1- and - [ float 1- ] Literal and ; >TARGET @@ -202,7 +194,7 @@ CREATE Bittable 80 c, 40 c, 20 c, 10 c, \ assumes cell alignment granularity (as GNU C) : cfaligned ( taddr1 -- taddr2 ) - \ see kernal.fs + \ see kernel.fs dup cfalign+ + ; >CROSS @@ -233,15 +225,10 @@ CREATE Bittable 80 c, 40 c, 20 c, 10 c, \ threading modell 13dec92py -\ generic threading modell -: docol, ( -- ) :docol T A, 0 , H ; - >TARGET : >body ( cfa -- pfa ) T cell+ cell+ H ; >CROSS -: dodoes, ( -- ) T :doesjump A, 0 , H ; - \ Ghost Builder 06oct92py \ new version with temp variable 10may93jaw @@ -252,7 +239,7 @@ VARIABLE VocTemp : T> previous VocTemp @ set-current ; 4711 Constant 4712 Constant -4713 Constant +4713 Constant 4714 Constant \ iForth makes only immediate directly after create \ make atonce trick! ? @@ -381,11 +368,11 @@ VARIABLE ^imm s" crossdoc.fd" r/w create-file throw value doc-file-id \ contains the file-id of the documentation file -: \G ( -- ) +: T-\G ( -- ) source >in @ /string doc-file-id write-line throw - source >in ! drop ; immediate + postpone \ ; -Variable to-doc +Variable to-doc to-doc on : cross-doc-entry ( -- ) to-doc @ tlast @ 0<> and \ not an anonymous (i.e. noname) header @@ -398,13 +385,13 @@ Variable to-doc [char] ) parse doc-file-id write-file throw s" )" doc-file-id write-file throw [char] \ parse 2drop - POSTPONE \g + T-\G >in ! - THEN to-doc on ; + THEN ; \ Target TAGS creation -s" kernal.TAGS" r/w create-file throw value tag-file-id +s" kernel.TAGS" r/w create-file throw value tag-file-id \ contains the file-id of the tags file Create tag-beg 2 c, 7F c, bl c, @@ -463,8 +450,9 @@ VARIABLE ;Resolve 1 cells allot >TARGET : Alias ( cfa -- ) \ name - dup 0< IF to-doc off THEN (THeader over resolve T A, H 80 flag! ; +: Alias: ( cfa -- ) \ name + ghost tuck swap resolve swap >magic ! ; >CROSS \ Conditionals and Comments 11may93jaw @@ -500,7 +488,8 @@ ghost unloop ghost ;S ghost lit ghost (compile) ghost ! 2drop drop ghost (does>) ghost noop 2drop ghost (.") ghost (S") ghost (ABORT") 2drop drop -ghost ' +ghost ' drop +ghost :docol ghost :doesjump ghost :dodoes 2drop drop \ compile 10may93jaw @@ -512,6 +501,11 @@ ghost ' ELSE postpone literal postpone gexecute THEN ; immediate +\ generic threading modell +: docol, ( -- ) compile :docol T 0 , H ; + +: dodoes, ( -- ) compile :doesjump T 0 , H ; + >TARGET : ' ( -- cfa ) bl word gfind 0= ABORT" CROSS: undefined " dup >magic @ = ABORT" CROSS: forward " >link @ ; @@ -527,6 +521,8 @@ Cond: chars ;Cond : alit, ( n -- ) compile lit T A, H ; >TARGET +Cond: \G T-\G ;Cond + Cond: Literal ( n -- ) restrict? lit, ;Cond Cond: ALiteral ( n -- ) restrict? alit, ;Cond @@ -585,7 +581,8 @@ Cond: ; ( -- ) restrict? Cond: [ restrict? state off ;Cond >CROSS -: !does :dodoes tlastcfa @ tuck T ! cell+ ! H ; +: !does + tlastcfa @ dup there >r tdp ! compile :dodoes r> tdp ! T cell+ ! H ; >TARGET Cond: DOES> restrict? @@ -606,8 +603,11 @@ Cond: DOES> restrict? \ DOES> dup >exec @ execute ; : gdoes, ( ghost -- ) >end @ dup >magic @ <> - IF dup >link @ dup 0< IF T A, 0 , H drop EXIT THEN drop THEN - :dodoes T A, H gexecute T here H cell - reloff ; + IF + dup >magic @ = + IF gexecute T 0 , H EXIT THEN + THEN + compile :dodoes gexecute T here H cell - reloff ; : TCreate ( -- ) last-ghost @ @@ -630,6 +630,10 @@ Cond: DOES> restrict? here ghostheader :noname postpone gdoes> postpone ?EXIT ; +: by: ( -- addr [xt] [colon-sys] ) \ name + ghost + :noname postpone gdoes> postpone ?EXIT ; + : ;DO ( addr [xt] [colon-sys] -- ) postpone ; ( S addr xt ) over >exec ! ; immediate @@ -641,9 +645,8 @@ Cond: DOES> restrict? \ Variables and Constants 05dec92py Build: ; -DO: ( ghost -- addr ) ;DO +by: :dovar ( ghost -- addr ) ;DO Builder Create -by Create :dovar resolve Build: T 0 , H ; by Create @@ -667,9 +670,8 @@ Variable tudp 0 tudp ! >TARGET Build: T 0 u, , H ; -DO: ( ghost -- up-addr ) T @ H tup @ + ;DO +by: :douser ( ghost -- up-addr ) T @ H tup @ + ;DO Builder User -by User :douser resolve Build: T 0 u, , 0 u, drop H ; by User @@ -680,9 +682,8 @@ by User Builder AUser Build: ( n -- ) T , H ; -DO: ( ghost -- n ) T @ H ;DO +by: :docon ( ghost -- n ) T @ H ;DO Builder Constant -by Constant :docon resolve Build: ( n -- ) T A, H ; by Constant @@ -701,9 +702,8 @@ by Constant Builder AValue Build: ( -- ) compile noop ; -DO: ( ghost -- ) ABORT" CROSS: Don't execute" ;DO +by: :dodefer ( ghost -- ) ABORT" CROSS: Don't execute" ;DO Builder Defer -by Defer :dodefer resolve Build: ( inter comp -- ) swap T immediate A, A, H ; DO: ( ghost -- ) ABORT" CROSS: Don't execute" ;DO @@ -719,9 +719,8 @@ Builder interpret/compile: Build: >r rot r@ nalign dup T , H ( align1 size offset ) + swap r> nalign ; -DO: T @ H + ;DO +by: :dofield T @ H + ;DO Builder Field -by Field :dofield resolve : struct T 0 1 chars H ; : end-struct T 2Constant H ; @@ -915,14 +914,15 @@ char 1 bigendian + cell + magic 7 + c! : drop drop ; : = = ; : lshift lshift ; : 2/ 2/ ; : . . ; -cell constant cell +\ cell constant cell + +mach-file count included \ include bug5.fs \ only forth also minimal definitions -: \ postpone \ ; -: \G postpone \G ; -: ( postpone ( ; +: \ postpone \ ; immediate +: ( postpone ( ; immediate : include bl word count included ; : .( [char] ) parse type ; : cr cr ; @@ -936,7 +936,12 @@ only forth also minimal definitions : hex hex ; : tudp T tudp H ; -: tup T tup H ; minimal +: tup T tup H ; + +: doc-off false T to-doc H ! ; +: doc-on true T to-doc H ! ; + +minimal \ for debugging... : order order ;