DUP >R 
Author Message
 DUP >R

Coos Haak mentioned:

Quote:
> R> DROP  and its complement DUP >R

What is the best name for DUP >R ?
Did anybody measure how often it is used?

I know of the following names for ( x -- x ) ( R: -- x ) :

DUP>R        -- 2DUP>R is difficult to distinguish from 2DUP >R
        when the code is pronounced, and 2DUP2>R is even
        uglier than 2R>2DROP.


COPY>R       -- maybe not the best name, but 2COPY>R is no problem
        because there is no COPY in Forth. OTOH, uses one more
        natural language word for the programming language purposes.

Any better suggestions?
("leave it in two words")

--
do not do that -- universal advice



Sat, 05 Jul 2003 13:37:33 GMT  
 DUP >R

Quote:

> Coos Haak mentioned:
> > R> DROP  and its complement DUP >R

> What is the best name for DUP >R ?
> Did anybody measure how often it is used?

> I know of the following names for ( x -- x ) ( R: -- x ) :

> DUP>R -- 2DUP>R is difficult to distinguish from 2DUP >R
> when the code is pronounced, and 2DUP2>R is even
> uglier than 2R>2DROP.



> COPY>R -- maybe not the best name, but 2COPY>R is no problem
> because there is no COPY in Forth. OTOH, uses one more
> natural language word for the programming language purposes.

> Any better suggestions?
> ("leave it in two words")



--

-GJC



Sat, 05 Jul 2003 14:14:21 GMT  
 DUP >R

Quote:

> Coos Haak mentioned:
> > R> DROP  and its complement DUP >R

> What is the best name for DUP >R ?
> Did anybody measure how often it is used?

> I know of the following names for ( x -- x ) ( R: -- x ) :

> DUP>R   -- 2DUP>R is difficult to distinguish from 2DUP >R
>         when the code is pronounced, and 2DUP2>R is even
>         uglier than 2R>2DROP.



> COPY>R  -- maybe not the best name, but 2COPY>R is no problem
>         because there is no COPY in Forth. OTOH, uses one more
>         natural language word for the programming language purposes.

> Any better suggestions?
> ("leave it in two words")

> --
> do not do that -- universal advice

I use R!

Jerry
--
Engineering is the art of making what you want from things you can get.
-----------------------------------------------------------------------



Sat, 05 Jul 2003 23:36:02 GMT  
 DUP >R

Quote:


> > ... names for ( x -- x ) ( R: -- x ) :

> I use R!

For me, R! is ( x -- ) ( R: y -- x ),



Sun, 06 Jul 2003 03:12:00 GMT  
 DUP >R


Quote:


>> > ... names for ( x -- x ) ( R: -- x ) :

>> I use R!

>For me, R! is ( x -- ) ( R: y -- x ),


For me too, and r! is a synonym of r0! to be consistent with r1! r2!
etc.  One cycle, 10ns.


stack is not unnecessarily temporarily enlarged.  This *could* cause an
on-chip stack spill to memory (yawn) in some architectures - a very
marginal improvement but worth making a habit of.

Cheers
--
Keith Wootten



Sun, 06 Jul 2003 05:35:55 GMT  
 DUP >R
Performance relies on the compiler. This is benchmarked with bigFORTH on
a 233MHz-Pentium-MMX.

Of course this may very with other processors, because the original
Pentium is sensitive to the order/pairing of the instructions.

\ increment byte in memory



VARIABLE foo

: T1  ( -- )  0 foo C!  100000000 FOR 1 foo C+!-1 NEXT ;
: T2  ( -- )  0 foo C!  100000000 FOR 1 foo C+!-2 NEXT ;
: T3  ( -- )  0 foo C!  100000000 FOR 1 foo C+!-3 NEXT ;

VERSION 1: 18 instructions / 12.7 sec --> 29.6 clocks
disw c+!-1  Adresse : 1074949776
40126E90: xchg    ESP,ESI           87F4
40126E92: push    EAX               50
40126E93: movzx   EAX,BYTE PTR [EAX]
                                    0FB600
40126E96: pop     ECX               59
40126E97: pop     EDX               5A
40126E98: push    ECX               51
40126E99: push    EAX               50
40126E9A: mov     EAX,EDX           8BC2
40126E9C: pop     EDX               5A
40126E9D: add     EAX,EDX           03C2
40126E9F: pop     EDX               5A
40126EA0: push    EAX               50
40126EA1: mov     EAX,EDX           8BC2
40126EA3: pop     EDX               5A
40126EA4: mov     [EAX],DL          8810
40126EA6: pop     EAX               58
40126EA7: xchg    ESP,ESI           87F4
40126EA9: ret                       C3

