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


Groups > comp.lang.forth > #38588

Re: Writing SM/REM and FM/MOD

From "Rod Pemberton" <bork@lllljunkqwer.cpm>
Newsgroups comp.lang.forth
Subject Re: Writing SM/REM and FM/MOD
Date 2015-04-24 21:46 -0400
Organization Aioe.org NNTP Server
Message-ID <op.xxmkjsx8wa0t4m@localhost> (permalink)
References <8a492bc8-9c9e-465b-95e4-7d9b986ff583@googlegroups.com> <5536e913$0$23230$e4fe514c@dreader34.news.xs4all.nl> <2015Apr22.145431@mips.complang.tuwien.ac.at> <5537b544$0$2870$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


On Wed, 22 Apr 2015 10:50:43 -0400, Hans Bezemer
<the.beez.speaks@gmail.com> wrote:

> Anton Ertl wrote:
>
> http://www.complang.tuwien.ac.at/cvsweb/cgi-bin/cvsweb/gforth/Attic/primitives?rev=1.53;content-type=text%2Fplain
>
> As far as double cell stack operations go:
>
> : 2swap rot >r rot r> ;
>
> Is probably more efficient than:
>
> : 2swap >r -rot r> -rot ;
>
> Since most systems define -ROT as "ROT ROT" (gforth doesn't - it's a
> primitive).
>
> Hence,
>
> : 2nip rot drop rot drop ;
>
> Is probably more efficient than:
>
> : 2nip 2swap 2drop ;
>
> And finally, if your PICK or 2SWAP isn't too good, this /may/ be a  
> slightly
> better alternative:
>
> : 2TUCK OVER >R ROT >R ROT OVER R> R> ROT ;
>

Here are some alternate definitions which may be useful
depending on which low-leve words ("primitives") are
available to you.

: 2SWAP 2TUCK 2DROP ;
: 2SWAP 2OVER 2>R 2>R 2DROP 2R> 2R> ;
: 2SWAP ROT >R ROT R> ;
: 2SWAP >R -ROT R> -ROT ;
: 2SWAP >R SWAP R> SWAP >R >R SWAP R> SWAP R> ;

: 2NIP 2SWAP 2DROP ;
: 2NIP 2>R 2DROP 2R> ;
: 2NIP ROT DROP ROT DROP ;
: 2NIP >R -ROT DROP DROP R> ;
: 2NIP >R >R DROP DROP R> R> ;
: 2NIP >R SWAP DROP SWAP DROP R> ;

: 2TUCK 2SWAP 2OVER ;
: 2TUCK 2DUP 2>R 2SWAP 2R> ;
: 2TUCK DUP >R OVER >R ROT >R ROT R> R> R> ;
: 2TUCK OVER >R >R -ROT R@ -ROT R> R> SWAP ;

: 2OVER 2SWAP 2TUCK ;
: 2OVER 2>R 2DUP 2R> 2SWAP ;
: 2OVER >R >R OVER OVER R> R> ROT >R ROT R> ;
: 2OVER >R >R OVER OVER R> -ROT R> -ROT ;

: 2ROT 2>R 2SWAP 2R> 2SWAP ;

I was hoping to obtain a definition for 2TUCK or 2OVER without
ROT or -ROT for my own use, but the solver was taking way, way
too long ...  So, the best I could do was two ROTs, for now.


Rod Pemberton

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


Thread

Writing SM/REM and FM/MOD Julian Fondren <julian.fondren@gmail.com> - 2015-04-21 13:23 -0700
  Writing SM/REM and FM/MOD Mark Wills <markwills1970@gmail.com> - 2015-04-21 13:45 -0700
    Writing SM/REM and FM/MOD Mark Wills <markwills1970@gmail.com> - 2015-04-21 13:54 -0700
    Re: Writing SM/REM and FM/MOD Hans Bezemer <the.beez.speaks@gmail.com> - 2015-04-22 11:49 +0200
      Re: Writing SM/REM and FM/MOD Lars Brinkhoff <lars.spam@nocrew.org> - 2015-04-22 12:09 +0200
        Re: Writing SM/REM and FM/MOD anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-22 10:37 +0000
          Re: Writing SM/REM and FM/MOD Michael Barry <barrym95838@yahoo.com> - 2015-04-22 08:19 -0700
        Re: Writing SM/REM and FM/MOD Hans Bezemer <the.beez.speaks@gmail.com> - 2015-04-22 13:25 +0200
          Re: Writing SM/REM and FM/MOD Lars Brinkhoff <lars.spam@nocrew.org> - 2015-04-22 14:42 +0200
    Re: Writing SM/REM and FM/MOD foxaudioresearch@gmail.com - 2015-04-28 06:44 -0700
      Re: Writing SM/REM and FM/MOD Mark Wills <markwills1970@gmail.com> - 2015-04-28 07:27 -0700
  Re: Writing SM/REM and FM/MOD stephen@mpeforth.com (Stephen Pelc) - 2015-04-21 21:44 +0000
  Re: Writing SM/REM and FM/MOD "Rod Pemberton" <bork@lllljunkqwer.cpm> - 2015-04-21 18:32 -0400
    Re: Writing SM/REM and FM/MOD Julian Fondren <julian.fondren@gmail.com> - 2015-04-21 16:28 -0700
      Re: Writing SM/REM and FM/MOD "David N. Williams" <williams@umich.edu> - 2015-04-21 23:05 -0400
        Re: Writing SM/REM and FM/MOD "David N. Williams" <williams@umich.edu> - 2015-04-21 23:07 -0400
      Re: Writing SM/REM and FM/MOD krishna.myneni@ccreweb.org - 2015-04-22 18:15 -0700
  Re: Writing SM/REM and FM/MOD albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-22 00:19 +0000
    Re: Writing SM/REM and FM/MOD anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-22 12:54 +0000
      Re: Writing SM/REM and FM/MOD Hans Bezemer <the.beez.speaks@gmail.com> - 2015-04-22 16:50 +0200
        Re: Writing SM/REM and FM/MOD anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-22 15:29 +0000
        Re: Writing SM/REM and FM/MOD "Rod Pemberton" <bork@lllljunkqwer.cpm> - 2015-04-24 21:46 -0400
          Re: Writing SM/REM and FM/MOD Michael Barry <barrym95838@yahoo.com> - 2015-04-27 22:08 -0700
            Re: Writing SM/REM and FM/MOD "Rod Pemberton" <bork@lllljunkqwer.cpm> - 2015-04-28 03:24 -0400
    Re: Writing SM/REM and FM/MOD Julian Fondren <ayrnieu@gmail.com> - 2015-05-11 16:38 -0700
      Re: Writing SM/REM and FM/MOD albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-05-12 00:24 +0000
      Re: Writing SM/REM and FM/MOD anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-05-12 13:58 +0000
  Re: Writing SM/REM and FM/MOD anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-22 13:43 +0000

csiph-web