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


Groups > comp.lang.forth > #9523 > unrolled thread

Adding thousands separators

Started by"Ed" <nospam@invalid.com>
First post2012-02-13 21:24 +1100
Last post2012-03-01 18:52 +0000
Articles 20 on this page of 141 — 26 participants

Back to article view | Back to comp.lang.forth


Contents

  Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-13 21:24 +1100
    Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-13 13:05 -0800
      Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-16 10:19 +1100
    Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-15 08:48 +0100
      Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-23 22:46 -0800
        Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-24 08:07 +0100
        Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-24 15:00 +0100
          Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-24 08:29 -1000
            Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-25 00:11 +0100
          Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-27 23:28 -0800
            Re: Adding thousands separators Alex McDonald <blog@rivadpm.com> - 2012-02-28 01:37 -0800
              Re: Adding thousands separators Ron Aaron <rambamist@gmail.com> - 2012-02-28 15:06 +0200
            Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-29 09:29 +0100
              Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-29 03:00 -0600
                Re: Adding thousands separators The Beez <the.beez.speaks@gmail.com> - 2012-02-29 03:44 -0800
                  Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-29 11:19 -0600
              Re: Adding thousands separators hughaguilar96@yahoo.com - 2012-02-29 22:48 -0800
                Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-01 08:38 +0100
                  Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-01 00:57 -0800
                    Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-01 18:23 +0100
                    Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-01 17:22 -0800
                      Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-01 18:00 -0800
                        Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-01 22:14 -0800
                          Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-02 06:58 -0800
                            Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-02 11:07 -0800
                              Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-02 13:13 -0600
                              Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-02 11:25 -0800
                                Re: Adding thousands separators Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-03 11:00 +0000
                                  Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 03:17 -0800
                                    Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-03 12:30 +0000
                                      Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 11:39 -0800
                                      Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-06 16:31 -0800
                                    Re: Adding thousands separators mhx@iae.nl (Marcel Hendrix) - 2012-03-03 15:52 +0200
                                      Re: Adding thousands separators Coos Haak <chforth@hccnet.nl> - 2012-03-03 16:23 +0100
                                      Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 10:19 -0800
                                      Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 12:35 -0800
                                    Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-03 11:02 -0600
                                      Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-03 17:25 +0000
                                        Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 10:14 -0800
                                          Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-03 14:14 -0600
                                            Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 14:52 -0800
                                              Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-04 03:39 -0600
                                          Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-04 15:02 +0000
                                        Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-03 14:11 -0600
                                      Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-03 23:49 +0100
                                        Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 15:50 -0800
                                        Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-04 15:38 +0000
                                          Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-04 18:08 +0100
                                            Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-04 11:20 -0600
                                            Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-04 17:45 +0000
                                              Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-04 23:50 +0100
                                                Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-05 14:39 +0000
                                          Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-06 13:01 -0800
                                            Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-12 16:05 +0000
                                    Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-03 15:45 -0800
                                      Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 17:56 -0800
                                        Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-05 15:41 -0800
                                          Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-06 11:27 -0800
                                  Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 11:01 -0800
                        Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-02 05:53 -0800
                      Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-03 01:49 +0100
        Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-29 17:20 +1100
          Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-29 07:51 +0100
          Re: Adding thousands separators hughaguilar96@yahoo.com - 2012-02-29 21:26 -0800
            Re: Adding thousands separators "WJ" <w_a_x_man@yahoo.com> - 2012-03-03 03:45 +0000
            Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-04 20:49 +1100
              Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-04 15:16 +0100
                Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-06 15:06 +1100
                  Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-06 08:32 +0100
              Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-05 15:06 -0800
                Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-06 15:03 +1100
                Re: Adding thousands separators hwfwguy@gmail.com - 2012-03-06 20:29 -0800
                  Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-06 23:18 -0800
                    Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-07 06:07 -0800
                    Re: Adding thousands separators hwfwguy@gmail.com - 2012-03-07 06:36 -0800
                      Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-07 16:19 -0800
                        Re: Adding thousands separators Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-08 10:51 +0000
    Re: Adding thousands separators Doug Hoffman <glidedog@gmail.com> - 2012-02-15 20:18 -0500
      Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-17 12:29 +1100
        Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-17 09:42 -0800
          Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-20 15:24 +0000
            Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-20 20:41 -0800
              Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-21 16:46 +0000
                Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-21 12:23 -0600
                  Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-21 11:32 -0800
                    Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-22 12:46 +1100
                      Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-22 10:08 +0000
                        Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-22 08:51 -1000
                          Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 14:28 -0800
                          Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-23 13:13 +0000
                          Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-24 14:32 +1100
                            Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-23 19:53 -1000
                              Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-03 12:47 +1100
                                Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-03-02 22:26 -0800
                                  Re: Adding thousands separators Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2012-03-03 14:32 +0000
                                  Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-04 21:31 +1100
                                    Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-03-04 10:07 -0800
                                      Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-06 15:31 +1100
                                        Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-03-05 22:26 -0800
                                        Re: Adding thousands separators Josh Grams <josh@qualdan.com> - 2012-03-06 12:32 +0000
                            Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-24 05:04 -0800
                              Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-24 08:30 -1000
                      Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-22 04:28 -0600
                        Re: Adding thousands separators stephenXXX@mpeforth.com (Stephen Pelc) - 2012-02-22 14:59 +0000
                          Re: Adding thousands separators stephenXXX@mpeforth.com (Stephen Pelc) - 2012-02-22 18:05 +0000
                      Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 07:49 -0800
                        Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-02-22 12:46 -0800
                          Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 18:24 -0800
                        Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-24 13:23 +1100
                Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-21 11:29 -0800
                  Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-22 09:56 +0000
                    Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 07:37 -0800
                      Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-22 10:30 -0600
                      Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-22 16:24 +0000
                      Re: Adding thousands separators Brad <hwfwguy@gmail.com> - 2012-02-23 07:44 -0800
                        Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-02-23 17:54 +0100
                        Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-23 16:51 +0000
                          Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-23 11:49 -0600
                            Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-02-23 13:26 -0800
                              Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-23 15:58 -0600
                            Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-02-26 02:25 +0100
                              Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-26 03:24 -0600
                                Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-26 13:40 +0000
                                  Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-26 11:06 -0600
                    Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-23 15:02 -0800
    Re: Adding thousands separators Doug Hoffman <glidedog@gmail.com> - 2012-02-16 13:21 -0500
    Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-02-16 20:44 -0800
      Re: Adding thousands separators Coos Haak <chforth@hccnet.nl> - 2012-02-17 21:32 +0100
    Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-17 22:41 +0100
      Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-17 18:52 -0800
        Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-18 10:39 +0100
          Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-18 21:22 +1100
            Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-18 13:12 +0100
              Re: Adding thousands separators "Peter Knaggs" <pjk@bcs.org.uk> - 2012-02-18 16:30 +0000
                Re: Adding thousands separators Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2012-02-18 17:08 +0000
                Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-18 14:46 -0800
              Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-04 20:47 +1100
    Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-28 17:03 -0800
    Re: Adding thousands separators "WJ" <w_a_x_man@yahoo.com> - 2012-03-01 18:13 +0000
      Re: Adding thousands separators Alex McDonald <blog@rivadpm.com> - 2012-03-01 12:46 -0800
    Re: Adding thousands separators "WJ" <w_a_x_man@yahoo.com> - 2012-03-01 18:52 +0000