VERSION 2: 16 instructions / 13.5 sec --> 31.5 clocks
disw c+!-2  Adresse : 1074949816
40126EB8: xchg    ESP,ESI           87F4
40126EBA: push    EAX               50
40126EBB: mov     -$04[ESI],EAX     8946FC
40126EBE: sub     ESI,$04           83EE04
40126EC1: pop     EAX               58
40126EC2: movzx   EAX,BYTE PTR [EAX]
                                    0FB600
40126EC5: pop     EDX               5A
40126EC6: add     EAX,EDX           03C2
40126EC8: push    EAX               50
40126EC9: mov     EAX,[ESI]         8B06
40126ECB: add     ESI,$04           83C604
40126ECE: pop     EDX               5A
40126ECF: mov     [EAX],DL          8810
40126ED1: pop     EAX               58
40126ED2: xchg    ESP,ESI           87F4
40126ED4: ret                       C3

VERSION 3: 15 instructions / 55.5 sec --> 129.3 sec
disw c+!-3  Adresse : 1074949860
40126EE4: xchg    ESP,ESI           87F4
40126EE6: mov     -$04[ESI],EAX     8946FC
40126EE9: sub     ESI,$04           83EE04
40126EEC: mov     EAX,[ESI]         8B06
40126EEE: movzx   EAX,BYTE PTR [EAX]
                                    0FB600
40126EF1: pop     EDX               5A
40126EF2: add     EAX,EDX           03C2
40126EF4: push    EAX               50
40126EF5: mov     EAX,[ESI]         8B06
40126EF7: add     ESI,$04           83C604
40126EFA: pop     EDX               5A
40126EFB: mov     [EAX],DL          8810
40126EFD: pop     EAX               58
40126EFE: xchg    ESP,ESI           87F4
40126F00: ret                       C3

--
Bernd



Mon, 07 Jul 2003 04:10:19 GMT  
 DUP >R

Quote:

> Coos Haak mentioned:
> > R> DROP  and its complement DUP >R

> What is the best name for DUP >R ?
> Did anybody measure how often it is used?

not "measured", because of "very often"...
I use the name
        >RR

regards,
        hp
--
        .hpr - h.-peter recktenwald, berlin - t: +49 30 85967858
Linux & Assembly & Forth: http://home.snafu.de/phpr/index-lx.html (en,de)
Verwendung zu kommerziellen Zwecken ist gem. 28 Abs. 3 BDSG untersagt.



Mon, 07 Jul 2003 18:33:14 GMT  
 DUP >R

Quote:

>Performance relies on the compiler. This is benchmarked with bigFORTH
on
>a 233MHz-Pentium-MMX.

The following demonstrates this with VFX Forth v3.3

Quote:
>\ increment byte in memory



>VERSION 1: 18 instructions / 12.7 sec --> 29.6 clocks
>disw c+!-1  Adresse : 1074949776
>40126E90: xchg    ESP,ESI           87F4
>40126E92: push    EAX               50
>40126E93: movzx   EAX,BYTE PTR [EAX]
>                                    0FB600
>40126E96: pop     ECX               59
>40126E97: pop     EDX               5A
>40126E98: push    ECX               51
>40126E99: push    EAX               50
>40126E9A: mov     EAX,EDX           8BC2
>40126E9C: pop     EDX               5A
>40126E9D: add     EAX,EDX           03C2
>40126E9F: pop     EDX               5A
>40126EA0: push    EAX               50
>40126EA1: mov     EAX,EDX           8BC2
>40126EA3: pop     EDX               5A
>40126EA4: mov     [EAX],DL          8810
>40126EA6: pop     EAX               58
>40126EA7: xchg    ESP,ESI           87F4
>40126EA9: ret                       C3

VFX Forth:
dis c+!-1
C+!-1
( 004966D0    0FB613 )                MOVZX   EDX, Byte Ptr 0 [EBX]
( 004966D3    035500 )                ADD     EDX, [EBP]
( 004966D6    8813 )                  MOV     0 [EBX], DL
( 004966D8    8B5D04 )                MOV     EBX, [EBP+04]
( 004966DB    8D6D08 )                LEA     EBP, [EBP+08]
( 004966DE    C3 )                    NEXT,
( 15 bytes )
 ok

- Show quoted text -

Quote:
>VERSION 2: 16 instructions / 13.5 sec --> 31.5 clocks
>disw c+!-2  Adresse : 1074949816
>40126EB8: xchg    ESP,ESI           87F4
>40126EBA: push    EAX               50
>40126EBB: mov     -$04[ESI],EAX     8946FC
>40126EBE: sub     ESI,$04           83EE04
>40126EC1: pop     EAX               58
>40126EC2: movzx   EAX,BYTE PTR [EAX]
>                                    0FB600
>40126EC5: pop     EDX               5A
>40126EC6: add     EAX,EDX           03C2
>40126EC8: push    EAX               50
>40126EC9: mov     EAX,[ESI]         8B06
>40126ECB: add     ESI,$04           83C604
>40126ECE: pop     EDX               5A
>40126ECF: mov     [EAX],DL          8810
>40126ED1: pop     EAX               58
>40126ED2: xchg    ESP,ESI           87F4
>40126ED4: ret                       C3

