Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

It is necessary to have purpose. -- Alice #1, "I, Mudd", stardate 4513.3


devel / comp.lang.forth / Re: DLSHIFT and DRSHIFT

SubjectAuthor
* DLSHIFT and DRSHIFTKrishna Myneni
+* Re: DLSHIFT and DRSHIFTKrishna Myneni
|+* Re: DLSHIFT and DRSHIFTAnton Ertl
||`- Re: DLSHIFT and DRSHIFTKrishna Myneni
|+* Re: DLSHIFT and DRSHIFTRuvim
||+* Re: DLSHIFT and DRSHIFTKrishna Myneni
|||+* Re: DLSHIFT and DRSHIFTBernd Linsel
||||`* Re: DLSHIFT and DRSHIFTalbert
|||| `- Re: DLSHIFT and DRSHIFTAnton Ertl
|||`* Re: DLSHIFT and DRSHIFTAnton Ertl
||| `* Re: DLSHIFT and DRSHIFTKrishna Myneni
|||  +* Re: DLSHIFT and DRSHIFTminforth
|||  |`* Re: DLSHIFT and DRSHIFTKrishna Myneni
|||  | `- Re: DLSHIFT and DRSHIFTminforth
|||  `* Re: DLSHIFT and DRSHIFTAnton Ertl
|||   `* Re: DLSHIFT and DRSHIFTKrishna Myneni
|||    `* Re: DLSHIFT and DRSHIFTAnton Ertl
|||     `* Re: DLSHIFT and DRSHIFTKrishna Myneni
|||      `- Re: DLSHIFT and DRSHIFTAnton Ertl
||`* Re: DLSHIFT and DRSHIFTdxf
|| `* Re: DLSHIFT and DRSHIFTKrishna Myneni
||  `* Re: DLSHIFT and DRSHIFTdxf
||   `* Re: DLSHIFT and DRSHIFTKrishna Myneni
||    `- Re: DLSHIFT and DRSHIFTdxf
|+- Re: DLSHIFT and DRSHIFTHans Bezemer
|`- Re: DLSHIFT and DRSHIFTKrishna Myneni
+* Re: DLSHIFT and DRSHIFTKrishna Myneni
|`* Re: DLSHIFT and DRSHIFTRuvim
| `* Re: DLSHIFT and DRSHIFTKrishna Myneni
|  `* Re: DLSHIFT and DRSHIFTRuvim
|   +* Re: DLSHIFT and DRSHIFTKrishna Myneni
|   |`* Re: DLSHIFT and DRSHIFTHans Bezemer
|   | +- Re: DLSHIFT and DRSHIFTKrishna Myneni
|   | +- Re: DLSHIFT and DRSHIFTdxf
|   | `* Re: DLSHIFT and DRSHIFTdxf
|   |  +* Re: DLSHIFT and DRSHIFTminforth
|   |  |`* Re: DLSHIFT and DRSHIFTdxf
|   |  | `* Re: DLSHIFT and DRSHIFTKrishna Myneni
|   |  |  `* Re: DLSHIFT and DRSHIFTdxf
|   |  |   +* Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  |   |`- Re: DLSHIFT and DRSHIFTdxf
|   |  |   `* Re: DLSHIFT and DRSHIFTAnton Ertl
|   |  |    +- Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  |    `- Re: DLSHIFT and DRSHIFTdxf
|   |  +* Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  |`* Re: DLSHIFT and DRSHIFTKrishna Myneni
|   |  | `* Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  |  `* Re: DLSHIFT and DRSHIFTKrishna Myneni
|   |  |   `- Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  +* Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  |`- Re: DLSHIFT and DRSHIFTHans Bezemer
|   |  `* Re: DLSHIFT and DRSHIFTHans Bezemer
|   |   `* Re: DLSHIFT and DRSHIFTdxf
|   |    `* Re: DLSHIFT and DRSHIFTdxf
|   |     `* Re: DLSHIFT and DRSHIFTdxf
|   |      `* Re: DLSHIFT and DRSHIFTalbert
|   |       `* Re: DLSHIFT and DRSHIFTdxf
|   |        +* Re: DLSHIFT and DRSHIFTmhx
|   |        |+- Re: DLSHIFT and DRSHIFTKrishna Myneni
|   |        |`- Re: DLSHIFT and DRSHIFTdxf
|   |        `* Re: DLSHIFT and DRSHIFTalbert
|   |         `- Re: DLSHIFT and DRSHIFTHans Bezemer
|   `- Re: DLSHIFT and DRSHIFTdxf
`* Re: DLSHIFT and DRSHIFTalbert
 +- Re: DLSHIFT and DRSHIFTKrishna Myneni
 `- Re: DLSHIFT and DRSHIFTBernd Linsel

Pages:123
Re: DLSHIFT and DRSHIFT

<nnd$68963214$54a11c02@3792486c0605191e>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26612&group=comp.lang.forth#26612

  copy link   Newsgroups: comp.lang.forth
Date: Thu, 4 Apr 2024 17:34:27 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<c4647d14d5348badce538c50b74a1a62@www.novabbs.com>
<660a7c93$1@news.ausics.net> <uufnci$2qom1$1@dont-email.me>
<660b7557$1@news.ausics.net> <660e59cd$1@news.ausics.net>
Content-Language: en-US
From: the.beez.speaks@gmail.com (Hans Bezemer)
In-Reply-To: <660e59cd$1@news.ausics.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$68963214$54a11c02@3792486c0605191e>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!news.quux.org!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe006.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 37
Injection-Date: Thu, 04 Apr 2024 17:34:27 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Hans Bezemer - Thu, 4 Apr 2024 15:34 UTC

