Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uakari.primate.wisc.edu!dogie.macc.wisc.edu!vms.macc.wisc.edu From: stevens@vms.macc.wisc.edu (PAul STevens -- MACC) Newsgroups: comp.lang.forth Subject: Re: The Minimal Forth Machine Message-ID: <2241@dogie.macc.wisc.edu> Date: 11 Aug 89 14:56:30 GMT Sender: news@dogie.macc.wisc.edu Distribution: na Organization: University of Wisconsin Academic Computing Center Lines: 46 In article <1330@massormetrix.ida.liu.se>, mikpa@massormetrix.ida.liu.se (Mikael Patel) writes... >Hi, Forth Lovers, how about a distributed problem solving session? > >The quest is to find `the minimal Forth Machine'. What is the minimal set >of operations such a machine must implement? > >I have started to attach this problem. My first group of operations to >study is the arithmetric operations, thus the sub-problem is; What is >the minimal set of operation to realize + - * /mod mod /? > >Sofar I need: > not xor > 0> 0< 0= > 1+ 1- > dup swap rot drop > >r r> > if else then > tail-recurse ( compiles a branch to the beginning of the definition) > I don't think you really want a minimal machine. I bet it would amount to no more than 4 words, including IF and THEN. One of the words might be -!, which subtracts a memory location from the top of the stack and puts the result both on the top of the stack and back in the memory location. -! ( 16b addr .. 16b-(addr)) (addr) = 16b-(addr) Let's try one: variable JUNKA ( scratch area for several words ) variable JUNKB ( scratch area ) : DROP ( 16b .. ) JUNKA -! JUNKA -! ( clear junka and stack entry ) JUNKB JUNKA -! ( junka and tos both = address of junkb ) -! JUNKB -! ( clear tos and junkb ) JUNKA -! ( junka=-junkb ) JUNKB -! JUNKB -! ( clear junkb and tos ) JUNKA -! -! ; ( subtract 0 from second entry on stack) ( leaves it unchanged and drops entry ) Could get inefficient! For example, you certainly don't need ROT in your example: : ROT >R SWAP R> SWAP ; In the limit you wind up with something about as efficient as a Turing machine. But very complete.