embedded systems developers tools, cross compilers
  Home  |   SwiftX Archive  |   SwiftForth Archive  |

Re: REFILL and SOURCE use in SWIFTX

From: Ron Oliver <ron_at_forth.com>
Date: Mon, 05 Jun 2006 16:05:53 -0400

Kenneth Butterfield wrote:
> Hi all
>
> I have developed some code in SwiftForth that works like a second pass compiler for a database. In the first pass I store data and I have forward cross links only. In the second pass I add the backward links that could not be compiled in the first pass.
>
> I use REFILL and SOURCE to get the next line in the file being interpreted and EVALUATE to interpret the line.
>
> When I try the same trick in SWIFTX the input buffer returned by SOURCE does not contain the next line in the file
>
> My question is whether REFILL or SOURCE are modified someway in SWIFTX (68k version).
> (It may be that the address returned is being interpreted as part of the cross compiler space)
> Is there a way to have the data from SOURCE be used correctly
>
> Thanks in ADVANCE, Ken B

You didn't post enough code to compile your snippet (>ENERGY is
missing,) but your problem most likely has to do with memory access.
The error message

Address 130A7A is not valid for this section type Ac227 1109.2
At line 20 in C:\ForthInc\SwiftX\Src\68K\GN32\L2413ATTENFIX6.F

comes from attempting to access inaccessible target memory at compile
time...in this case, probably from passing a host address to target
memory operators.

Colon definitions in INTERPRETER scope use target memory operators @, !,
etc., not host memory operators. This is the most useful arrangement,
as most INTERPRETER colon definitions are for manipulating the target
image, such as CREATE ... DOES> words. When compiling in INTERPRETER,
you have to use @(H), !(H), etc. or scope modifications such as [+HOST]
... [PREVIOUS] to access host memory.

Interpreting in INTERPRETER doesn't have the same dictionary search
order as compiling in INTERPRETER, so you can't "hand-walk" INTERPRETER
definitions the way you can TARGET ones. But you can hand-walk HOST
definitions just like you'd expect, so if you have a lot of work to do
on the host, it's easiest to get the work done in HOST, and keep the
INTERPRETER interfacing words to a minimum.

An example follows...hope this helps!

\ Begin example code
{ ---------------------------------------------------------------------
Parse input file and compile results to target

HOST VARIABLE #MYBUFFER holds how many bytes are in HOST buffer
MYBUFFER.

!MYBUFFER appends x to MYBUFFER.
Note that memory operators in HOST operate on host memory.

PROCESS-MYFILE processes the input file and loads up MYBUFFER.

COMPILE-MYFILE processes the input file and compiles the result to
the target image.
Notes:
- C, in an INTERPRETER colon definition compiles into the target image
   (CDATA or IDATA, whichever is currently selected.)
- (H) memory operators are required to access host memory from
   INTERPRETER scope.
- This will run on a 16-bit target, but it's the programmer's
   responsibility to assure the host data fits in a 16-bit cell.

MYFILE is the start of the compiled data on the target.
--------------------------------------------------------------------- }

HOST
VARIABLE #MYBUFFER 1024 BUFFER: MYBUFFER

: !MYBUFFER ( x -- ) MYBUFFER #MYBUFFER @ + ! CELL #MYBUFFER +! ;
: PROCESS-MYFILE ( -- ) 0 #MYBUFFER ! ( parse and process here ) ;

INTERPRETER

: COMPILE-MYFILE ( -- ) PROCESS-MYFILE
    #MYBUFFER @(H) 0 ?DO I MYBUFFER @(H) , CELL +LOOP ;

TARGET

CREATE MYFILE COMPILE-MYFILE

\ End example code

-- 
Ron Oliver
Consulting Engineer
FORTH, Inc.
www.forth.com
----------------------------------------------------------------------
swiftx_at_forth.com          The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users.  For product support and bug 
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Jun 05 2006 - 13:06:23 PDT

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:51 PST