On 04-04-2024 09:42, dxf wrote:
> On 2/04/2024 2:02 pm, dxf wrote:
>> ...
>> LSHIFT/RSHIFT was intended to support the corresponding machine-code primitives available on
>> modern architectures.
>
> Not a bad guess as it turns out.
>
> Digging further I found this from ANS 'BASIS17' June 1991:
>
> 8.1.2205 SHIFT
>
> ( x1 n -- x2 )
>
> Perform a logical shift of n bit-places on x1, giving x2. If n is
> positive, shift the bits n places toward the most significant bit. If n is
> negative, shift them toward the least significant bits. Put zero into
> the places "uncovered" by the shift.
>
> That led to this Jan 1992 message:
>
> https://groups.google.com/g/comp.lang.forth/c/DqrKMIiyLWc/m/1XUyYBaHyfYJ
>
Fun part - 4tH still has SHIFT, performing exactly as indicated. LSHIFT
is exactly like SHIFT, while RSHIFT is expanded to NEGATE SHIFT.

It's been like that for the last 30 years. Can't remember whether I
nicked the word from Forth-79, but if it was there I can't rule it out.

The word has been changed several times. First to force a logical RSHIFT
and second to properly handle shifts exceeding CELL-BITS bits.

It's also exposed in uBasic/4tH with the SHL() function (which also
accepts negative shifts).

Hans Bezemer

Re: DLSHIFT and DRSHIFT

<2024Apr4.182725@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26614&group=comp.lang.forth#26614

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: DLSHIFT and DRSHIFT
Date: Thu, 04 Apr 2024 16:27:25 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 24
Message-ID: <2024Apr4.182725@mips.complang.tuwien.ac.at>
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me> <uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me> <uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me> <nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net> <c4647d14d5348badce538c50b74a1a62@www.novabbs.com> <660a7c93$1@news.ausics.net> <uufnci$2qom1$1@dont-email.me> <660b7557$1@news.ausics.net> <660e59cd$1@news.ausics.net>
Injection-Date: Thu, 04 Apr 2024 16:30:21 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="94700be7374b022f71570f4ae41ea5f1";
logging-data="809041"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+e4f2p76rcjmH+Avuq1GJh"
Cancel-Lock: sha1:E3TvGmFJqs0kCeBSCEQfKb4eAeQ=
X-newsreader: xrn 10.11
 by: Anton Ertl - Thu, 4 Apr 2024 16:27 UTC

dxf <dxforth@gmail.com> writes:
>That led to this Jan 1992 message:
>
>https://groups.google.com/g/comp.lang.forth/c/DqrKMIiyLWc/m/1XUyYBaHyfYJ

I found the last posting in this thread most fitting:

|Andrew Scott
|Jan 13, 1992, 9:32:24 PM
| |John Hayes writes:
|>The bidirectional shift operator is probably a result of the parsimony
|>of Forth philosophy; why have two operators when one will do.
| |I thought part of the Forth philosophy was exactly the *opposite*. We
|wouldn't have words like 1+ or 0< if efficiency wasn't regarded as more
|important than a small set of consistent words.

- 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: https://euro.theforth.net/2023

Re: DLSHIFT and DRSHIFT

<660f4cbd$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26619&group=comp.lang.forth#26619

  copy link   Newsgroups: comp.lang.forth
Date: Fri, 5 Apr 2024 11:58:39 +1100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Content-Language: en-GB
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<c4647d14d5348badce538c50b74a1a62@www.novabbs.com>
<660a7c93$1@news.ausics.net> <uufnci$2qom1$1@dont-email.me>
<660b7557$1@news.ausics.net> <660e59cd$1@news.ausics.net>
<nnd$68963214$54a11c02@3792486c0605191e>
From: dxforth@gmail.com (dxf)
In-Reply-To: <nnd$68963214$54a11c02@3792486c0605191e>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <660f4cbd$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 44
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Fri, 5 Apr 2024 00:58 UTC

On 5/04/2024 2:34 am, Hans Bezemer wrote:
> On 04-04-2024 09:42, dxf wrote:
>> On 2/04/2024 2:02 pm, dxf wrote:
>>> ...
>>> LSHIFT/RSHIFT was intended to support the corresponding machine-code primitives available on
>>> modern architectures.
>>
>> Not a bad guess as it turns out.
>>
>> Digging further I found this from ANS 'BASIS17' June 1991:
>>
>>    8.1.2205 SHIFT
>>
>>      ( x1 n -- x2 )
>>
>>    Perform a logical shift of n bit-places on x1, giving x2. If n is
>>    positive, shift the bits n places toward the most significant bit. If n is
>>    negative, shift them toward the least significant bits. Put zero into
>>    the places "uncovered" by the shift.
>>
>> That led to this Jan 1992 message:
>>
>> https://groups.google.com/g/comp.lang.forth/c/DqrKMIiyLWc/m/1XUyYBaHyfYJ
>>
> Fun part - 4tH still has SHIFT, performing exactly as indicated. LSHIFT is exactly like SHIFT, while RSHIFT is expanded to NEGATE SHIFT.
>
> It's been like that for the last 30 years. Can't remember whether I nicked the word from Forth-79, but if it was there I can't rule it out.

