--- gforth/cross.fs 2002/12/27 17:19:33 1.131 +++ gforth/cross.fs 2003/01/19 23:35:29 1.135 @@ -1,7 +1,7 @@ \ CROSS.FS The Cross-Compiler 06oct92py \ Idea and implementation: Bernd Paysan (py) -\ Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc. +\ Copyright (C) 1995-2003 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -1412,11 +1412,10 @@ T has? rom H \ MakeKernel 22feb99jaw -: makekernel ( targetsize -- ) +: makekernel ( start targetsize -- ) \G convenience word to setup the memory of the target \G used by main.fs of the c-engine based systems - 100 swap dictionary (region) - setup-target ; + dictionary (region) setup-target ; >MINIMAL : makekernel makekernel ; @@ -2270,6 +2269,7 @@ Defer setup-prim-semantics Variable prim# : first-primitive ( n -- ) prim# ! ; +: group 0 word drop prim# @ 1- -$200 and prim# ! ; : Primitive ( -- ) \ name >in @ skip? IF drop EXIT THEN >in ! s" prims" T $has? H 0= @@ -2580,8 +2580,13 @@ Cond: [ ( -- ) interpreting-state ;Cond Defer instant-interpret-does>-hook +T has? peephole H [IF] : does-resolved ( ghost -- ) compile does-exec g>xt T a, H ; +[ELSE] +: does-resolved ( ghost -- ) + g>xt T a, H ; +[THEN] : resolve-does>-part ( -- ) \ resolve words made by builders @@ -2929,17 +2934,23 @@ compile: does-resolved ;compile : >mark ( -- sys ) T here ( dup ." M" hex. ) 0 , H ; -: branchoffset ( src dest -- ) - tchar / ; \ ?? jaw +X has? abranch [IF] + : branchoffset ( src dest -- ) drop ; + : offset, ( n -- ) X A, ; +[ELSE] + : branchoffset ( src dest -- ) - tchar / ; \ ?? jaw + : offset, ( n -- ) X , ; +[THEN] -:noname compile branch X here branchoffset X , ; +:noname compile branch X here branchoffset offset, ; IS branch, ( target-addr -- ) -:noname compile ?branch X here branchoffset X , ; +:noname compile ?branch X here branchoffset offset, ; IS ?branch, ( target-addr -- ) -:noname compile branch T here 0 , H ; +:noname compile branch T here 0 H offset, ; IS branchmark, ( -- branchtoken ) -:noname compile ?branch T here 0 , H ; +:noname compile ?branch T here 0 H offset, ; IS ?branchmark, ( -- branchtoken ) -:noname T here 0 , H ; +:noname T here 0 H offset, ; IS ?domark, ( -- branchtoken ) :noname dup X @ ?struc X here over branchoffset swap X ! ; IS branchtoresolve, ( branchtoken -- ) @@ -3012,7 +3023,7 @@ Cond: ?LEAVE ?leave, ;Cond : loop] ( target-addr -- ) branchto, - dup X here branchoffset X , + dup X here branchoffset offset, tcell - (done) ; : skiploop] ?dup IF branchto, branchtoresolve, THEN ; @@ -3117,55 +3128,6 @@ Cond: LOOP 1 ncontrols? loop, ;Cond Cond: +LOOP 1 ncontrols? +loop, ;Cond Cond: NEXT 1 ncontrols? next, ;Cond -\ Absoulte branches 26sep02jaw - -\ This section defined different semantics for -\ conditionals, using and compiling absolute branches - -X has? abranch [IF] - -Ghost abranch drop -Ghost a?branch drop -Ghost a(?do) drop -Ghost a(do) drop -Ghost a(next) drop -Ghost a(+loop) drop -Ghost a(loop) drop - -:noname compile abranch X a, ; plugin-of branch, - -:noname compile a?branch X a, ; plugin-of ?branch, - -:noname compile abranch T here 0 a, H ; plugin-of branchmark, - -:noname compile a?branch T here 0 a, H ; plugin-of ?branchmark, - -:noname - dup X @ ABORT" CROSS: branch already resolved" - X here swap X a! ; plugin-of branchtoresolve, - -:noname - 0 compile a(?do) ?domark, (leave) - branchtomark, 2 to1 ; plugin-of ?do, - -: aloop] ( target-addr -- ) - branchto, - dup X a, - tcell - (done) ; - -:noname - 1to compile a(loop) aloop] - compile unloop skiploop] ; plugin-of loop, - -:noname - 1to compile a(+loop) aloop] - compile unloop skiploop] ; plugin-of +loop, - -:noname - compile a(next) aloop] compile unloop ; plugin-of next, - -[THEN] - \ String words 23feb93py : ," [char] " parse ht-string, X align ; @@ -3718,7 +3680,6 @@ previous : bye bye ; \ dummy -: group 0 word drop ; \ turnkey direction : H forth ; immediate