Page 6 of 8 — ← Prev page 1 2 3 4 5 [6] 7 8  Next page →


#9699

FromBruceMcF <agila61@netscape.net>
Date2012-02-24 05:04 -0800
Message-ID<094d77f8-ddd9-4e2f-b9ea-abcaa8a44389@y38g2000yqb.googlegroups.com>
In reply to#9692
On Feb 23, 10:32 pm, "Ed" <nos...@invalid.com> wrote:
> ANS-Forth is God (and Bruce his prophet).  Portability is
> the holy grail of ANS-Forth.  The more portable our code,
> the closer we must be to God.  Anything less indicates
> failure on our part.

Wow, I had not idea I had that job. I reckon I have been rather
massively falling far short of such an august and important
responsibility. In any event, for this particular case,

{pronouncement tone="sonorous"} Inspired by ANS-Forth, our peculiarly
agent-free God, this code is DEPENDENT upon U< finding all negative
signed values to be greater than all positive signed values. It is
only PORTABLE to systems exhibiting this behavior, believed to be all
systems in existence but not necessarily all conceivable systems, and
SHOULD ONLY BE SO PORTED. So mote it be. {/pronouncement}

[toc] | [prev] | [next] | [standalone]


#9701

From"Elizabeth D. Rather" <erather@forth.com>
Date2012-02-24 08:30 -1000
Message-ID<Z-6dnTPTmqXZStrSnZ2dnUVZ_oYAAAAA@supernews.com>
In reply to#9699
On 2/24/12 3:04 AM, BruceMcF wrote:
> On Feb 23, 10:32 pm, "Ed"<nos...@invalid.com>  wrote:
>> ANS-Forth is God (and Bruce his prophet).  Portability is
>> the holy grail of ANS-Forth.  The more portable our code,
>> the closer we must be to God.  Anything less indicates
>> failure on our part.
>
> Wow, I had not idea I had that job. I reckon I have been rather
> massively falling far short of such an august and important
> responsibility. In any event, for this particular case,
>
> {pronouncement tone="sonorous"} Inspired by ANS-Forth, our peculiarly
> agent-free God, this code is DEPENDENT upon U<  finding all negative
> signed values to be greater than all positive signed values. It is
> only PORTABLE to systems exhibiting this behavior, believed to be all
> systems in existence but not necessarily all conceivable systems, and
> SHOULD ONLY BE SO PORTED. So mote it be. {/pronouncement}