Didn't think to look but yes - it is from Forth-79 'Reference Word Set' (Kitt Peak Forth
words that didn't make it into the standard proper).

ASHIFT n1 n2 -- n3
Shift the value n1 arithemetically n2 bits left if n2 is
positive, shifting zeros into the least-significant bit
positions. If n2 is negative, n1 is shifted right. Sign
extension is to be consistent with the processor's arithmetic
shift.
> The word has been changed several times. First to force a logical RSHIFT and second to properly handle shifts exceeding CELL-BITS bits.
>
> It's also exposed in uBasic/4tH with the SHL() function (which also accepts negative shifts).
>
> Hans Bezemer

Re: DLSHIFT and DRSHIFT

<nnd$6d6232f8$617ed8f5@89bdbd77391bf9e2>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26627&group=comp.lang.forth#26627

  copy link   Newsgroups: comp.lang.forth
Date: Fri, 5 Apr 2024 22:43:52 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<c4647d14d5348badce538c50b74a1a62@www.novabbs.com>
<660a7c93$1@news.ausics.net> <uufnci$2qom1$1@dont-email.me>
<660b7557$1@news.ausics.net> <660e59cd$1@news.ausics.net>
<2024Apr4.182725@mips.complang.tuwien.ac.at>
Content-Language: en-US
From: the.beez.speaks@gmail.com (Hans Bezemer)
In-Reply-To: <2024Apr4.182725@mips.complang.tuwien.ac.at>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Message-ID: <nnd$6d6232f8$617ed8f5@89bdbd77391bf9e2>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!newsfeed.bofh.team!2.eu.feeder.erje.net!feeder.erje.net!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 25
Injection-Date: Fri, 05 Apr 2024 22:43:52 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Hans Bezemer - Fri, 5 Apr 2024 20:43 UTC

On 04-04-2024 18:27, Anton Ertl wrote:
> dxf <dxforth@gmail.com> writes:
> I found the last posting in this thread most fitting:
>
> |Andrew Scott
> |Jan 13, 1992, 9:32:24 PM
> |
> |John Hayes writes:
> |>The bidirectional shift operator is probably a result of the parsimony
> |>of Forth philosophy; why have two operators when one will do.
> |
> |I thought part of the Forth philosophy was exactly the *opposite*. We
> |wouldn't have words like 1+ or 0< if efficiency wasn't regarded as more
> |important than a small set of consistent words.

So true - which is fun when you're implementing Forth in bytecode. Since
bytecodes are limited, you want to restrict the number of words, while
Forth tends to expand its vocabulary. The most common ones have their
own bytecode in 4tH, while the less frequently used are often
composites. 4tH got about 100 bytecodes, but almost three times the
number of builtin words.

Hans Bezemer

Re: DLSHIFT and DRSHIFT

<6610a146$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26628&group=comp.lang.forth#26628

  copy link   Newsgroups: comp.lang.forth
Date: Sat, 6 Apr 2024 12:11:36 +1100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<c4647d14d5348badce538c50b74a1a62@www.novabbs.com>
<660a7c93$1@news.ausics.net> <uufnci$2qom1$1@dont-email.me>
<660b7557$1@news.ausics.net> <660e59cd$1@news.ausics.net>
<2024Apr4.182725@mips.complang.tuwien.ac.at>
Content-Language: en-GB
From: dxforth@gmail.com (dxf)
In-Reply-To: <2024Apr4.182725@mips.complang.tuwien.ac.at>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <6610a146$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 20
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Sat, 6 Apr 2024 01:11 UTC

On 5/04/2024 3:27 am, Anton Ertl wrote:
> ...
> I found the last posting in this thread most fitting:
>
> |Andrew Scott
> |Jan 13, 1992, 9:32:24 PM
> |
> |John Hayes writes:
> |>The bidirectional shift operator is probably a result of the parsimony
> |>of Forth philosophy; why have two operators when one will do.
> |
> |I thought part of the Forth philosophy was exactly the *opposite*. We
> |wouldn't have words like 1+ or 0< if efficiency wasn't regarded as more
> |important than a small set of consistent words.

ALLOT is a good example of the 'parsimony' rule. Unlike bidirectional
shift, co-habitation is cheap and easy. Issues created by a bidirectional
ALLOT mostly affects 16-bit users. As I could afford to be single, I have
ALLOT and RECOVER.

Re: DLSHIFT and DRSHIFT

<nnd$13528db7$4cea3111@28a700ec0dd4b5a8>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26629&group=comp.lang.forth#26629

  copy link   Newsgroups: comp.lang.forth
Date: Sun, 7 Apr 2024 14:53:12 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
Content-Language: en-US
From: the.beez.speaks@gmail.com (Hans Bezemer)
In-Reply-To: <660a0c49$1@news.ausics.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$13528db7$4cea3111@28a700ec0dd4b5a8>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!npeer.as286.net!npeer-ng0.as286.net!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 31
Injection-Date: Sun, 07 Apr 2024 14:53:12 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2121
 by: Hans Bezemer - Sun, 7 Apr 2024 12:53 UTC

