On Tue, 16 Jan 2018 00:07:54 -0800 (PST)
Manuel Rodriguez <
a...@gmx.net> wrote:
> I'm sure, the following question is completely ontopic, because it
> has to do with compiler construction.
(You'd be wrong, but whatever ...)
> Or to be more specific, of how
> to translate one program into another program.
Usenet groups comp.compilers or comp.lang.misc would be your best bet
after Google searches.
> The starting point is
> a turing-machine, which is used in the Busy Beaver game. I'm linking
> to the German Wikipedia
> [link]
I'm not looking at that.
> because
> they have not only the busy-beaver itself in their article, but also
> a visualization state-machine. The diagram shows, that the machine
> can have different states, which are changed on demand. The
> interesting aspect of a state-machine is, that it is not a computer,
> and not a Forth virtual machine. It is something, which is one level
> deeper.
I don't know what you mean by that, as FSMs are usually coded in a
high-level language, like Forth or C, so they cannot be "one-level
deeper".
> It is called Microcode, because it is so low level, that no
> stack or registers are existing.
Microcode
https://en.wikipedia.org/wiki/Microcode
As for FSMs, Julian V. Noble (RIP) coded a bunch of FSM in Forth.
Someone else (Jeff Fox?) posted a link to his paper. I also ported one
of his FSMs to C, years ago, posted to comp.lang.c, which may be easier
to understand:
https://groups.google.com/d/msg/comp.lang.c/WjqgM4p0LrU/XA-YJvYsqS8J
> In theory, it is possible to program a state-machine for every
> purpose, for example to print out many One's or solving a factorial
> problem.
Yes, but unless you have a tool (compiler-compiler, BNF parser, etc) to
construct the FSM from a grammar, FSMs difficult to program and
maintain, for anything more than simple tasks. Grammars are human
readable and editable. Of course, if you have a grammar as the
front-end and an FSM as the back-end, you don't need Forth.
> But, what we want is to construct on top something which is
> more useful. An easy to program computer, a stackmachine.
In my opinion, the easiest way to program a computer is using an
integer array, not a stack. The easiest way to program an array is by
using an array-based programming language, like Brainfuck. Compilers
for a few higher level languages (BASIC, assembly, etc) have been
produced for Brainfuck. However, Brainfuck is very primitive. You
might wish to select another language. Unfortunately, if you want your
code to be portable, you're restricted to C and Forth, as they're the
most widely implemented.
> I believe, that everybody here in the newsgroup knows, what a
> stackmachine is,
Ok.
> it is more useful than a statemachine,
Speculative.
> because it can be programmed in Forth.
A state machine can be programmed in Forth too, as you also stated. So,
I don't know what you intended to say here.
> And here is my question:
So, you do have one of those.
> How to transform a forth-like stackmachine into a
> low-level-state-machine? So we have as input a Forth program and as
> output a state-machine.
That's a good question. I've not done that. I'd direct you to post to
comp.compilers.
Rod Pemberton
--
"White Privilege - The privilege of being called 'racist' by people who
see nothing else about you except your race." - Internet meme