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


Groups > comp.lang.forth > #60519

Re: Heap's algorithm

From Alex <alex@rivadpm.com>
Newsgroups comp.lang.forth
Subject Re: Heap's algorithm
Date 2017-06-09 18:43 +0100
Organization A noiseless patient Spider
Message-ID <ohemi0$dvb$1@dont-email.me> (permalink)
References (2 earlier) <774d2d0e-81f4-4219-a17d-858494f100a1@googlegroups.com> <7931b062-2ae1-4810-a14b-c29cf7721dd8@googlegroups.com> <2fc231bf-4c5a-45fd-9718-ced9d9c65238@googlegroups.com> <644df7e0-68b7-4444-b0f8-eb8753bf3b03@googlegroups.com> <7emdnUxke-MDJ6fEnZ2dnUU7-LfNnZ2d@supernews.com>

Show all headers | View raw


On 6/9/2017 16:11, Andrew Haley wrote:
> Raimond Dragomir <raimond.dragomir@gmail.com> wrote:
>>
>> I try it, here it is again:
>> : switch { a1 a2 -- } a1 @ a2 @ a1 ! a2 ! ;
>>
>> Some things just don't fit to the stack model. They are more
>> random access than ordered in some way. The traditional forth
>> doesn't want to admit this reality and solves everything by
>> stack juggling, no matter how awfull the code looks (and
>> probably is).
> 
> If you're going to insist on traditional, Forth would do something
> like this:
> 
> code switch ( a1 a2)
>     0 [ebp] eax mov ( a1 -> eax)
>     0 [eax] ecx mov ( n1 -> ecx)
>     0 [ebx] ecx xchg ( n1 -> a2, n2 -> ecx)
>     cell [ebp] ebx mov
>     ecx 0 [eax] mov ( n2 -> a1)
>     2 cells # ebp add ( pop a1 and a2)
>     ret
> end-code
> 
> This is a semi-serious point: when it was commonplace to write fiddly
> low-level definitions like this in code, there wasn't much of a
> perceived problem.
> 
> Andrew.
> 

XCHG LOCKs for memory operands.

see exchange
code exchange ( 2 -- 0 )
\ exchange is defined in src/kernel/gkernel32.fs at line 1288
\ call compiled
\ code=$401D0F len=17 type=129
( $0 )    mov     ecx dword { $0 ebp }              \ 8B4D00
( $3 )    mov     edx dword { eax }                 \ 8B10
( $5 )    mov     edi dword { ecx }                 \ 8B39
( $7 )    mov     dword { eax } edi                 \ 8938
( $9 )    mov     dword { ecx } edx                 \ 8911
( $B )    mov     eax dword { $4 ebp }              \ 8B4504
( $E )    add     ebp $8                            \ 83C508
( $11 )   ret                                       \ C3 ( end ) ok

EAX is cached TOS, EBP is stack.

-- 
Alex

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