On 01-04-2024 03:22, dxf wrote:
> While your double-shift algorithm produces the correct results (not shown here),
> the intermediate values presented to each RSHIFT/LSHIFT can be quite out-of-bounds
> e.g. a shift of 40 and -20 (actually FFFFFFE0) would concern me. That an 'unambiguous'
> RSHIFT/LSHIFT will mask questionable parameters fed to it and return a result of 0,
> I for one find problematic. IMO it were better that RSHIFT/LSHIFT should fail than
> do this.

For those interested in the entire fixed routine, here it is:

: dlshift
dup 0> 0= if drop ;then
dup cell-bits - dup 0< 0= if >r drop drop r> lshift 0 swap ;then drop
>r over 0 invert cell-bits r@ - dup >r lshift and r> rshift swap
r@ lshift or swap r> lshift swap
;

: drshift
dup 0> 0= if drop ;then
dup cell-bits - dup 0< 0= if >r drop nip r> rshift 0 ;then drop
>r dup 0 invert cell-bits r@ - dup >r rshift and r> lshift swap
r@ rshift spin r> rshift or swap
;

: SPIN SWAP ROT ;
: ;THEN POSTPONE EXIT POSTPONE THEN ; IMMEDIATE

"cell-bits" should be obvious.

Hans Bezemer

Re: DLSHIFT and DRSHIFT

<6613d195$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26630&group=comp.lang.forth#26630

  copy link   Newsgroups: comp.lang.forth
Date: Mon, 8 Apr 2024 21:14:29 +1000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<nnd$13528db7$4cea3111@28a700ec0dd4b5a8>
Content-Language: en-GB
From: dxforth@gmail.com (dxf)
In-Reply-To: <nnd$13528db7$4cea3111@28a700ec0dd4b5a8>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <6613d195$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 46
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Mon, 8 Apr 2024 11:14 UTC

On 7/04/2024 10:53 pm, Hans Bezemer wrote:
> On 01-04-2024 03:22, dxf wrote:
>> While your double-shift algorithm produces the correct results (not shown here),
>> the intermediate values presented to each RSHIFT/LSHIFT can be quite out-of-bounds
>> e.g. a shift of 40 and -20 (actually FFFFFFE0) would concern me.  That an 'unambiguous'
>> RSHIFT/LSHIFT will mask questionable parameters fed to it and return a result of 0,
>> I for one find problematic.  IMO it were better that RSHIFT/LSHIFT should fail than
>> do this.
>
> For those interested in the entire fixed routine, here it is:
>
> : dlshift
>   dup 0> 0= if drop ;then
>   dup cell-bits - dup 0< 0= if >r drop drop r> lshift 0 swap ;then drop
>   >r over 0 invert cell-bits r@ - dup >r lshift and r> rshift swap
>   r@ lshift or swap r> lshift swap
> ;
>
> : drshift
>   dup 0> 0= if drop ;then
>   dup cell-bits - dup 0< 0= if >r drop nip r> rshift 0 ;then drop
>   >r dup 0 invert cell-bits r@ - dup >r rshift and r> lshift swap
>   r@ rshift spin r> rshift or swap
> ;
>
> : SPIN SWAP ROT ;
> : ;THEN POSTPONE EXIT POSTPONE THEN ; IMMEDIATE
>
> "cell-bits" should be obvious.

'8 cells' should work for most users.

Here's a hack (fix?) of the routines from CForth:
https://github.com/MitchBradley/cforth/blob/master/src/cforth/double.fth

Seems to pass Krishna's tests (other than full double cell shift) but no
warranty :)

: DLSHIFT ( xd u -- xd2 )
dup cell-bits u< not if nip cell-bits - lshift 0 swap exit then
tuck lshift >r 2dup cell-bits swap - rshift r> or >r lshift r> ;

: DRSHIFT ( xd u -- xd2 )
dup cell-bits u< not if cell-bits - rshift nip 0 exit then
2dup rshift >r tuck cell-bits swap - lshift -rot rshift or r> ;

Re: DLSHIFT and DRSHIFT

<6614bbd1$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26631&group=comp.lang.forth#26631

  copy link   Newsgroups: comp.lang.forth
Date: Tue, 9 Apr 2024 13:53:53 +1000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<nnd$13528db7$4cea3111@28a700ec0dd4b5a8> <6613d195$1@news.ausics.net>
Content-Language: en-GB
From: dxforth@gmail.com (dxf)
In-Reply-To: <6613d195$1@news.ausics.net>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <6614bbd1$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 29
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Tue, 9 Apr 2024 03:53 UTC

On 8/04/2024 9:14 pm, dxf wrote:
> ...
> Here's a hack (fix?) of the routines from CForth:
> https://github.com/MitchBradley/cforth/blob/master/src/cforth/double.fth
>
> Seems to pass Krishna's tests (other than full double cell shift) but no
> warranty :)
> ...

It appears the original also has a problem when shift is zero. A quick fix is:

: DLSHIFT ( xd u -- xd2 )
?dup if
dup cell-bits u< not if nip cell-bits - lshift 0 swap exit then
tuck lshift >r 2dup cell-bits swap - rshift r> or >r lshift r>
then ;
: DRSHIFT ( xd u -- xd2 )
?dup if
dup cell-bits u< not if cell-bits - rshift nip 0 exit then
2dup rshift >r tuck cell-bits swap - lshift -rot rshift or r>
then ;

