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


Groups > comp.lang.forth > #42052

Re: old `leave` renamed to `exhaust`

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: old `leave` renamed to `exhaust`
Date 2015-09-17 06:04 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2015Sep17.080430@mips.complang.tuwien.ac.at> (permalink)
References (4 earlier) <mt8f9i$qm3$1@speranza.aioe.org> <y7pior0acvxj.ch2dlom72stl$.dlg@40tude.net> <mtafsr$j8m$1@speranza.aioe.org> <2015Sep16.081024@mips.complang.tuwien.ac.at> <mtdi68$5nh$1@speranza.aioe.org>

Show all headers | View raw


"HAA" <someone@microsoft.com> writes:
>Output
>below is from 8086 PolyForth /LOOP.  I was unable to test \LOOP as
>there was none in the implementation I had.
>
>: TEST DO I U. 1 /LOOP ; ok
>0 10 TEST  10 ok
>10 0 TEST  0 1 2 3 4 5 6 7 8 9 ok
>HEX ok
>FFFF FFF8 TEST  FFF8 FFF9 FFFA FFFB FFFC FFFD FFFE ok
>0 FFF8 TEST  FFF8 ok
>
>Note the full 64K range was not possible (unlike 83 +LOOP)

Ok, Gforth's -LOOP uses wraparound arithmetics:

: x ?do i hex. 1 -loop ;  ok
-3 3 cr x 
$3 $2 $1 $0 $FFFFFFFFFFFFFFFF $FFFFFFFFFFFFFFFE  ok
$7ffffffffffffffd $8000000000000001 cr x 
$8000000000000001 $8000000000000000 $7FFFFFFFFFFFFFFF $7FFFFFFFFFFFFFFE  ok

It also works with increments exceeding MAX-N:

: y 0 -1 do i hex. -5 -loop ;  ok
y $FFFFFFFFFFFFFFFF $4  ok

The current implementation does not loop if index=limit.  The current
test corresponds to:

index limit - incr u> if
  ... loop ..
else
  ... exit loop ...
then

And of course this does not loop if index=limit.

An implementation that loops on index=limit would be:

limit newindex - incr u>= if
   ... loop ...
else
   ... exit loop
then

I have changed the implementation accordingly, and it seems to work:

: z 0 0 do i hex. $4000000000000000 -loop ;  ok
cr z 
$0 $C000000000000000 $8000000000000000 $4000000000000000  ok

Looking at the code, it takes the same number of instructions, so the
performance should be similar:

old                                  new
mov  0x0(%r13),%rdx                  mov  0x0(%r13),%rax                
mov  %r15,%rcx                       mov  0x8(%r13),%rsi                
mov  (%rbx),%rdi                     mov  %r15,%rcx                     
lea  0x8(%r15),%r15                  mov  (%rbx),%rdi                   
mov  %rdx,%rsi                       lea  0x8(%r15),%r15                
sub  0x8(%r13),%rdx                  sub  %r14,%rax                     
sub  %r14,%rsi                       sub  %rax,%rsi                     
cmp  %rdx,%r14                       cmp  %rsi,%r14                     
jae  0x4031ec <gforth_engine+1500>   ja   0x4031ec <gforth_engine+1500> 
mov  %rsi,0x0(%r13)                  mov  %rax,0x0(%r13)                
mov  (%rdi),%rdx                     mov  (%rdi),%rdx                   
lea  0x8(%rdi),%rbx                  lea  0x8(%rdi),%rbx                
mov  0x8(%rcx),%r14                  mov  0x8(%rcx),%r14                
mov  %rdx,%rax                       mov  %rdx,%rax                     
jmpq *%rax                           jmpq *%rax                         
mov  %rsi,0x0(%r13)                  mov  %rax,0x0(%r13)                
mov  0x8(%rcx),%r14                  mov  0x8(%rcx),%r14                
add  $0x10,%rbx                      add  $0x10,%rbx                    
mov  -0x8(%rbx),%rdx                 mov  -0x8(%rbx),%rdx               
mov  %rdx,%rax                       mov  %rdx,%rax                     
jmpq *%rax                           jmpq *%rax                         

- 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: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

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


Thread

old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-07 20:29 +0000
  Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-08 14:52 +1000
    Re: old `leave` renamed to `exhaust` Mark Wills <markwills1970@gmail.com> - 2015-09-08 00:57 -0700
      Re: old `leave` renamed to `exhaust` Bernd Paysan <bernd.paysan@gmx.de> - 2015-09-08 15:19 +0200
    Re: old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-08 16:25 +0000
      Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-09 11:39 +1000
        Re: old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-09 10:42 +0000
          Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-10 14:05 +1000
            Re: old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-10 13:33 +0000
              Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-10 22:04 +0200
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-10 22:13 +0200
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-11 13:14 +1000
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-11 12:30 +0200
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-11 21:47 +1000
                Re: old `leave` renamed to `exhaust` Bernd Paysan <bernd.paysan@gmx.de> - 2015-09-11 14:09 +0200
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-12 11:29 +1000
                Re: old `leave` renamed to `exhaust` "Elizabeth D. Rather" <erather@forth.com> - 2015-09-11 16:05 -1000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-14 12:25 +1000
                Re: old `leave` renamed to `exhaust` "Elizabeth D. Rather" <erather@forth.com> - 2015-09-13 17:53 -1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-14 08:33 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-15 16:55 +1000
                Re: old `leave` renamed to `exhaust` hughaguilar96@gmail.com - 2015-09-15 01:46 -0700
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-15 15:14 +0200
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-15 15:13 +0000
                Re: old `leave` renamed to `exhaust` hughaguilar96@gmail.com - 2015-09-15 16:13 -0700
                Re: old `leave` renamed to `exhaust` jim.brakefield@ieee.org - 2015-09-15 17:05 -0700
                Re: old `leave` renamed to `exhaust` hughaguilar96@gmail.com - 2015-09-15 18:35 -0700
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-19 11:42 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-19 10:48 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-20 00:01 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-19 15:02 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-21 15:51 +1000
                Re: old `leave` renamed to `exhaust` "Elizabeth D. Rather" <erather@forth.com> - 2015-09-15 08:45 -1000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-16 11:18 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-16 06:10 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-17 15:15 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-17 06:04 +0000
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-11 14:16 +0200

csiph-web