Thread

Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-08 23:21 -0700
  Re: Heap's algorithm Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-06-09 00:27 -0700
    Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 01:40 -0700
      Re: Heap's algorithm Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-06-09 02:15 -0700
        Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 03:04 -0700
          Re: Heap's algorithm Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-06-09 03:50 -0700
            Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 07:37 -0700
              Re: Heap's algorithm Coos Haak <htrofhc@gmail.com> - 2017-06-09 19:50 +0200
                Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 11:32 -0700
            Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 07:54 -0700
            Re: Heap's algorithm Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-09 10:11 -0500
              Re: Heap's algorithm Alex <alex@rivadpm.com> - 2017-06-09 18:43 +0100
          Re: Heap's algorithm rickman <gnuarm@gmail.com> - 2017-06-09 11:18 -0400
            Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 08:42 -0700
              Re: Heap's algorithm rickman <gnuarm@gmail.com> - 2017-06-09 13:43 -0400
      Re: Heap's algorithm Lars Brinkhoff <lars.spam@nocrew.org> - 2017-06-09 13:08 +0200
    Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-09 09:35 -0700
      Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 23:31 -0700
        Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-10 14:28 -0700
          Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-10 14:44 -0700
            Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-10 18:56 -0700
              Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-10 19:19 -0700
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-10 21:04 -0700
                Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-10 21:08 -0700
                Re: Heap's algorithm Ron Aaron <rambamist@gmail.com> - 2017-06-11 07:19 +0300
                Re: Heap's algorithm Alex <alex@rivadpm.com> - 2017-06-11 09:43 +0100
                Re: Heap's algorithm minforth@arcor.de - 2017-06-11 02:35 -0700
                Re: Heap's algorithm Alex <alex@rivadpm.com> - 2017-06-11 10:45 +0100
                Re: Heap's algorithm rickman <gnuarm@gmail.com> - 2017-06-11 12:32 -0400
                Re: Heap's algorithm Alex <alex@rivadpm.com> - 2017-06-11 17:52 +0100
                Re: Heap's algorithm rickman <gnuarm@gmail.com> - 2017-06-12 23:26 -0400
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-12 19:55 -0700
                Re: Heap's algorithm krishna.myneni@ccreweb.org - 2017-06-11 14:40 -0700
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-12 09:02 -0700
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-10 21:30 -0700
                Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-10 21:51 -0700
                Re: Heap's algorithm "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-12 02:24 +0000
                Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-11 19:28 -0700
                Re: Heap's algorithm Melzzzzz <Melzzzzz@zzzzz.com> - 2017-06-12 03:41 +0000
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-14 22:15 -0700
                Re: Heap's algorithm Ron Aaron <rambamist@gmail.com> - 2017-06-15 08:29 +0300
                Re: Heap's algorithm Alex <alex@rivadpm.com> - 2017-06-15 12:24 +0100
                Re: Heap's algorithm Ron Aaron <rambamist@gmail.com> - 2017-06-15 15:59 +0300
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-16 01:25 -0700
                Re: Heap's algorithm awegel@arcor.de (Alexander Wegel) - 2017-06-15 14:08 +0200
                Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-16 10:46 -0700
                Re: Heap's algorithm awegel@arcor.de (Alexander Wegel) - 2017-06-17 02:47 +0200
  Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-09 00:31 -0700
  Re: Heap's algorithm Coos Haak <htrofhc@gmail.com> - 2017-06-09 12:32 +0200
  Re: Heap's algorithm hum9 <obi65537@gmail.com> - 2017-06-09 10:03 -0700
    Re: Heap's algorithm hum9 <obi65537@gmail.com> - 2017-06-09 22:28 -0700
  Re: Heap's algorithm hum9 <obi65537@gmail.com> - 2017-06-10 03:07 -0700
    Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-10 05:41 -0700
      Re: Heap's algorithm hum9 <obi65537@gmail.com> - 2017-06-10 18:05 +0300
  Re: Heap's algorithm "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-12 03:32 +0000
    Re: Heap's algorithm "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-12 03:35 +0000
      Re: Heap's algorithm "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-12 04:01 +0000
      Re: Heap's algorithm "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-12 11:01 +0000
    Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-11 21:14 -0700
      Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-11 22:00 -0700
        Re: Heap's algorithm Melzzzzz <Melzzzzz@zzzzz.com> - 2017-06-12 07:54 +0000
          Re: Heap's algorithm Julian Fondren <julian.fondren@gmail.com> - 2017-06-12 01:13 -0700
            Re: Heap's algorithm Melzzzzz <Melzzzzz@zzzzz.com> - 2017-06-12 08:20 +0000
  Re: Heap's algorithm Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-06-14 20:17 +0100
    Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-16 01:16 -0700
      Re: Heap's algorithm Alex <alex@rivadpm.com> - 2017-06-16 15:14 +0100
        Re: Heap's algorithm Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-06-16 20:15 +0100
      Re: Heap's algorithm Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-06-16 20:14 +0100
        Re: Heap's algorithm hughaguilar96@gmail.com - 2017-06-16 19:35 -0700

csiph-web