Re: Stack vs stackless operation

Liste des GroupesRevenir à cl forth 
Sujet : Re: Stack vs stackless operation
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forth
Date : 26. Feb 2025, 15:32:50
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Feb26.153250@mips.complang.tuwien.ac.at>
References : 1 2 3
User-Agent : xrn 10.11
mhx@iae.nl (mhx) writes:
: :=: ( a b -- ) \ exchange values among two variables
OVER @ >R  DUP @   ROT !   R> SWAP ! ;

<https://www.complang.tuwien.ac.at/forth/programs/sort.fs> contains:

: exchange ( addr1 addr2 -- )
    over @ over @ >r swap ! r> swap ! ;

Let's see if Gforth produces better code for one of them:

see-code :=:                           see-code exchange                   
$7FBD6B6A06A8 over    1->2             $7FBD6B6A0728 over    1->2          
7FBD6B26B3B0:   mov     r15,$08[r10]   7FBD6B26B3F0:   mov     r15,$08[r10]
$7FBD6B6A06B0 @    2->2                $7FBD6B6A0730 @    2->2             
7FBD6B26B3B4:   mov     r15,[r15]      7FBD6B26B3F4:   mov     r15,[r15]   
$7FBD6B6A06B8 >r    2->1               $7FBD6B6A0738 over    2->3          
7FBD6B26B3B7:   mov     -$08[r14],r15  7FBD6B26B3F7:   mov     r9,r13      
7FBD6B26B3BB:   sub     r14,$08        $7FBD6B6A0740 @    3->3             
$7FBD6B6A06C0 dup    1->2              7FBD6B26B3FA:   mov     r9,[r9]     
7FBD6B26B3BF:   mov     r15,r13        $7FBD6B6A0748 >r    3->2            
$7FBD6B6A06C8 @    2->2                7FBD6B26B3FD:   mov     -$08[r14],r9
7FBD6B26B3C2:   mov     r15,[r15]      7FBD6B26B401:   sub     r14,$08     
$7FBD6B6A06D0 rot    2->3              $7FBD6B6A0750 swap    2->3          
7FBD6B26B3C5:   mov     r9,$08[r10]    7FBD6B26B405:   add     r10,$08     
7FBD6B26B3C9:   add     r10,$08        7FBD6B26B409:   mov     r9,r13      
$7FBD6B6A06D8 !    3->1                7FBD6B26B40C:   mov     r13,[r10]   
7FBD6B26B3CD:   mov     [r9],r15       $7FBD6B6A0758 !    3->1             
$7FBD6B6A06E0 r>    1->2               7FBD6B26B40F:   mov     [r9],r15    
7FBD6B26B3D0:   mov     r15,[r14]      $7FBD6B6A0760 r>    1->2            
7FBD6B26B3D3:   add     r14,$08        7FBD6B26B412:   mov     r15,[r14]   
$7FBD6B6A06E8 swap    2->3             7FBD6B26B415:   add     r14,$08     
7FBD6B26B3D7:   add     r10,$08        $7FBD6B6A0768 swap    2->3          
7FBD6B26B3DB:   mov     r9,r13         7FBD6B26B419:   add     r10,$08     
7FBD6B26B3DE:   mov     r13,[r10]      7FBD6B26B41D:   mov     r9,r13      
$7FBD6B6A06F0 !    3->1                7FBD6B26B420:   mov     r13,[r10]   
7FBD6B26B3E1:   mov     [r9],r15       $7FBD6B6A0770 !    3->1             
$7FBD6B6A06F8 ;s    1->1               7FBD6B26B423:   mov     [r9],r15    
7FBD6B26B3E4:   mov     rbx,[r14]      $7FBD6B6A0778 ;s    1->1            
7FBD6B26B3E7:   add     r14,$08        7FBD6B26B426:   mov     rbx,[r14]   
7FBD6B26B3EB:   mov     rax,[rbx]      7FBD6B26B429:   add     r14,$08     
7FBD6B26B3EE:   jmp     eax            7FBD6B26B42D:   mov     rax,[rbx]   
                                       7FBD6B26B430:   jmp     eax         

These things are hard to predict:-)

- 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: https://forth-standard.org/
EuroForth 2023 proceedings: http://www.euroforth.org/ef23/papers/
EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

