Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!sunic!kth!draken!tut!tp
From: tp@tut.fi (Lassila Timo-Pekka)
Newsgroups: comp.lang.forth
Subject: Re: The Minimal Forth Machine
Message-ID: 
Date: 16 Aug 89 07:40:30 GMT
References: <1330@massormetrix.ida.liu.se>
Sender: News@tut.fi
Organization: Tampere Univ. of Technology, Finland.
Lines: 40
In-reply-to: mikpa@massormetrix.ida.liu.se's message of 11 Aug 89 09:53:01 GMT

In article <1330@massormetrix.ida.liu.se> mikpa@massormetrix.ida.liu.se (Mikael Patel) writes:


> ( Arithmetric operations with a small set of primitives, Mikael Patel, 1989)

> ( Requires: not xor 0> 0< 0= 1+ 1- dup swap rot drop >r r> if else then)
                      ^^          ^^          ^^^
> ( Implements: 0 1 negate abs + - * /mod / mod)

How about ...

: >0 dup <0
  if drop 0
  else =0
    if 0
    else 1
    then
  then ;

: 1- not 1+ not ;

: rot >r swap r> swap ;


> : (*) ( a x y -- z)
>   dup 0>				( Check if there is still more to do)
>   if 1-					( Decrement counter)
>     swap rot over + swap rot		( Add to result and put back in order )
               ^^^^

And you forgot this.

: over >r dup r> swap ;


--
Timo-Pekka Lassila            # Tampere University of Technology 
                              #     /Signal Processing Laboratory
tp@tut.fi                     # PO Box 527, SF-33101 Tampere, Finland
mcvax!tut!tp                  #