VFX Forth:
dis c+!-2
C+!-2
( 004966FC    53 )                    PUSH    EBX
( 004966FD    0FB61B )                MOVZX   EBX, Byte Ptr 0 [EBX]
( 00496700    035D00 )                ADD     EBX, [EBP]
( 00496703    5A )                    POP     EDX
( 00496704    881A )                  MOV     0 [EDX], BL
( 00496706    8B5D04 )                MOV     EBX, [EBP+04]
( 00496709    8D6D08 )                LEA     EBP, [EBP+08]
( 0049670C    C3 )                    NEXT,
( 17 bytes )
 ok

- Show quoted text -

Quote:
>VERSION 3: 15 instructions / 55.5 sec --> 129.3 sec
>disw c+!-3  Adresse : 1074949860
>40126EE4: xchg    ESP,ESI           87F4
>40126EE6: mov     -$04[ESI],EAX     8946FC
>40126EE9: sub     ESI,$04           83EE04
>40126EEC: mov     EAX,[ESI]         8B06
>40126EEE: movzx   EAX,BYTE PTR [EAX]
>                                    0FB600
>40126EF1: pop     EDX               5A
>40126EF2: add     EAX,EDX           03C2
>40126EF4: push    EAX               50
>40126EF5: mov     EAX,[ESI]         8B06
>40126EF7: add     ESI,$04           83C604
>40126EFA: pop     EDX               5A
>40126EFB: mov     [EAX],DL          8810
>40126EFD: pop     EAX               58
>40126EFE: xchg    ESP,ESI           87F4
>40126F00: ret                       C3

VFX Forth:
dis c+!-3
C+!-3
( 0049672C    53 )                    PUSH    EBX
( 0049672D    8B1C24 )                MOV     EBX, [ESP]
( 00496730    0FB61B )                MOVZX   EBX, Byte Ptr 0 [EBX]
( 00496733    035D00 )                ADD     EBX, [EBP]
( 00496736    5A )                    POP     EDX
( 00496737    881A )                  MOV     0 [EDX], BL
( 00496739    8B5D04 )                MOV     EBX, [EBP+04]
( 0049673C    8D6D08 )                LEA     EBP, [EBP+08]
( 0049673F    C3 )                    NEXT,
( 20 bytes )
 ok

Once the compiler reaches a certain efficiency, the need for
micro-optimisation words such as DUP>R and R>DROP
completely disappears.
--

MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)2380 631441, fax: +44 (0)2380 339691
web: http://www.mpeltd.demon.co.uk - free ProForth downloads!



Mon, 07 Jul 2003 18:47:22 GMT  
 DUP >R

Quote:

> Once the compiler reaches a certain efficiency, the need for
> micro-optimisation words such as DUP>R and R>DROP
> completely disappears.

For me, it's not a matter of efficiency.
the word >R means "create a local variable",
RDROP means "delete that local variable",
and COPY>R means "also going to a local variable" (of a value).

It's not the matter of standardization:
the standard solution is ugly but possible.

It's the matter of adequate naming, such naming that
would make thinking most convenient.



Tue, 08 Jul 2003 04:19:17 GMT  
 DUP >R

Quote:

> not "measured", because of "very often"...
> I use the name
>         >RR

I use the name to denote "move a return address to the r-stack",
on F-PC this would be 2>R ,
on Win32Forth this is equivalent to REL>ABS >R ,
and on many Forths (best Forths) it is just >R .




Tue, 08 Jul 2003 04:23:38 GMT  
 DUP >R

concerning "Re: DUP >R":

Quote:

> > Coos Haak mentioned:
> > > R> DROP  and its complement DUP >R

> > What is the best name for DUP >R ?

F-PC  uses   DUP>R   and   R>drop
I never found any problems with these names,
many are used to these names.

Quote:
> > Did anybody measure how often it is used?

in F-PC very often.
It depends on your 'philosohpy' and the size of your return stack.
F-PC  makes VERY much use of saving data on the return stack.
The return stack of the original version even may overflow during
fileloading, but these erros are quite 'soft'.

Quote:
> > I know of the following names for ( x -- x ) ( R: -- x ) :

> > DUP>R   -- 2DUP>R is difficult to distinguish from 2DUP >R
> >         when the code is pronounced, and 2DUP2>R is even
> >         uglier than 2R>2DROP.

I interpret   2dup>R   thinking of    2(dup>R)
i.e.  doing a   dup>R   operation on a 2cell-size-item.

