home .. forth .. colorforth mail list archive ..

Re: [colorforth] How is colorForth different from other Forths?


----- Original Message ----- 
From: "Samuel A. Falvo II" <kc5tja@xxxxxxxx>
To: <colorforth@xxxxxxxxxxxxxxxxxx>
Sent: Thursday, December 18, 2003 8:07 AM
Subject: Re: [colorforth] How is colorForth different from other Forths?


> On Thursday 18 December 2003 06:51 am, John Drake wrote:
> > Looking at the wordlist link that Mark provided I
> > see two words that might handle this.  The words
> > are:
> >
> >  "mark" - Record current dictionary pointers
mark  saves the macro forth and h  pointers  overwriting previous values.
> > and
> >  "empty" - Record current dictionary pointers
>
> These words won't even help.  To implement temporary buffers, it's best
> to use definitions like this:
>
> : buf1 here ;
> : buf2 here 4096 + ;
> : buf3 here 6144 + ;
>
> and so on.  The only problem with this is that you cannot pre-allocate
> the temporary buffers, so that you can dynamically build another buffer
> thereafter.  The first time you use , or a related word, the value of
> 'here' changes, and consequently, buf1..buf3 will return different
> values.
>
> ALLOT is necessary if you're looking to establish multiple buffers.  I
> use ALLOT extensively in the implementation of FS/Forth's target
> compiler, and I don't think it's easily implementable any other way.
> For example, because I build my program's ELF headers using , and C,
> words, and because I build the string table for the ELF executable
> dynamically, I must pre-allocate and ensure a unique address for the
> string table, so that subsequent execution of the ELF header words won't
> change the address of the string table (effectively corrupting it in the
> process, as the contents of the buffer don't move with it!).
>
> Assuming H is the variable used to hold the current HERE pointer, then:
>
> VARIABLE H
> : here H @ ;
> : allot h +! ;
> : , here ! 4 allot ;
> : 2, here ! 2 allot ;  ( little-endian CPUs only )
> : 1, here c! 1 allot ;
>
> As can be seen, implementing ALLOT isn't hard.  Frankly, ALLOT itself
> really isn't necessary if H is exposed to the programmer directly (which
> I don't recall if it is or isn't in ColorForth).
>
colorForth H  is not in eather wordlist. H is hidden.
> --
> Samuel A. Falvo II
>
>
 For buffers and other needed  variable data,
I  would put a verible at the start of an empty block and use variable as
alocation pointer.
variable z
On source block  name fields in red, allot z space with yellow words, green
words for use of field.
: aname   [   z @ dup  4 + z ! ]  ( a- ) ;
and in empty  put  z  2 + z !  to reset pointer  because the field names
will be discarded by empt .
  The 2 + steps past the null that is needed by load to exit block and not
try to load my data.
On 18 block before mark empty
load the block with the variable
Robert

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
> Main web page - http://www.colorforth.com


---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com