Gosh, Bruce, thanks for stepping up to the plate!  We'll look forward to 
your future pronouncements with enthusiasm!

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

[toc] | [prev] | [next] | [standalone]


#9660

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-02-22 04:28 -0600
Message-ID<Fe6dnahIqfmiXtnSnZ2dnUVZ_jadnZ2d@supernews.com>
In reply to#9657
Ed <nospam@invalid.com> wrote:
> BruceMcF wrote:
>>
>> ... but just using WITHIN is simpler, since then whether the U< works
>> correctly outside its standard domain is not an issue.
> 
> Using WITHIN may be "simpler" but it has its costs.  See below.
> 
> I make no apology for comparison technique I used. 

> : test1  [char] 0 [char] 9 1+ within ;  ok
> : test2  [char] 0 - 10 u< ;  ok

But it's exactly the same operations, written differently.

WITHIN  is

  over - >r - r> u<

so let's try inlining WITHIN:

: test3   [char] 0 [char] 9 1+  over - >r - r> u< ;  ok
see test3 
TEST3 
( 080B9CC0    6A0A )                  PUSH      0A
( 080B9CC2    83C3D0 )                ADD       EBX, -30
( 080B9CC5    5A )                    POP       EDX
( 080B9CC6    3BDA )                  CMP       EBX, EDX
( 080B9CC8    0F92C3 )                SETB/NAE BL
( 080B9CCB    F6DB )                  NEG       BL
( 080B9CCD    0FBEDB )                MOVSX     EBX, BL
( 080B9CD0    C3 )                    NEXT,
( 17 bytes, 8 instructions )

Not bad at all.  My wild-assed guess is that VFX is seeing R-stack
operations and refusing to inline the WITHIN.

Andrew.

[toc] | [prev] | [next] | [standalone]


#9663

FromstephenXXX@mpeforth.com (Stephen Pelc)
Date2012-02-22 14:59 +0000
Message-ID<4f45019e.59526143@192.168.0.50>
In reply to#9660
On Wed, 22 Feb 2012 04:28:15 -0600, Andrew Haley
<andrew29@littlepinkcloud.invalid> wrote:

>Not bad at all.  My wild-assed guess is that VFX is seeing R-stack
>operations and refusing to inline the WITHIN.

WITHIN is part of the first stage build before any optimisation
tools are compiled. Redefining WITHIN gives good results:

: w1		\ n1|u1 n2|u2 n3|u3 -- flag
  over - >r - r> u<
;

: w2		\ n1|u1 n2|u2 n3|u3 -- flag
  over - -rot - swap u<
;

: twa		\ u -- flag
  [char] 0 [char] 9 1+  within
;

: twb		\ u -- flag
  [char] 0 [char] 9 1+  w2
;

dis twa 
TWA 
( 004C91C0    8D6DF8 )                LEA       EBP, [EBP+-08]
( 004C91C3    C7450030000000 )        MOV       DWord Ptr [EBP],
00000030
( 004C91CA    895D04 )                MOV       [EBP+04], EBX
( 004C91CD    BB3A000000 )            MOV       EBX, 0000003A
( 004C91D2    E81DF4F3FF )            CALL      004085F4        WITHIN
( 004C91D7    C3 )                    NEXT,
( 24 bytes, 6 instructions )
 ok