A test using random numbers and shifts suggests it now works. Reference definitions
used were:

: UD2/ ( xd1 -- xd2 ) d2/ [ 0 invert 1 rshift ] literal and ;
: DRSHIFT2 ( xd1 n -- xd2 ) 0 ?do ud2/ loop ;
: DLSHIFT2 ( xd1 n -- xd2 ) 0 ?do d2* loop ;

Re: DLSHIFT and DRSHIFT

<66188ab1$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26658&group=comp.lang.forth#26658

  copy link   Newsgroups: comp.lang.forth
Date: Fri, 12 Apr 2024 11:13:21 +1000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Content-Language: en-GB
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <uu02tt$2k3jf$1@dont-email.me>
<uu1c3r$2tdj0$1@dont-email.me> <uu1e7t$2tueu$1@dont-email.me>
<uu1huv$2uqc2$1@dont-email.me> <uu1t7e$31jjc$1@dont-email.me>
<nnd$51ea08c7$4ebacde5@98ba4a1ad989127a> <660a0c49$1@news.ausics.net>
<nnd$13528db7$4cea3111@28a700ec0dd4b5a8> <6613d195$1@news.ausics.net>
<6614bbd1$1@news.ausics.net>
From: dxforth@gmail.com (dxf)
In-Reply-To: <6614bbd1$1@news.ausics.net>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <66188ab1$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 21
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Fri, 12 Apr 2024 01:13 UTC

On 12/04/2024 1:11 am, albert@spenarnc.xs4all.nl wrote:
>
> While others indulge in endless discussions about DRSHIFT
> I thought to attempt some literate programming.

It didn't prompt you to test your own implementation?

( D0= D0<> D0< D= D< D- M+ DRSHIFT DLSHIFT DU< ) \ AvdH B6Mar22

: DLSHIFT >R SWAP DUP R@ LSHIFT SWAP 8 CELLS R@ - RSHIFT ROT R>
LSHIFT OR ;

: DRSHIFT >R DUP R@ RSHIFT SWAP 8 CELLS R@ - LSHIFT ROT R>
RSHIFT OR SWAP ;

0 4 d. 17179869184 ok
0 4 0 drshift d. 17179869188 ok

4 0 d. 4 ok
4 0 0 dlshift d. 17179869188 ok

Re: DLSHIFT and DRSHIFT

<nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26659&group=comp.lang.forth#26659

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: DLSHIFT and DRSHIFT
References: <utvgki$2ciso$1@dont-email.me> <6613d195$1@news.ausics.net> <6614bbd1$1@news.ausics.net> <66188ab1$1@news.ausics.net>
From: albert@spenarnc.xs4all.nl
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5>
Organization: KPN B.V.
Date: Fri, 12 Apr 2024 10:27:49 +0200
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 33
Injection-Date: Fri, 12 Apr 2024 10:27:49 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: albert@spenarnc.xs4all.nl - Fri, 12 Apr 2024 08:27 UTC

In article <66188ab1$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
>On 12/04/2024 1:11 am, albert@spenarnc.xs4all.nl wrote:
>>
>> While others indulge in endless discussions about DRSHIFT
>> I thought to attempt some literate programming.
>
>It didn't prompt you to test your own implementation?
>
> ( D0= D0<> D0< D= D< D- M+ DRSHIFT DLSHIFT DU< ) \ AvdH B6Mar22
>
> : DLSHIFT >R SWAP DUP R@ LSHIFT SWAP 8 CELLS R@ - RSHIFT ROT R>
> LSHIFT OR ;
>
> : DRSHIFT >R DUP R@ RSHIFT SWAP 8 CELLS R@ - LSHIFT ROT R>
> RSHIFT OR SWAP ;
>
>0 4 d. 17179869184 ok
>0 4 0 drshift d. 17179869188 ok
>
>4 0 d. 4 ok
>4 0 0 dlshift d. 17179869188 ok
>

Good catch! Shifting over 8 CELLS is an ambiguous condition.
insert
DUP 0= IF EXIT THEN
in front of the code.
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring. - the Wise from Antrim -

Re: DLSHIFT and DRSHIFT

<661a5369$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26660&group=comp.lang.forth#26660

  copy link   Newsgroups: comp.lang.forth
Date: Sat, 13 Apr 2024 19:42:00 +1000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: dxforth@gmail.com (dxf)
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <6613d195$1@news.ausics.net>
<6614bbd1$1@news.ausics.net> <66188ab1$1@news.ausics.net>
<nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5>
Content-Language: en-GB
In-Reply-To: <nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <661a5369$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 38
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Sat, 13 Apr 2024 09:42 UTC

