Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!ucbvax!CGEUGE54.BITNET!BARTHO From: BARTHO@CGEUGE54.BITNET ("PAUL BARTHOLDI, OBSERVATOIRE DE GENEVE") Newsgroups: comp.lang.forth Subject: RE" How do I do this in forth ? (-> stacks) Message-ID: <16D0A3308E9F001B3C@cgeuge54.bitnet> Date: 22 Oct 90 13:05:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 126 Hi, > Intereseting you should mention this. I'm doing exactly the same > thing with an othello playing program. I haven't gotten very far, as > I only last week found a un*x forth to run. The way I think I'll > handle it is to define a seperate stack for alpha, beta, depth. > Set it up analogously to the return stack, ie: define words like > alpha-pop, alpha-push, alpha@ <==> r>, >r, r@ > May I suggest an other syntax, both to define and use extra stacks: STACK and INTO pushes the value on the named stack ... pop the top of the named stack onto the normal stack ... RESET clear the named stack Here is my old version on my HP1000-F, with some comments added. 0 VARIABLE %%VAR \ this is controled by INTO and RESET \ and used by stacks objects as message \ %%VAR is reset to 0 each time a stack is used \ %%VAR is set to 1 by INTO \ %%VAR is set to 2 by RESET NB If you use often the top of stack, without willing to remove it, just add a third command like TOS: \ %%VAR is set to 3 by TOS 1 %%VAR SET INTO 2 %%VAR SET RESET \ 3 %%VAR SET TOS \ the following two lines are error message used by the assembler bellow. ORC5 & . WORD, Special stack underflow . FORTH ORC6 & . WORD, Special stack overflow . FORTH \ Now the definition of STACK, using HP1000 assembler ... sorry for that \ it should not be that difficult to understand and port to another cpu. \ the B register points initially to the cfa, INB, then make it to the pfa \ Note that the HP1000 is a 16 bits WORD addressing machine. +--------------------+ + Header(name) + +--------------------+ + lfa + +--------------------+ + cfa + +--------------------+ + stack pointer +-----+ +--------------------+ | ^ + + | | +--------------------+ | | + + | | +--------------------+ | | + + | stack size | +--------------------+ | | + + | | +--------------------+ | | + top of stack +<----+ | +--------------------+ : v + ... + : +--------------------+ : <----+ (initially) : STACK