dis twb 
TWB 
( 004C9200    83C3D0 )                ADD       EBX, -30
( 004C9203    83FB0A )                CMP       EBX, 0A
( 004C9206    0F92C3 )                SETB/NAE BL
( 004C9209    F6DB )                  NEG       BL
( 004C920B    0FBEDB )                MOVSX     EBX, BL
( 004C920E    C3 )                    NEXT,
( 15 bytes, 6 instructions )
 ok

In a future release, we'll get rid of another two instructions in TWB.

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#9668

FromstephenXXX@mpeforth.com (Stephen Pelc)
Date2012-02-22 18:05 +0000
Message-ID<4f452da3.70795812@192.168.0.50>
In reply to#9663
On Wed, 22 Feb 2012 14:59:59 GMT, stephenXXX@mpeforth.com (Stephen
Pelc) wrote:

>In a future release, we'll get rid of another two instructions in TWB.

As of VFX Forth build 3270:

: twa		\ u -- flag
  [char] 0 [char] 9 1+  within
;

dis twa 
TWA 
( 004C9190    83C3D0 )                ADD       EBX, -30
( 004C9193    83FB0A )                CMP       EBX, 0A
( 004C9196    1BDB )                  SBB       EBX, EBX
( 004C9198    C3 )                    NEXT,
( 9 bytes, 4 instructions )
 ok

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#9665

FromBruceMcF <agila61@netscape.net>
Date2012-02-22 07:49 -0800
Message-ID<6cd2d961-0ce9-467f-91a0-76c86446acec@t15g2000yqi.googlegroups.com>
In reply to#9657
On Feb 21, 8:46 pm, "Ed" <nos...@invalid.com> wrote:
> BruceMcF wrote:
>
> > ... but just using WITHIN is simpler, since then whether the U< works
> > correctly outside its standard domain is not an issue.
>
> Using WITHIN may be "simpler" but it has its costs.
> See below.
...

> : test1  [char] 0 [char] 9 1+ within ;  ok
> : test2  [char] 0 - 10 u< ;  ok

I think the "this is only guaranteed to work with two's complement" is
a phurphee ... after all, its *not* guaranteed with work with 2's
complement, it just does.

That's because of the way that the hardware typically implements
signed and unsigned operations, and there's absolutely no reason to
expect 1's complement to be different on that score just because it
has a -0 where 2's complement has a -1.

If anyone has implemented a Forth on a 1's complement signal processor
in the past twenty years, I'd be interested in hearing about it, but
to implement a Forth an on integer signed magnitude machine that is
not an antique, first someone must build the signed magnitude machine
~ I would expect as an FPGA core, but I have no idea *why* they would
build it.

[toc] | [prev] | [next] | [standalone]


#9670

FromPaul Rubin <no.email@nospam.invalid>
Date2012-02-22 12:46 -0800
Message-ID<7x7gzed29u.fsf@ruckus.brouhaha.com>
In reply to#9665
BruceMcF <agila61@netscape.net> writes:
> If anyone has implemented a Forth on a 1's complement signal processor
> in the past twenty years, I'd be interested in hearing about it, but
> to implement a Forth an on integer signed magnitude machine that is
> not an antique, first someone must build the signed magnitude machine
> ~ I would expect as an FPGA core, but I have no idea *why* they would
> build it.

Chuck Moore apparently made a chip where (I guess in order to save a few
transistors) it sounds like he had logic high = 1 for some bits in a
word and high=0 for other bits.  So to transfer data from a PC to his
chip, instead of having to either send the bits unchanged or xor them
with 0xffff (inverting them all), you had to xor with 0xaaaa (flipping
every other bit).  See:

  http://www.ultratechnology.com/ahatalk.htm

[toc] | [prev] | [next] | [standalone]


#9674

FromBruceMcF <agila61@netscape.net>
Date2012-02-22 18:24 -0800
Message-ID<f53f2b58-1ef8-4e16-a34d-907d75703f0a@w9g2000vbv.googlegroups.com>
In reply to#9670
On Feb 22, 3:46 pm, Paul Rubin <no.em...@nospam.invalid> wrote:
> BruceMcF <agil...@netscape.net> writes:
>> If anyone has implemented a Forth on a 1's complement signal
>> processor in the past twenty years, I'd be interested in hearing
>> about it, but to implement a Forth an on integer signed magnitude
>> machine that is not an antique, first someone must build the signed
>> magnitude machine ~ I would expect as an FPGA core, but I have no
>> idea *why* they would build it.