On 12/04/2024 6:27 pm, albert@spenarnc.xs4all.nl wrote:
> In article <66188ab1$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
>> On 12/04/2024 1:11 am, albert@spenarnc.xs4all.nl wrote:
>>>
>>> While others indulge in endless discussions about DRSHIFT
>>> I thought to attempt some literate programming.
>>
>> It didn't prompt you to test your own implementation?
>>
>> ( D0= D0<> D0< D= D< D- M+ DRSHIFT DLSHIFT DU< ) \ AvdH B6Mar22
>>
>> : DLSHIFT >R SWAP DUP R@ LSHIFT SWAP 8 CELLS R@ - RSHIFT ROT R>
>> LSHIFT OR ;
>>
>> : DRSHIFT >R DUP R@ RSHIFT SWAP 8 CELLS R@ - LSHIFT ROT R>
>> RSHIFT OR SWAP ;
>>
>> 0 4 d. 17179869184 ok
>> 0 4 0 drshift d. 17179869188 ok
>>
>> 4 0 d. 4 ok
>> 4 0 0 dlshift d. 17179869188 ok
>>
>
> Good catch! Shifting over 8 CELLS is an ambiguous condition.
> insert
> DUP 0= IF EXIT THEN
> in front of the code.

That handles the specific case '0 shift' but the ambiguous condition
you mention arises again here:

HEX
03 01 8 cells dlshift .( Expected: 00 03 Got: ) swap u. u. cr
FF 00 8 cells dlshift .( Expected: 00 FF Got: ) swap u. u. cr
00 01 8 cells drshift .( Expected: 01 00 Got: ) swap u. u. cr
00 FF 8 cells drshift .( Expected: FF 00 Got: ) swap u. u. cr
DECIMAL

Re: DLSHIFT and DRSHIFT

<feec42ecf39ae7c817e6b2a5fa051be7@www.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26661&group=comp.lang.forth#26661

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: mhx@iae.nl (mhx)
Newsgroups: comp.lang.forth
Subject: Re: DLSHIFT and DRSHIFT
Date: Sat, 13 Apr 2024 13:54:54 +0000
Organization: novaBBS
Message-ID: <feec42ecf39ae7c817e6b2a5fa051be7@www.novabbs.com>
References: <utvgki$2ciso$1@dont-email.me> <6613d195$1@news.ausics.net> <6614bbd1$1@news.ausics.net> <66188ab1$1@news.ausics.net> <nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5> <661a5369$1@news.ausics.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1049262"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Posting-User: 59549e76d0c3560fb37b97f0b9407a8c14054f24
X-Rslight-Site: $2y$10$2f0.zI2sNkQAbOKnUWm3S.Qi5KBvq6yLZC9h9cwiVA839l0sRV9bW
X-Spam-Checker-Version: SpamAssassin 4.0.0
 by: mhx - Sat, 13 Apr 2024 13:54 UTC

Krishna Myneni wrote:
[..]
> Just tested DLSHIFT and found weird things going on. Traced the problem
> to LSHIFT.
[..]
> 1 64 LSHIFT . \ expected to get zero
> 1 \ instead, got 1

> Then, I looked at the spec. for LSHIFT and, indeed, there is an
> ambiguous condition for u >= BITS_PER_CELL .

> 6.1.1805
> LSHIFT “l-shift”
> CORE
> ( x1 u – – x2 )
> Perform a logical left shift of u bit-places on x1, giving x2. Put
> zeroes into the least significant bits vacated by the shift. An
> ambiguous condition exists if u is greater than or equal to the number
> of bits in a cell.

Interesting. Apparently this was changed somewhere in
the course of time, as my local version of the spec. says:

LSHIFT CORE
( u1 u -- u2 )
Perform a logical shift of u bit-places on u1, giving u2. Shift the bits
n places toward the most significant bit. Put zero into the places
"uncovered" by the shift. When u is greater than or equal to the number
of bits in a cell, u2 wraps around.

Fortunately, this is exactly what AMD/Intel hardware does, and leads to

FORTH> 1 64 lshift . 1 ok

-marcel

Re: DLSHIFT and DRSHIFT

<uvf4h8$38hom$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26664&group=comp.lang.forth#26664

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: krishna.myneni@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: DLSHIFT and DRSHIFT
Date: Sat, 13 Apr 2024 18:29:42 -0500
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <uvf4h8$38hom$1@dont-email.me>
References: <utvgki$2ciso$1@dont-email.me> <6613d195$1@news.ausics.net>
<6614bbd1$1@news.ausics.net> <66188ab1$1@news.ausics.net>
<nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5> <661a5369$1@news.ausics.net>
<feec42ecf39ae7c817e6b2a5fa051be7@www.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 14 Apr 2024 01:29:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="803700620d26eb7e6561f16ec8e1ad58";
logging-data="3426070"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yNVBE52kpoHxwdXXBR1O8"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Zm4jB5h5hY2deAlSk6dMb19cKYE=
In-Reply-To: <feec42ecf39ae7c817e6b2a5fa051be7@www.novabbs.com>
Content-Language: en-US
 by: Krishna Myneni - Sat, 13 Apr 2024 23:29 UTC

On 4/13/24 08:54, mhx wrote:
> Krishna Myneni wrote:
> [..]
>> Just tested DLSHIFT and found weird things going on. Traced the
>> problem to LSHIFT.
> [..]
>> 1 64 LSHIFT .  \ expected to get zero
>> 1              \ instead, got 1
>
>> Then, I looked at the spec. for LSHIFT and, indeed, there is an
>> ambiguous condition for u >= BITS_PER_CELL .
>
>
>> 6.1.1805
>> LSHIFT “l-shift”
>> CORE
>> ( x1 u – – x2 )
>> Perform a logical left shift of u bit-places on x1, giving x2. Put
>> zeroes into the least significant bits vacated by the shift. An
>> ambiguous condition exists if u is greater than or equal to the number
>> of bits in a cell.
>
> Interesting. Apparently this was changed somewhere in
> the course of time, as my local version of the spec. says:
>
> LSHIFT                                                                 CORE
>     ( u1 u -- u2 )
>     Perform a logical shift of u bit-places on u1, giving u2. Shift the
> bits
>     n places toward the most significant bit. Put zero into the places
>     "uncovered" by the shift. When u is greater than or equal to the
> number
>     of bits in a cell, u2 wraps around.
>
> Fortunately, this is exactly what AMD/Intel hardware does, and leads to
>
> FORTH> 1 64 lshift . 1  ok
>
> -marcel

The spec for LSHIFT which I posted is the same as the one in Forth-94
(ANS Forth), so yours must have come from an earlier standard, or it
just mirrors the SHL instruction spec for x86/x86_64. IMO the language
spec shouldn't be tied to the behavior of a processor machine level
instruction on a specific processor family.

Also, I don't see what good a wrap-around shift is when u is greater
than or equal to the bits in a cell. In what algorithm would you use
such an operation? Bit operations such as a linear shift register where
the bits drop off in the direction of the shift, or a bit rotation
within a cell with an arbitrary number seem to be more useful.

--
Krishna

Re: DLSHIFT and DRSHIFT

<661b6354$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26667&group=comp.lang.forth#26667

  copy link   Newsgroups: comp.lang.forth
Date: Sun, 14 Apr 2024 15:02:13 +1000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <6613d195$1@news.ausics.net>
<6614bbd1$1@news.ausics.net> <66188ab1$1@news.ausics.net>
<nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5> <661a5369$1@news.ausics.net>
<feec42ecf39ae7c817e6b2a5fa051be7@www.novabbs.com>
Content-Language: en-GB
From: dxforth@gmail.com (dxf)
In-Reply-To: <feec42ecf39ae7c817e6b2a5fa051be7@www.novabbs.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <661b6354$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 35
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Sun, 14 Apr 2024 05:02 UTC

On 13/04/2024 11:54 pm, mhx wrote:
> Krishna Myneni wrote:
> [..]
>> Just tested DLSHIFT and found weird things going on. Traced the problem to LSHIFT.
> [..]
>> 1 64 LSHIFT .  \ expected to get zero
>> 1              \ instead, got 1
>
>> Then, I looked at the spec. for LSHIFT and, indeed, there is an ambiguous condition for u >= BITS_PER_CELL .
>
>
>> 6.1.1805
>> LSHIFT “l-shift”
>> CORE
>> ( x1 u – – x2 )
>> Perform a logical left shift of u bit-places on x1, giving x2. Put zeroes into the least significant bits vacated by the shift. An ambiguous condition exists if u is greater than or equal to the number of bits in a cell.
>
> Interesting. Apparently this was changed somewhere in
> the course of time, as my local version of the spec. says:
>
> LSHIFT                                                                 CORE
>     ( u1 u -- u2 )
>     Perform a logical shift of u bit-places on u1, giving u2. Shift the bits
>     n places toward the most significant bit. Put zero into the places
>     "uncovered" by the shift. When u is greater than or equal to the number
>     of bits in a cell, u2 wraps around.
>
> Fortunately, this is exactly what AMD/Intel hardware does, and leads to
>
> FORTH> 1 64 lshift . 1  ok

Unfortunate for the Intel 8086 and folks who expected a 0 result.

Re: DLSHIFT and DRSHIFT

<nnd$4083d04a$4b16de1d@a0cd55e93bc8e117>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26672&group=comp.lang.forth#26672

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: DLSHIFT and DRSHIFT
References: <utvgki$2ciso$1@dont-email.me> <66188ab1$1@news.ausics.net> <nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5> <661a5369$1@news.ausics.net>
From: albert@spenarnc.xs4all.nl
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$4083d04a$4b16de1d@a0cd55e93bc8e117>
Organization: KPN B.V.
Date: Sun, 14 Apr 2024 13:06:12 +0200
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 54
Injection-Date: Sun, 14 Apr 2024 13:06:12 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: albert@spenarnc.xs4all.nl - Sun, 14 Apr 2024 11:06 UTC

In article <661a5369$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
>On 12/04/2024 6:27 pm, albert@spenarnc.xs4all.nl wrote:
>> In article <66188ab1$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
>>> On 12/04/2024 1:11 am, albert@spenarnc.xs4all.nl wrote:
>>>>
>>>> While others indulge in endless discussions about DRSHIFT
>>>> I thought to attempt some literate programming.
>>>
>>> It didn't prompt you to test your own implementation?
>>>
>>> ( D0= D0<> D0< D= D< D- M+ DRSHIFT DLSHIFT DU< ) \ AvdH B6Mar22
>>>
>>> : DLSHIFT >R SWAP DUP R@ LSHIFT SWAP 8 CELLS R@ - RSHIFT ROT R>
>>> LSHIFT OR ;
>>>
>>> : DRSHIFT >R DUP R@ RSHIFT SWAP 8 CELLS R@ - LSHIFT ROT R>
>>> RSHIFT OR SWAP ;
>>>
>>> 0 4 d. 17179869184 ok
>>> 0 4 0 drshift d. 17179869188 ok
>>>
>>> 4 0 d. 4 ok
>>> 4 0 0 dlshift d. 17179869188 ok
>>>
>>
>> Good catch! Shifting over 8 CELLS is an ambiguous condition.
>> insert
>> DUP 0= IF EXIT THEN
>> in front of the code.
>
>That handles the specific case '0 shift' but the ambiguous condition
>you mention arises again here:
>
>HEX
>03 01 8 cells dlshift .( Expected: 00 03 Got: ) swap u. u. cr
>FF 00 8 cells dlshift .( Expected: 00 FF Got: ) swap u. u. cr
>00 01 8 cells drshift .( Expected: 01 00 Got: ) swap u. u. cr
>00 FF 8 cells drshift .( Expected: FF 00 Got: ) swap u. u. cr
>DECIMAL

