Fairchild SYMBOL

Jim Battle frustum at pacbell.net
Thu Jan 1 16:23:38 CST 2009


bfranchuk at jetnet.ab.ca wrote:
> bfranchuk at jetnet.ab.ca wrote:
>> Dave McGuire wrote:
>>
>>>   Nono, think of the architectural research that this would 
>>> facilitate!  Aside from just being fun, one could do some seriously 
>>> interesting architectural work with something like this.
>>
>> Um how do you do recusion?

like anyone else -- with RAM and a pointer.  the parser could be as simple as looking at 
one byte of input text per clock, or it could perhaps have a window of the next, say, 8 
bytes looking forward in the stream, and decode entire tokens in a single clock.

if the parsing logic hit "A - (B - C)", the state machine would

    look up "A" in the symbol table and retrieve its value (or hold an index to it) and 
place it on a value stack

    the "-" operator would be pushed on an operator stack

    "(" is pushed on the operator stack

    the "B" would be looked up, and saved on the value stack

    the "-" would be looked up, and since it has higher precedence than the top of the 
operator stack [which is "("], "-" would be pushed on the operator stack too.

    the "C" would be looked up and saved on the value stack

    the ")" is lower precedence than "-", so "-" is popped off the operator stack, and 
since it is dyadic, the B and C values would be popped off the value stack and operated 
on.  the ")" is checked against the top of the operator stack; we find the "(" and pop it. 
  if we found another operator instead, say unary "-", that would have been processed 
first.  the operator stack is still non-empty, as "-" is found, so it is popped.  since it 
is dyadic, the "B-C" value is popped and "A" value is popped and operated on.  the 
operator stack is empty, and the expression is complete.

a dirt simple state machine can carry that out; a smarter one delays pushing results in 
hopes that the next step needs the just computed result anyway.  error processing would 
complicate things to know how far to rewind the stack.  one could opt to have dedicated 
operator/value stacks, but then there would be a hard limit for the depth of expression 
nesting.  This is manageable for Dartmouth BASIC, but more of a problem for a language 
with scoping.

the best solution is to logically have the stacks in main memory, but to cache the top N 
entries from each FIFO.


More information about the cctech mailing list