> Chuck Moore apparently made a chip where (I guess in order to save a
> few transistors) it sounds like he had logic high = 1 for some bits
> in a word and high=0 for other bits.

Alternating bits, yes. However, that is the physical current levels ~
stack bits and memory bits line up ~ even stack bits got to even
memory bits, odd stack bits got to odd memory bits ~ so its not
difference at code level. As that link noted, its just like connecting
a 1 high system to a 0 high system ~ at the I/O edge, you have to
convert, but each processor works just fine on the data it is
generating and processing itself.

Whether its for gates or speed or stability (at least some of those
chips are clockless) or some combination, but internally, aren't those
are all 2's complement chips? If an advantage of 2's complement is
gate count, after all, wouldn't that tilt Chuck even more strongly
than it tilted the evolution of microprocessors?

[toc] | [prev] | [next] | [standalone]


#9689

From"Ed" <nospam@invalid.com>
Date2012-02-24 13:23 +1100
Message-ID<ji6s6s$gor$1@news-01.bur.connect.com.au>
In reply to#9665
BruceMcF wrote:
> ...
> I think the "this is only guaranteed to work with two's complement" is
> a phurphee ... after all, its *not* guaranteed with work with 2's
> complement, it just does.
> ...

What was actually said was:

"The definition is dependent on 2's complement."

The statement was in a response to a reader who expressed
difficulty comprehending aspects of the code I posted.  Since
the algorithm used was "tricky" I felt I owed an explanation.
Other number representations were not considered as I see
them as unlikely targets for any code that I post.


[toc] | [prev] | [next] | [standalone]


#9653

FromBruceMcF <agila61@netscape.net>
Date2012-02-21 11:29 -0800
Message-ID<ddfb049a-3f49-40c9-9e86-a0b27c31d45f@9g2000yqo.googlegroups.com>
In reply to#9651
On Feb 21, 11:46 am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
wrote:
> However, if the hardware does not have such an unsigned comparison,
> only a signed comparison, and the Forth system implements U< to just
> use this signed comparison without provision for dealing with negative
> numbers, then 9 -1 U< will be false whether -1 is represented in
> 2s-complement, 1's complement, or sign-magnitude.

why then does a 2s-complement encoding guarantee that it will
necessarily work? Its the distinction between 2s-complement and 1s-
complement in the guarantee offered that I don't see.

[toc] | [prev] | [next] | [standalone]


#9658

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2012-02-22 09:56 +0000
Message-ID<2012Feb22.105614@mips.complang.tuwien.ac.at>
In reply to#9653
BruceMcF <agila61@netscape.net> writes:
>On Feb 21, 11:46=A0am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
>wrote:
>> However, if the hardware does not have such an unsigned comparison,
>> only a signed comparison, and the Forth system implements U< to just
>> use this signed comparison without provision for dealing with negative
>> numbers, then 9 -1 U< will be false whether -1 is represented in
>> 2s-complement, 1's complement, or sign-magnitude.
>
>why then does a 2s-complement encoding guarantee that it will
>necessarily work?

It doesn't.  However, AFAIK all 2s-complement hardware has an unsigned
comparison.  For 1s-complement or sign-magnitude hardware, I would
expect that it only has unsigned comparison if it also has unsigned
addition (for 2s-complement there is no difference between signed and
unsigned addition).

- 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 2011: http://www.euroforth.org/ef11/

[toc] | [prev] | [next] | [standalone]


#9664

FromBruceMcF <agila61@netscape.net>
Date2012-02-22 07:37 -0800
Message-ID<a1b7f821-1b8a-4427-937f-526a89509b1c@t24g2000yqj.googlegroups.com>
In reply to#9658
On Feb 22, 4:56 am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
wrote:
> It doesn't.  However, AFAIK all 2s-complement hardware has an unsigned
> comparison.  For 1s-complement or sign-magnitude hardware, I would
> expect that it only has unsigned comparison if it also has unsigned
> addition (for 2s-complement there is no difference between signed and
> unsigned addition).

There is no difference between signed and unsigned addition with one's
complement machines, either: just like 2's complement, it adds past
max-signed and overflows into the top bit, and the difference between
signed integers and unsigned addresses is the interpretation of that
overflow ~ and I don't see why you wouldn't handle that by return an
overflow flag in the operation just as with 2's complement hardware.