You are right. Totally annoyed with this. Changed the library to

: DLSHIFT 0 ?DO 2DUP D+ LOOP ;

: DRSHIFT 0 ?DO 2 UDM/MOD ROT DROP LOOP ;

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring. - the Wise from Antrim -

Re: DLSHIFT and DRSHIFT

<nnd$7329c8e7$6f162acb@cfb62c92dfcdd85c>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26750&group=comp.lang.forth#26750

  copy link   Newsgroups: comp.lang.forth
Date: Sun, 21 Apr 2024 16:11:24 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: DLSHIFT and DRSHIFT
Newsgroups: comp.lang.forth
References: <utvgki$2ciso$1@dont-email.me> <66188ab1$1@news.ausics.net>
<nnd$203ed82f$4df54a42@7ca86a72b6ce8cf5> <661a5369$1@news.ausics.net>
<nnd$4083d04a$4b16de1d@a0cd55e93bc8e117>
Content-Language: en-US
From: the.beez.speaks@gmail.com (Hans Bezemer)
In-Reply-To: <nnd$4083d04a$4b16de1d@a0cd55e93bc8e117>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$7329c8e7$6f162acb@cfb62c92dfcdd85c>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe006.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 68
Injection-Date: Sun, 21 Apr 2024 16:11:24 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Hans Bezemer - Sun, 21 Apr 2024 14:11 UTC

On 14-04-2024 13:06, albert@spenarnc.xs4all.nl wrote:
> In article <661a5369$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
>> On 12/04/2024 6:27 pm, albert@spenarnc.xs4all.nl wrote:
>>> In article <66188ab1$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
>>>> On 12/04/2024 1:11 am, albert@spenarnc.xs4all.nl wrote:
>>>>>
>>>>> While others indulge in endless discussions about DRSHIFT
>>>>> I thought to attempt some literate programming.
>>>>
>>>> It didn't prompt you to test your own implementation?
>>>>
>>>> ( D0= D0<> D0< D= D< D- M+ DRSHIFT DLSHIFT DU< ) \ AvdH B6Mar22
>>>>
>>>> : DLSHIFT >R SWAP DUP R@ LSHIFT SWAP 8 CELLS R@ - RSHIFT ROT R>
>>>> LSHIFT OR ;
>>>>
>>>> : DRSHIFT >R DUP R@ RSHIFT SWAP 8 CELLS R@ - LSHIFT ROT R>
>>>> RSHIFT OR SWAP ;
>>>>
>>>> 0 4 d. 17179869184 ok
>>>> 0 4 0 drshift d. 17179869188 ok
>>>>
>>>> 4 0 d. 4 ok
>>>> 4 0 0 dlshift d. 17179869188 ok
>>>>
>>>
>>> Good catch! Shifting over 8 CELLS is an ambiguous condition.
>>> insert
>>> DUP 0= IF EXIT THEN
>>> in front of the code.
>>
>> That handles the specific case '0 shift' but the ambiguous condition
>> you mention arises again here:
>>
>> HEX
>> 03 01 8 cells dlshift .( Expected: 00 03 Got: ) swap u. u. cr
>> FF 00 8 cells dlshift .( Expected: 00 FF Got: ) swap u. u. cr
>> 00 01 8 cells drshift .( Expected: 01 00 Got: ) swap u. u. cr
>> 00 FF 8 cells drshift .( Expected: FF 00 Got: ) swap u. u. cr
>> DECIMAL

Sure, I had to adapt it a bit: 4tH is segmented, so 1 CELLS renders 1.
[HEX] only works at compile time, so HEX is added to allow for runtime
behavior. And sure, not all of this stuff is core, so some libs are
added as well.

include lib/dbldot.4th \ if you insist..
include lib/dshift.4th \ identical to routine posted on c.l.f.

[HEX] HEX
03 01 8 /cell * dlshift .( Expected: 00 03 Got: ) swap u. u. cr
FF 00 8 /cell * dlshift .( Expected: 00 FF Got: ) swap u. u. cr
00 01 8 /cell * drshift .( Expected: 01 00 Got: ) swap u. u. cr
00 FF 8 /cell * drshift .( Expected: FF 00 Got: ) swap u. u. cr
[DECIMAL] DECIMAL

But it's rock solid:

$ pp4th -x clfdrshift.4th
Expected: 00 03 Got: 0 3
Expected: 00 FF Got: 0 FF
Expected: 01 00 Got: 1 0
Expected: FF 00 Got: FF 0

Hans Bezemer

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor