[A92] Re: Forth-92


[Prev][Next][Index][Thread]

[A92] Re: Forth-92




I've found an implementation of Forth on the 68000 (actually, for the 
Macintosh, but it's 68K generation) written by a guy about ten miles from 
me, and I'm going to see if I can sweet-talk some source out of him, if 
only as an example.

One of the problems I'm dealing with is that the dictionary is likely to 
move around in memory quite a bit.  We can't put it at the high end of RAM 
and lock it (the traditional way of fixing addresses without hurting the 
heap block compression routines), because then we can't grow the dictionary 
without manually moving it down in RAM--which changes addresses 
anyway.  The issue here is that most Forth words are identified by their 
code addresses, which we don't want to recalculate--every single one--when 
the dictionary is moved.

The 68K has a 32-bit-address-plus-16-bit-signed-offset addressing mode, the 
name of which I can't remember (it's been ages since I've written 
asm).  This allows one to reference a 64K block around an address, but only 
32K in either direction.  So, my solution is this:
--Obtain the address of the start of the dictionary (using heap handle 
dereferencing).
--Add 32768 (the negative range of a signed word) to it.  (Let's call that D)
--Treat the first cell in the dict as -32768(D), and the last cell (if the 
dictionary is the full 64K) as 32767(D).

This offset address D may not necessarily even be a valid RAM address, 
because the actual RAM available in the TI-whatever is a tiny little sliver 
of the 68000's address space.  The offsets from D into the file would be 
constant, and as long as we don't write any really funky execution 
addresses, we won't be grabbing random bytes from somewhere past the end of 
RAM.

I don't know if this would work like I intend it to, or if it's a good 
idea.  The -other- 68K Forth implementor (creator of Pocket Forth for the 
Mac) imposed a 32K dictionary size limit, as that was the positive offset 
range of the pointers.  Either he didn't think of this rather strange 
solution, or he ruled it out as unwise.

Thoughts?
Cliff Biffle





Follow-Ups: References: