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


Groups > comp.lang.forth > #59930

pforth return stack strangeness

From admin@simple.gopher
Newsgroups comp.lang.forth
Subject pforth return stack strangeness
Date 2017-05-27 17:03 +0000
Organization Aioe.org NNTP Server
Message-ID <ogcbht$10da$1@gioia.aioe.org> (permalink)

Show all headers | View raw


Maybe there are some pforth users here..

QUADRATIC example from page 112 in Starting Forth book:
% pforth
  / compute a * X^2 + b * X + c
  : QUAD ( a b c X -- n) >R SWAP ROT I * + R> * + ;    ok
  2 7 9 3 QUAD . ==> 30 ok

The answer should be 48.  TRACE suggests stuff is getting drop/corrupted:

  2 7 9 3 TRACE QUAD .
  << QUAD +0      <10:4> 2 7 9 3           ||  >R                  >> 3    ok
  s
  << QUAD +4      <10:2> 2 7               ||  SWAP                >>    ok
  s
  << QUAD +8      <10:2> 7 2               ||  ROT                 >>    ok
  s
  << QUAD +12     <10:2> 2 0               ||  I                   >>    ok
  s
  << QUAD +16     <10:3> 2 0 1515870810    ||  *                   >>    ok
  s
  << QUAD +20     <10:2> 2 0               ||  +                   >>    ok
  s
  << QUAD +24     <10:1> 2                 ||  R>                  >>    ok
  s
  << QUAD +28     <10:2> 2 9               ||  *                   >>    ok
  s
  << QUAD +32     <10:1> 18                ||  +                   >>    ok
  s
  << QUAD +36     <10:0>                   ||  EXIT                >>    ok
  s Finished.
     ok

For reference, same thing in gforth:
  % gforth -e ": quad >r swap rot i * + r> * + ; 2 7 9 3 quad . bye"
  48

pforth documentation doesn't suggest limited return stack functionality; not
sure why it doesn't work..

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


Thread

pforth return stack strangeness admin@simple.gopher - 2017-05-27 17:03 +0000
  Re: pforth return stack strangeness Julian Fondren <julian.fondren@gmail.com> - 2017-05-27 10:22 -0700
    Re: pforth return stack strangeness admin@simple.gopher - 2017-05-27 19:15 +0000
      Re: pforth return stack strangeness Julian Fondren <julian.fondren@gmail.com> - 2017-05-27 12:37 -0700
  Re: pforth return stack strangeness Roelf Toxopeus <rt4all@nothishetnet.nl> - 2017-05-27 21:10 +0200

csiph-web