Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #47187

Re: Looking for some help with this gforth program. Thanks!

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Looking for some help with this gforth program. Thanks!
Date 2016-05-16 12:21 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2016May16.142145@mips.complang.tuwien.ac.at> (permalink)
References (7 earlier) <nh6a4i$d8s$1@dont-email.me> <bc9fdf8d-b53e-467f-9c35-4730dbd6bf39@googlegroups.com> <nh8skf$83l$2@dont-email.me> <2016May15.123405@mips.complang.tuwien.ac.at> <nh9u7g$cl1$1@dont-email.me>

Show all headers | View raw


rickman <gnuarm@gmail.com> writes:
>I'm a bit surprised to hear anyone say implementing Forth on an x86 is 
>anything but easy... well as easy as it would be on any CPU including 
>stack machines.  The primary difference between a stack machine and the 
>x86 is the lack of flexibility in the stack machine.  An x86 processor 
>can do all the stack manipulations the stack machine can do as well as 
>any manner of optimizations made possible by the register set and hugely 
>flexible addressing modes.

If you implement Forth the easy way (like, e.g., Machine Forth), you
lose quite a bit of performance: Machine Forth keeps the TOS in the
register and the rest of the stack in memory.  If you do something
like "5 +", the "5" stores the old TOS to memory, and the "+" loads it
back from memory.  This costs 5-6 cycles of latency on one of the
higher-performance Intel CPUs of the last few years.

A stack machine would avoid that problem, and, if implemented with
comparable technology as the Intel CPUs, would be quite a bit faster
on this kind of code.  Alternatively, one can have a more
sophisticated compiler that keeps stack items in register and avoids
this kind of problem.  In that case the stack machine has no
performance advantage; a stack machine with in-order execution would
be much simpler, but would not benefit from superscalar execution
enabled by out-of-order execution, so I guess the Intel CPU would be
faster, although at a huge cost in CPU complexity.

>When I designed my stack machine I gave it some features that were 
>actually more efficient than the Forth virtual machine such as use of 
>the return stack to hold and manipulate addresses separate from data. 
>So maybe it is the Forth VM itself that limits efficiency.

There are some things, like implementing MOVE, where classic Forth is
not particularly good.  The classic answer is that these are the kinds
of things classically written in assembly language.  Of course, if the
assembly language of the CPU is Forth, that answer does not help, so
Charles Moore and others have added a few address registers: IIRC one
variant has A (a separate register) and R (the top of return stack); I
dimly remember that another address register B also occured in the
discussions.

That's certainly a good answer to the implementing-MOVE problem.  When
that came up, some people also wondered whether we should not add A
etc. to Forth as a programming language.  That discussion seems to
have died down without anyone (but Charles Moore) adding A to their
Forth system.  I guess some are happy with the drop-to-assembly
solution, and others use locals or other solutions when there are too
many values used in the inner loop than fit comfortably on the stack.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2016: http://www.euroforth.org/ef16/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 13:54 -0700
  Re: Looking for some help with this gforth program. Thanks! all2001@spambog.com (Wolfgang Allinger) - 2016-05-11 17:59 -0300
    Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-11 19:16 -0700
      Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 19:40 -0700
        Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-11 23:22 -0700
          Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-12 00:01 -0700
            Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-12 00:08 -0700
              Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-12 12:09 -0700
            Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-12 20:48 -0400
              Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-12 18:04 -0700
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-12 21:21 -0400
                Re: Looking for some help with this gforth program. Thanks! Cecil Bayona <cbayona@cbayona.com> - 2016-05-12 20:27 -0500
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-12 18:46 -0700
                Re: Looking for some help with this gforth program. Thanks! Cecil Bayona <cbayona@cbayona.com> - 2016-05-12 23:28 -0500
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-13 00:52 -0700
                Re: Looking for some help with this gforth program. Thanks! Pablo Hugo Reda <pabloreda@gmail.com> - 2016-05-13 04:07 -0700
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-14 00:42 -0400
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-14 00:05 -0700
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-15 00:10 -0400
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-15 10:34 +0000
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-15 09:43 -0400
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-16 12:21 +0000
                Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-16 07:38 -0700
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-16 14:56 +0000
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-16 12:07 -0400
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-16 09:18 -0700
                Re: Looking for some help with this gforth program. Thanks! Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-05-16 13:19 -0500
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-17 12:39 +0000
                Re: Looking for some help with this gforth program. Thanks! Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-05-17 10:34 -0500
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-17 15:54 +0000
                Re: Looking for some help with this gforth program. Thanks! mhx@iae.nl - 2016-05-17 12:44 -0700
                Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-15 11:03 -0700
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-15 21:56 -0400
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-15 19:02 -0700
                Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-15 20:03 -0700
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-16 02:13 -0400
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-16 00:37 -0700
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-16 13:41 +0000
                Re: Looking for some help with this gforth program. Thanks! Bernd Paysan <bernd.paysan@gmx.de> - 2016-05-16 21:42 +0000
                Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-16 16:23 -0700
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-16 16:41 -0700
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-16 20:32 -0700
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-16 20:47 -0700
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-17 06:32 +0000
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-17 07:56 -0700
                Re: Looking for some help with this gforth program. Thanks! Bernd Paysan <bernd.paysan@gmx.de> - 2016-05-17 23:05 +0000
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-17 21:16 -0700
                Re: Looking for some help with this gforth program. Thanks! Bernd Paysan <bernd.paysan@gmx.de> - 2016-06-04 22:44 +0000
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-17 13:42 +0000
                Re: Looking for some help with this gforth program. Thanks! Bernd Paysan <bernd.paysan@gmx.de> - 2016-05-17 22:31 +0000
                Re: Looking for some help with this gforth program. Thanks! anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-18 16:43 +0000
                Re: Looking for some help with this gforth program. Thanks! Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-05-16 10:38 -0500
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-16 10:10 -0700
                Re: Looking for some help with this gforth program. Thanks! Cecil Bayona <cbayona@cbayona.com> - 2016-05-16 12:29 -0500
                Re: Looking for some help with this gforth program. Thanks! Cecil Bayona <cbayona@cbayona.com> - 2016-05-16 12:34 -0500
                Re: Looking for some help with this gforth program. Thanks! Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-05-16 13:27 -0500
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-17 16:11 -0700
                Re: Looking for some help with this gforth program. Thanks! Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-05-18 04:31 -0500
                Re: Looking for some help with this gforth program. Thanks! Albert van der Horst <albert@cherry.spenarnc.xs4all.nl> - 2016-05-16 18:46 +0000
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-14 00:07 -0700
                Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-14 00:20 -0700
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-14 01:23 -0700
                Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-15 00:13 -0400
                Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-14 21:55 -0700
  Re: Looking for some help with this gforth program. Thanks! Paul Rubin <no.email@nospam.invalid> - 2016-05-11 17:08 -0700
    Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 17:40 -0700
      Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 18:54 -0700
        Re: Looking for some help with this gforth program. Thanks! Doug Hoffman <glidedog@gmail.com> - 2016-05-13 06:55 -0400
          Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-13 11:07 -0700
          Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-13 20:42 -0700
            Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-13 20:57 -0700
            Re: Looking for some help with this gforth program. Thanks! Doug Hoffman <glidedog@gmail.com> - 2016-05-14 05:54 -0400
              Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-14 15:20 -0700
                Re: Looking for some help with this gforth program. Thanks! Doug Hoffman <glidedog@gmail.com> - 2016-05-15 05:45 -0400
                Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-15 11:21 -0700
                Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-15 11:39 -0700
    Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-11 20:45 -0700
      Re: Looking for some help with this gforth program. Thanks! hughaguilar96@gmail.com - 2016-05-11 23:05 -0700
        Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 23:15 -0700
          Re: Looking for some help with this gforth program. Thanks! rickman <gnuarm@gmail.com> - 2016-05-12 22:34 -0400
      Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 23:11 -0700
  Re: Looking for some help with this gforth program. Thanks! november.nihal@gmail.com - 2016-05-11 19:00 -0700
    Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-11 19:14 -0700
  Re: Looking for some help with this gforth program. Thanks! humptydumpty <ouatubi@gmail.com> - 2016-05-12 01:48 -0700
    Re: Looking for some help with this gforth program. Thanks! Doug Hoffman <glidedog@gmail.com> - 2016-05-12 07:43 -0400
      Re: Looking for some help with this gforth program. Thanks! humptydumpty <ouatubi@gmail.com> - 2016-05-12 10:21 -0700
    Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-12 12:11 -0700
  Re: Looking for some help with this gforth program. Thanks! "Ala'a" <amalawi@gmail.com> - 2016-05-12 14:34 -0700
    Re: Looking for some help with this gforth program. Thanks! murphy.darin@gmail.com - 2016-05-12 16:20 -0700
  Re: Looking for some help with this gforth program. Thanks! Marcos Cruz <use_the_contact_page@programandala.net> - 2016-05-14 12:27 +0000
  Re: Looking for some help with this gforth program. Thanks! "WJ" <w_a_x_man@yahoo.com> - 2016-05-16 05:35 +0000

csiph-web