--- gforth/cross.fs 1994/02/11 16:30:45 1.1 +++ gforth/cross.fs 1994/05/18 17:29:50 1.4 @@ -1,5 +1,5 @@ \ CROSS.FS The Cross-Compiler 06oct92py -\ $Id: cross.fs,v 1.1 1994/02/11 16:30:45 anton Exp $ +\ $Id: cross.fs,v 1.4 1994/05/18 17:29:50 pazsan Exp $ \ Idea and implementation: Bernd Paysan (py) \ Copyright 1992 by the ANSI figForth Development Group @@ -117,13 +117,6 @@ Variable bit$ Variable tdp : there tdp @ ; -\ Constants 06apr93py - --2 Constant :docol --3 Constant :docon --4 Constant :dovar --5 Constant :dodoes - \ Parameter for target systems 06oct92py include machine.fs @@ -144,7 +137,9 @@ include machine.fs -2 Constant :docol -3 Constant :docon -4 Constant :dovar --5 Constant :dodoes +-5 Constant :douser +-6 Constant :dodoes +-7 Constant :doesjump >CROSS @@ -186,7 +181,9 @@ CREATE Bittable 80 c, 40 c, 20 c, 10 c, : >bit ( addr n -- c-addr mask ) 8 /mod rot + swap bits ; : +bit ( addr n -- ) >bit over c@ or swap c! ; +: -bit ( addr n -- ) >bit invert over c@ and swap c! ; : relon ( taddr -- ) bit$ @ swap cell/ +bit ; +: reloff ( taddr -- ) bit$ @ swap cell/ -bit ; \ Target memory access 06oct92py @@ -228,7 +225,7 @@ CREATE Bittable 80 c, 40 c, 20 c, 10 c, : >body ( cfa -- pfa ) T cell+ cell+ H ; >CROSS -: dodoes, ( -- ) T 0 , 0 , H ; +: dodoes, ( -- ) T :doesjump A, 0 , H ; \ Ghost Builder 06oct92py @@ -412,7 +409,7 @@ ghost (do) ghost (?do) ghost (for) drop ghost (loop) ghost (+loop) 2drop ghost (next) drop -ghost unloop ghost EXIT 2drop +ghost unloop ghost ;S 2drop ghost lit ghost (compile) ghost ! 2drop drop ghost (;code) ghost noop 2drop ghost (.") ghost (S") ghost (ABORT") 2drop drop @@ -481,10 +478,12 @@ Cond: [Char] ( "" -- ) restrict (THeader ;Resolve ! there ;Resolve cell+ ! docol, depth T ] H ; +Cond: EXIT ( -- ) restrict? compile ;S ;Cond + Cond: ; ( -- ) restrict? depth ?dup IF 1- <> ABORT" CROSS: Stack changed" ELSE true ABORT" CROSS: Stack empty" THEN - compile EXIT state off + compile ;S state off ;Resolve @ IF ;Resolve @ ;Resolve cell+ @ resolve THEN ;Cond @@ -513,7 +512,7 @@ Cond: DOES> restrict? : 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 ; + :dodoes T A, H gexecute T here H cell - reloff ; : TCreate ( ghost -- ) CreateFlag on @@ -560,16 +559,30 @@ Build: T 0 A, H ; by Create Builder AVariable -Build: T 0 , H ; -by Create +\ User variables 04may94py + +>CROSS +Variable tup 0 tup ! +Variable tudp 0 tudp ! +: u, ( n -- udp ) + tup @ tudp @ + T ! H + tudp @ dup cell+ tudp ! ; +: au, ( n -- udp ) + tup @ tudp @ + T A! H + tudp @ dup cell+ tudp ! ; +>TARGET + +Build: T 0 u, , H ; +DO: ( ghost -- up-addr ) T @ H tup @ + ;DO Builder User +by User :douser resolve -Build: T 0 , 0 , H ; -by Create +Build: T 0 u, , 0 u, drop H ; +by User Builder 2User -Build: T 0 A, H ; -by Create +Build: T 0 au, , H ; +by User Builder AUser Build: ( n -- ) T , H ; @@ -769,6 +782,8 @@ only forth also minimal definitions : decimal decimal ; : hex hex ; +: tudp T tudp H ; +: tup T tup H ; minimal \ for debugging... : order order ;