[OpenBIOS] powerpc64

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Mon Oct 18 13:17:14 CEST 2010

Andreas Färber wrote:

> Corresponding code is:
> #ifndef FCOMPILER
> /* instead of pointing to an explicit 0 variable we
>  * point behind the pointer.
>  */
> static ucell t[] = { DOCOL, 0, (ucell)(t+3), 0 };
> static ucell *trampoline = t;
> #endif
> The warning goes away if I cast to (unsigned long) first, but the 
> initialization error remains. In powerpc-elf-gcc 4.4+ this didn't surface.
> Suggestions how to fix?
> Andreas

Right. So this code is to ensure that any arbitrarily executed Forth is 
always executed as part of a word (i.e. execution will always return to 
the previous point).

In order to do this, the trampoline is a synthetic word used to setup a 
Forth word like this:

DOCOL <xt of code/word> <xt of ;>

which is roughly equivalent to:

: trampoline <name of word> ;

Now the xt of ; is unknown until runtime due to dictionary relocation, 
but in fact ; is just a CFA of 0. Since an xt is a pointer to a Forth 
word, then <xt of ;> is done sneakily by pointing to an address 
containing 0 which is the CFA of semis().

Note there is a less sneaky version of this in the code already - see 
init_trampoline() in bootstrap.c.



Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs

More information about the OpenBIOS mailing list