Quote:



both names lead to a lot of misinterpretations.

Quote:
> > COPY>R  -- maybe not the best name, but 2COPY>R is no problem
> >         because there is no COPY in Forth. OTOH, uses one more
> >         natural language word for the programming language
> >         purposes.

why using  copy   if we in forth use   dup   for a copy operation.

Quote:
> > Any better suggestions?
> > ("leave it in two words")

this is to slow, as long as you use no special compiler optimisations.
I don't want to use a noisy 1 GHz pentium
if it can be done with a small processor driven by battery.

ON some applications I even use  2dup>R   and   2R>drop  ( CODE )
which speeds up some other high level words quite significantly.
of course a 8 or 16 bit and paged system needs those words more heavily
than a 32 bit linear system.

DMATH.seq  in F-PC speeds up when using combined functions.

Quote:
> > do not do that -- universal advice

that's a very good advice, give it to murphy .

--
                        Arndt Klingelnberg

         Aix la Chapelle   :-)   Euregio Meuse/Maas Rhine/Rhein
## CrossPoint v3.12d R ##



Tue, 08 Jul 2003 23:43:00 GMT  
 DUP >R

Quote:

> > > Did anybody measure how often it is used?
> in F-PC very often.
> It depends on your 'philosohpy' and the size of your return stack.
> F-PC  makes VERY much use of saving data on the return stack.
> The return stack of the original version even may overflow during
> fileloading, but these erros are quite 'soft'.

I don't by that, a error is still a error. stack errors like floating point
and NULL pointers my be 'soft' on some systems but *BOOM* Someday.

Ben.
--
"We do not inherit our time on this planet from our parents...
 We borrow it from our children."
"Luna family of Octal Computers" http://www.jetnet.ab.ca/users/bfranchuk



Sat, 05 Jul 2003 04:41:41 GMT  
 DUP >R

Quote:

> > > COPY>R  -- maybe not the best name, but 2COPY>R is no problem
> > >         because there is no COPY in Forth. OTOH, uses one more
> > >         natural language word for the programming language
> > >         purposes.

> why using  copy   if we in forth use   dup   for a copy operation.

For the same reason as there are UM/MOD FM/MOD and SM/REM :
to make it more different from other words.
2DUP>R may be confused with 2DUP >R when pronounced in any spoken
language (unless space delimiters are somehow pronounced).
There is no COPY in Forth so COPY>R and 2COPY>R lead to no
confusion.

COPYR ?
DUPR ?

Quote:
>...

[in sig]

Quote:
> > > do not do that -- universal advice
> that's a very good advice, give it to murphy .

And it is self-contradictive: it may be read as
"'do not do that' is an universal advice, so do that".

When we understand these two meanings, the third meaning
appears ("%1st% but %2nd%") and so on.

regards, MLG
--
the right question is half the answer



Wed, 09 Jul 2003 06:22:11 GMT  
 DUP >R

Quote:


> > > > COPY>R  -- maybe not the best name, but 2COPY>R is no problem
> > > >         because there is no COPY in Forth. OTOH, uses one more
> > > >         natural language word for the programming language
> > > >         purposes.

> > why using  copy   if we in forth use   dup   for a copy operation.

> For the same reason as there are UM/MOD FM/MOD and SM/REM :
> to make it more different from other words.
> 2DUP>R may be confused with 2DUP >R when pronounced in any spoken
> language (unless space delimiters are somehow pronounced).
> There is no COPY in Forth so COPY>R and 2COPY>R lead to no
> confusion.

> COPYR ?
> DUPR ?

    If it's hard to name, it probably shouldn't exist.

--

-GJC



Wed, 09 Jul 2003 10:38:18 GMT  
 DUP >R

Quote:

>Coos Haak mentioned:
>> R> DROP  and its complement DUP >R

>What is the best name for DUP >R ?

I've used R>> with the analogy being ">" as pipe overwrite and ">>" as
pipe append.  I don't use R! since stores normally overwrite the
previous comment.


holding the shift down and hitting the >. key.

(
----------
Virtually,

Bruce McFarling, Newcastle,

)



Sun, 13 Jul 2003 06:59:17 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. +R as a name for DUP >R

2. HELP>>>DUP SYMBOL PROBLEM

3. HELP>>>>>>>Fortran-Pascal Linking

4. >>>>>>>FROM SMTK TO C++

5. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

6. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

7. >>>>>AVL tree

8. >>>>>How to read a IMAGE file?(BMP, GIF)|||||||||

9. ANNOUNCE>>>>>TOTAL FrameWork from Cincom

10. Slow/No Speed>>>>>>>>>

11. UNDROP an alternative to ?DUP

12. dup

 

 
Powered by phpBB® Forum Software