Re: DOCOL in ITC Forth Engines (UK Newbie)
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: DOCOL in ITC Forth Engines (UK Newbie)         

Group: comp.lang.forth · Group Profile
Author: coos
Date: Sep 19, 2008 12:52

Op Fri, 19 Sep 2008 00:19:51 -0700 (PDT) schreef MarkWills:
> Hi there,
>
> I'm writing a traditional ITC FORTH implimentation on my favourite
> processor, the very old TMS9900 (RISC, stackless).
>
> I have a question regarding DOCOL.
>
> Should DOCOL follow the 'norm' of having a CFA (code-field address) or
> can it be considered a 'special' routine?
>
> I couldn't get things working until I realised that EXIT needed one,
> and I am starting to think that DOCOL does to.
>
> Previously, my EXIT routine was:
>
> exit dect r5
> mov *r5,r3
> jmp next
>
> However, NEXT expects a CFA, so I changed it to:
>
> exit data exit1
> exit1 dect r5
> mov *r5,r3
> jmp next
>
> (just added a pointer which points one (16 bit) word forward).
>
> I think I have just convinced myself that DOCOL does indeed need a CFA
> header, as it too is called by NEXT. Here's DOCOL:
>
> docol mov r3,*r5+
> inct r7
> mov r7,3
> jmp next
>
> I think it should be:
>
> docol data $+2
> mov r3,*r5+
> inct r7
> mov r7,3
> jmp next
>
> Damn! I actually have it executing a simple FORTH thread too: BEGIN 1+
> 2+ AGAIN ;
>
> Trouble is I had to put a hack in EXIT, and think this may be the
> reason why.
>
What hack, EXIT is a normal word like DUP or 2+. It needs the CFA that
points to its code, i.e. the address following the CFA. Its task is to pop
the Forth instruction pointer from the return stack and use that to give
back control to the word that was executed before the word that contained
EXIT was executing.

As others wrote, DOCOL is not like a normal Forth word, DODOES neither.
Its function is to push the instruction pointer on the return stack and
begin execution the current word. So DOCOL and EXIT are a lot like CALL and
RETURN in other languages.
> I hope you guys don't mind me asking old questions about out of date
> implementations!
>

Some of us are older than you might think ;-)
--
Coos
no comments
diggit! del.icio.us! reddit!