After all, the difference is that the conversion between positive and
negative can be done as a bitwise invert operation with no +1 step,
which in the worst case can propagate a carry across most of the
machine word. If you're only doing it in hardware enroute to a
subtract, you just invert the bits and invert the carry as a borrow
flag and its no difference, and so the scope of applications where
that is a difference that makes a difference would seem to be quite
small.

Subtracting equal negatives gives -0 and subtracting equal positives
gives +0 and so algorithms that assume that all 0 results are
positives need care, but I don't see that going on here.

[toc] | [prev] | [next] | [standalone]


#9666

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-02-22 10:30 -0600
Message-ID<nJqdnegrzK-JhdjSnZ2dnUVZ_gednZ2d@supernews.com>
In reply to#9664
BruceMcF <agila61@netscape.net> wrote:
> On Feb 22, 4:56?am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
> wrote:
>> It doesn't. ?However, AFAIK all 2s-complement hardware has an unsigned
>> comparison. ?For 1s-complement or sign-magnitude hardware, I would
>> expect that it only has unsigned comparison if it also has unsigned
>> addition (for 2s-complement there is no difference between signed and
>> unsigned addition).
> 
> There is no difference between signed and unsigned addition with one's
> complement machines, either: just like 2's complement, it adds past
> max-signed and overflows into the top bit, and the difference between
> signed integers and unsigned addresses is the interpretation of that
> overflow ~ and I don't see why you wouldn't handle that by return an
> overflow flag in the operation just as with 2's complement hardware.

Think about adding -1 and -1:

11111110 + 11111110 -> carry + 111111100

You have an end-around carry that has to be added back to get -2:

111111100 + 1 -> 111111101

Andrew.

[toc] | [prev] | [next] | [standalone]


#9667

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2012-02-22 16:24 +0000
Message-ID<2012Feb22.172432@mips.complang.tuwien.ac.at>
In reply to#9664
BruceMcF <agila61@netscape.net> writes:
>There is no difference between signed and unsigned addition with one's
>complement machines, either: just like 2's complement, it adds past
>max-signed and overflows into the top bit,

Hmm, if I signed-add 11...10 (-1) and 11...10 (-1) on a 1s-complement
machine, I expect the result to be either 11...101 (-2), whereas I
would expect an unsigned add to give 11...100.  So I see a difference
between signed and unsigned addition on such a machine.

> and the difference between
>signed integers and unsigned addresses is the interpretation of that
>overflow ~ and I don't see why you wouldn't handle that by return an
>overflow flag in the operation just as with 2's complement hardware.

I don't need to deal with overflow flags to get the same result for
this addition on 2s-complement hardware.

- 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 2011: http://www.euroforth.org/ef11/

[toc] | [prev] | [next] | [standalone]


#9678

FromBrad <hwfwguy@gmail.com>
Date2012-02-23 07:44 -0800
Message-ID<e0aafffd-115b-46e1-9d24-b1a799fd2286@1g2000yqv.googlegroups.com>
In reply to#9664
On Feb 22, 8:37 am, BruceMcF <agil...@netscape.net> wrote:
> After all, the difference is that the conversion between positive and
> negative can be done as a bitwise invert operation with no +1 step,
> which in the worst case can propagate a carry across most of the
> machine word. If you're only doing it in hardware enroute to a
> subtract, you just invert the bits and invert the carry as a borrow
> flag and its no difference, and so the scope of applications where
> that is a difference that makes a difference would seem to be quite
> small.

Since C drives CPU design these days, does C expect 2s complement
hardware? If so, it's a safe dependency to have.

[toc] | [prev] | [next] | [standalone]


#9680

FromBernd Paysan <bernd.paysan@gmx.de>
Date2012-02-23 17:54 +0100
Message-ID<ji5r00$tv3$1@online.de>
In reply to#9678
Brad wrote:
> Since C drives CPU design these days, does C expect 2s complement
> hardware? If so, it's a safe dependency to have.

AFAIK, the C standard does not.  But the reality is that most C programs 
depend on a bunch of assumptions:

* byte-addressed machines
* 2's complement
* unified address space
* ordered memory access

Well, essentially, x86 is the dominant platform, and what's guaranteed 
on x86 is taken for granted.  ARM has some slight deviations, especially 
on multi-core memory modell.  But that doesn't seem to be a major 
problem.  Most programmer programm for a single plattform, without 
portability in mind.

