[OpenBIOS] powerpc64

Andreas Färber andreas.faerber at web.de
Mon Oct 18 20:53:40 CEST 2010

Am 18.10.2010 um 13:17 schrieb Mark Cave-Ayland:

> 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().

Thanks for the explanation.

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

Yeah, that code looks better; it's being called from main(). From  
where could I call such initialization code for t in internal.c? I  
checked every damn occurrence of "t", it's not used elsewhere. Only  
trampoline[1] seems getting assigned in a few places. An initializer  
function using GCC attribute magic maybe?


More information about the OpenBIOS mailing list