Re: [stack] Concatenative Hardware Redux (Another 16 Instruction Set)

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
You missed the ADD instruction.

Seriously, though, I do suspect that Chuck Moore has it right on this
one... Use instruction slots in a larger word size, and allow some of
the slots to encode alternate instructions. In the SeaForth, you have
an 18-bit word size with 3 5-bit instructions plus a trailing 3-bit
instruction... The trailing instruction is very useful for the uLOOP
instruction, which can only go there and which performs a 'decrement
and loop if not zero' without a destination (which means it'll repeat
the preceding words in the instruction).You might want a trailing
_and_ a preceding slot; the preceding slot could be for literals and
targetted jumps (so that the instruction and the literal fit in the
same instruction slot).

And so on.

-Wm

On Jan 11, 2008 12:45 AM, Daniel Ehrenberg <[email protected]> wrote:
> Don't you think basic arithmetical operators would be useful, if this
> might eventually be actual and not theoretical hardware? If you only
> have and, shift and xor, maybe it's *possible* to implement arithmetic
> (I personally don't know how) but it wouldn't be as efficient. There's
> no real point in restricting yourself to 16 operations, especially
> when some of these operations will encode a literal and some of them
> won't.
>
> Dan
>
>
> On Jan 10, 2008 2:12 PM, Christopher Diggins <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> > Hi all,
> >
> >  Here is my most recent 16 instruction set for concatenative hardware.
> >  Any comments would be greatly appreciated.
> >
> >  /*
> >  * Released into the public domain by Christopher Diggins
> >  * Contact me if you have special licensing requirements
> >  * http://www.cdiggins.com
> >  */
> >
> >  enum
> >  {
> >  /* Push a literal value from the instruction stream */
> >  LIT = 0, /* -> a */
> >
> >  /* Add top two values on the stack */
> >  ADD = 1, /* a b -> (a + b) */
> >
> >  /* Shift second value on the stack left or right */
> >  SHIFT = 2, /* a b -> b < 32 ? (a >> b) : (a << (b - 32)) */
> >
> >  /* Perform exclusive or of top two values */
> >  XOR = 3, /* a b -> (a ^ b) */
> >
> >  /* Perfrom bitwise and of top two values */
> >  AND = 4, /* a b -> (a & b) */
> >
> >  /* Dynamic function/list construction */
> >  /* Note: lists and functions are identical from a programmer's perspective,
> >  a list is the result of a function that consumes nothing. Think of it
> >  as a new stack yielded by executing the function, except that it is
> >  lazy (evaluated at last minute) */
> >  PAPPLY = 5, /* a [X] -> [a X] */
> >  COMPOSE = 6, /* [X] [Y] -> [X Y] */
> >
> >  /* Branching and calling */
> >  APPLYIF = 7, /* bool [X] -> X or NOOP */
> >
> >  /* Reference creation and manipulation, used for playing with heap */
> >  MAKEREF = 8, /* a -> &a */
> >  GETREF = 9, /* &a -> a */
> >  SETREF = 10, /* &a b -> &(*a = b) */
> >
> >  /* Stack manipulation operations */
> >  FLIP = 11, /* a X b n:int -> b X a ; sizeof(X) == n */
> >  GETN = 12, /* a X n:int -> (a X, a) ; sizeof(X) == n */
> >  SETN = 13, /* (a X n:int, b) -> b X ; sizeof(X) == n */
> >
> >  /* Applies a function to a list */
> >  APPPLYTO = 14, /* [->X] [X->Y] => [Y] */
> >
> >  /* Make a suggestion ( I was thinking of COUNT, but I
> >  am not so sure ) */
> >  UNUSED = 15
> >  }
> >  opcodes;
> >
> >  /*
> >  Some examples of derived opcodes:
> >
> >  SWAP = 0 FLIPN
> >  DUP = 0 GETN
> >  POPD = 0 SETN
> >  POP = SWAP POPD
> >  QUOTE = [] CONS
> >  APPLY = TRUE SWAP APPLYIF
> >  CONS = SWAP QUOTE PAPPLY
> >  UNCONS = APPLY SWAP
> >  DIP = SWAP QUOTE COMPOSE APPLY
> >  */
> >
> >  Christopher Diggins
> >  http://www.cat-language.com
> >
>
>
>
> Yahoo! Groups Links
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.