Therefore, we can take the above as "almost for granted", and any 
plattform that significantly deviats is obscure and non-mainstream.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

[toc] | [prev] | [next] | [standalone]


#9681

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2012-02-23 16:51 +0000
Message-ID<2012Feb23.175123@mips.complang.tuwien.ac.at>
In reply to#9678
Brad <hwfwguy@gmail.com> writes:
>Since C drives CPU design these days, does C expect 2s complement
>hardware?

No.  And even on 2s-complement hardware, some C compilers (in
particular, gcc) fail to satisfy properties that are easy to satisfy
on the hardware.  Their implementors aspire to implement a
higher-level language, i.e., all the disadvantages of Java without the
advantages; although actually Java defines that it runs on
2s-complement machines, and that it's arithmetic has the usual
properties (which C does not define, and which is the excuse used by
these C implementors).

> If so, it's a safe dependency to have.

It is definitely a safe dependency to have.  Nobody has reported a
Forth implementation on a non-2s-complement machine, and such machines
appear to be a thing of the past.  And I don't expect Forth
implementors to be as crazy as the gcc people (and if any of this
crazyness infects a Forth implementor, just ignore his system).

- 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 2011: http://www.euroforth.org/ef11/

[toc] | [prev] | [next] | [standalone]


#9682

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-02-23 11:49 -0600
Message-ID<urWdnWjhQ_uO4dvSnZ2dnUVZ_sadnZ2d@supernews.com>
In reply to#9681
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> Brad <hwfwguy@gmail.com> writes:
>>Since C drives CPU design these days, does C expect 2s complement
>>hardware?
> 
> No.  And even on 2s-complement hardware, some C compilers (in
> particular, gcc) fail to satisfy properties that are easy to satisfy
> on the hardware.

I think I know what you're talking about, i.e. signed overflow being
undefined, and actually they're not at all easy to satisfy if you want
to do comprehensive loop optimization.  Also, you can turn those
optimizations off and get all the properties of 2's complement
arithmetic if you want.

Andrew.

[toc] | [prev] | [next] | [standalone]


#9684

FromPaul Rubin <no.email@nospam.invalid>
Date2012-02-23 13:26 -0800
Message-ID<7x62ex8cmq.fsf@ruckus.brouhaha.com>
In reply to#9682
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
> I think I know what you're talking about, i.e. signed overflow being
> undefined, and actually they're not at all easy to satisfy if you want
> to do comprehensive loop optimization.  Also, you can turn those
> optimizations off and get all the properties of 2's complement
> arithmetic if you want.

I could see a case for adding a pragma to guarantee some behavior of
signed overflow by avoiding certain optimizations, but going in the
opposite direction (expecting compiling with optimization turned off
without a specific pragma or flag) to change the program semantics
doesn't sound like a good idea.  That assumes the undefined overflow
behavior is consistent with the standard. 

This actually doesn't sound like what Anton is referring to though,
in the comment about aspiring to be a higher-level language.

[toc] | [prev] | [next] | [standalone]


#9685

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-02-23 15:58 -0600
Message-ID<EK-dnWT6PMYMK9vSnZ2dnUVZ_jWdnZ2d@supernews.com>
In reply to#9684
Paul Rubin <no.email@nospam.invalid> wrote:
> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> I think I know what you're talking about, i.e. signed overflow being
>> undefined, and actually they're not at all easy to satisfy if you want
>> to do comprehensive loop optimization.  Also, you can turn those
>> optimizations off and get all the properties of 2's complement
>> arithmetic if you want.
> 
> I could see a case for adding a pragma to guarantee some behavior of
> signed overflow by avoiding certain optimizations, but going in the
> opposite direction (expecting compiling with optimization turned off
> without a specific pragma or flag) to change the program semantics
> doesn't sound like a good idea.

That is a rather convoluted sentence, so forgive me if I'm
misinterpreting your meaning, but I think you'll find that the former
is the case.  Although the latter is the case too.  :-)

> This actually doesn't sound like what Anton is referring to though,
> in the comment about aspiring to be a higher-level language.

Oh, who knows...

Andrew.

[toc] | [prev] | [next] | [standalone]


Page 6 of 8 — ← Prev page 1 2 3 4 5 [6] 7 8  Next page →

Back to top | Article view | comp.lang.forth


csiph-web