Date Sujet#  Auteur
24 Feb 25 * Stack vs stackless operation72LIT
24 Feb 25 +* Re: Stack vs stackless operation4minforth
24 Feb 25 i`* Re: Stack vs stackless operation3LIT
24 Feb 25 i `* Re: Stack vs stackless operation2minforth
24 Feb 25 i  `- Re: Stack vs stackless operation1LIT
24 Feb 25 +* Re: Stack vs stackless operation14Anton Ertl
24 Feb 25 i`* Re: Stack vs stackless operation13LIT
25 Feb 25 i `* Re: Stack vs stackless operation12Anton Ertl
25 Feb 25 i  `* Re: Stack vs stackless operation11LIT
25 Feb 25 i   `* Re: Stack vs stackless operation10Anton Ertl
25 Feb 25 i    `* Re: Stack vs stackless operation9LIT
25 Feb 25 i     +* Re: Stack vs stackless operation5minforth
25 Feb 25 i     i`* Re: Stack vs stackless operation4LIT
25 Feb 25 i     i `* Re: Stack vs stackless operation3minforth
25 Feb 25 i     i  `* Re: Stack vs stackless operation2LIT
25 Feb 25 i     i   `- Re: Stack vs stackless operation1Gerry Jackson
25 Feb 25 i     `* Re: Stack vs stackless operation3Anton Ertl
25 Feb 25 i      `* Re: Stack vs stackless operation2LIT
25 Feb 25 i       `- Re: Stack vs stackless operation1Anton Ertl
25 Feb 25 +* Re: Stack vs stackless operation9dxf
25 Feb 25 i`* Re: Stack vs stackless operation8LIT
25 Feb 25 i +* Re: Stack vs stackless operation6dxf
25 Feb 25 i i`* Re: Stack vs stackless operation5LIT
26 Feb 25 i i `* Re: Stack vs stackless operation4dxf
26 Feb 25 i i  `* Re: Stack vs stackless operation3LIT
26 Feb 25 i i   `* Re: Stack vs stackless operation2minforth
26 Feb 25 i i    `- Re: Stack vs stackless operation1LIT
25 Feb 25 i `- Re: Stack vs stackless operation1Hans Bezemer
25 Feb 25 +* Re: Stack vs stackless operation2LIT
25 Feb 25 i`- do...loop (was: Stack vs stackless operation)1Anton Ertl
25 Feb 25 +* Re: Stack vs stackless operation10LIT
26 Feb 25 i`* Re: Stack vs stackless operation9Hans Bezemer
26 Feb 25 i `* Re: Stack vs stackless operation8LIT
26 Feb 25 i  `* Re: Stack vs stackless operation7Hans Bezemer
26 Feb 25 i   `* Re: Stack vs stackless operation6LIT
27 Feb 25 i    `* Re: Stack vs stackless operation5LIT
27 Feb 25 i     `* Re: Stack vs stackless operation4LIT
2 Mar 25 i      `* Re: Stack vs stackless operation3LIT
5 Mar 25 i       `* Re: Stack vs stackless operation2Hans Bezemer
6 Mar 25 i        `- Re: Stack vs stackless operation1LIT
25 Feb 25 `* Re: Stack vs stackless operation32LIT
25 Feb 25  +* Re: Stack vs stackless operation10Anton Ertl
25 Feb 25  i+- Re: Stack vs stackless operation1LIT
26 Feb 25  i`* Re: Stack vs stackless operation8LIT
26 Feb 25  i +- Re: Stack vs stackless operation1LIT
26 Feb 25  i `* Re: Stack vs stackless operation6John Ames
26 Feb 25  i  `* Re: Stack vs stackless operation5LIT
27 Feb 25  i   `* Re: Stack vs stackless operation4dxf
27 Feb 25  i    `* Re: Stack vs stackless operation3LIT
27 Feb 25  i     `* Re: Stack vs stackless operation2Hans Bezemer
27 Feb 25  i      `- Re: Stack vs stackless operation1LIT
26 Feb 25  +* Re: Stack vs stackless operation2Waldek Hebisch
26 Feb 25  i`- Re: Stack vs stackless operation1Anton Ertl
26 Feb 25  `* Re: Stack vs stackless operation19mhx
26 Feb 25   +- Re: Stack vs stackless operation1minforth
26 Feb 25   +* Re: Stack vs stackless operation16Anton Ertl
26 Feb 25   i`* Re: Stack vs stackless operation15Anton Ertl
26 Feb 25   i +* Re: Stack vs stackless operation7Paul Rubin
26 Feb 25   i i+- Re: Stack vs stackless operation1minforth
27 Feb 25   i i`* Re: Stack vs stackless operation5Anton Ertl
27 Feb 25   i i +* Re: Stack vs stackless operation2Paul Rubin
27 Feb 25   i i i`- Re: Stack vs stackless operation1Anton Ertl
27 Feb 25   i i `* Re: Stack vs stackless operation2Gerry Jackson
27 Feb 25   i i  `- Re: Stack vs stackless operation1Anton Ertl
28 Feb 25   i `* Re: Stack vs stackless operation7Anton Ertl
28 Feb 25   i  `* Re: Stack vs stackless operation6Paul Rubin
1 Mar 25   i   `* Re: Stack vs stackless operation5Anton Ertl
1 Mar 25   i    +- Stack caching (: Stack vs stackless operation)1Anton Ertl
1 Mar 25   i    `* Re: Stack vs stackless operation3Anton Ertl
1 Mar 25   i     `* Re: Stack vs stackless operation2Anton Ertl
1 Mar 25   i      `- Re: Stack vs stackless operation1mhx
27 Feb 25   `- Re: Stack vs stackless operation1mhx

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal