Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

24 Apr, 2024: Testing a new version of the Overboard here. If you have an issue post about it to rocksolid.nodes.help (I know. Everyone on Usenet has issues)


devel / comp.lang.forth / Re: Compiling string literals (was: Show human-readable time)

SubjectAuthor
* Show human-readable timePaul Rubin
+* Re: Show human-readable timePaul Rubin
|`* Re: Show human-readable timedxforth
| `* Re: Show human-readable timePaul Rubin
|  +* Re: Show human-readable timedxforth
|  |`* Re: Show human-readable timeHans Bezemer
|  | `* Re: Show human-readable timedxforth
|  |  `* Re: Show human-readable timeHans Bezemer
|  |   `* Re: Show human-readable timedxforth
|  |    `- Re: Show human-readable timeHans Bezemer
|  `* Re: Show human-readable timeAnton Ertl
|   +* Re: Show human-readable timePaul Rubin
|   |+- Re: Show human-readable timedxforth
|   |+* Re: Show human-readable timeAnton Ertl
|   ||+- Re: Show human-readable timedxforth
|   ||+* Re: Show human-readable timePaul Rubin
|   |||`* Re: Show human-readable timeAnton Ertl
|   ||| `* Re: Show human-readable timePaul Rubin
|   |||  `* Re: Show human-readable timeAnton Ertl
|   |||   `- Re: Show human-readable timeS Jack
|   ||`* Re: Show human-readable timePaul Rubin
|   || `- Re: Show human-readable timeAnton Ertl
|   |`* Re: Show human-readable timeBrian Fox
|   | +* Re: Show human-readable timeAnton Ertl
|   | |`- Re: Show human-readable timeBrian Fox
|   | +* Re: Show human-readable timedxforth
|   | |+* Re: Show human-readable timeAnton Ertl
|   | ||+* Re: Show human-readable timeS Jack
|   | |||+- Re: Show human-readable timedxforth
|   | |||`* Re: Show human-readable timeAnton Ertl
|   | ||| `* Re: Show human-readable timeS Jack
|   | |||  `* Re: Show human-readable timeS Jack
|   | |||   `- Re: Show human-readable timeS Jack
|   | ||`* Compiling string literals (was: Show human-readable time)Ruvim
|   | || `- Re: Compiling string literals (was: Show human-readable time)Anton Ertl
|   | |`* Re: Show human-readable timeS Jack
|   | | `* Re: Show human-readable timedxforth
|   | |  `* Re: Show human-readable timeS Jack
|   | |   `- Re: Show human-readable timedxforth
|   | `* Re: Show human-readable timePaul Rubin
|   |  +- Re: Show human-readable timeBrian Fox
|   |  `- Re: Show human-readable timedxforth
|   `* Re: Show human-readable timePaul Rubin
|    `- Re: Show human-readable timeBranimir Maksimovic
`- Re: Show human-readable timeS Jack

Pages:12
Re: Show human-readable time

<684bf042-6e5c-4888-8173-69e7a8a02cccn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14756&group=comp.lang.forth#14756

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:a54c:: with SMTP id o73mr17231292qke.334.1632596568319;
Sat, 25 Sep 2021 12:02:48 -0700 (PDT)
X-Received: by 2002:ad4:47a3:: with SMTP id a3mr16769018qvz.31.1632596568153;
Sat, 25 Sep 2021 12:02:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 25 Sep 2021 12:02:47 -0700 (PDT)
In-Reply-To: <sim0bd$fcq$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:7474:b969:d10:df82;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:7474:b969:d10:df82
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <684bf042-6e5c-4888-8173-69e7a8a02cccn@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Sat, 25 Sep 2021 19:02:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: S Jack - Sat, 25 Sep 2021 19:02 UTC

On Friday, September 24, 2021 at 9:08:49 PM UTC-5, dxforth wrote:
> The bigger annoyance is code alignment which some implementations
> put into ," etc instead of handling it separately. ," is a really
> handy function for compiling string constant data; but with
> implementations that variously align, null-terminate and others
> that don't, standardization becomes impossible.

Agree. Caught myself doing that but fixed it:
anew cobble ok
here ," abc" here ," defgh" here ," ij" cr rot tell swap tell tell
abcdefghij ok
--
me

Re: Show human-readable time

<614F9E17.900@rogers.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14757&group=comp.lang.forth#14757

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: brian....@rogers.com (Brian Fox)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Sat, 25 Sep 2021 18:09:27 -0400
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <614F9E17.900@rogers.com>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com> <sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com> <2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com> <614DD60B.3080602@rogers.com> <8735psqyj2.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="1875993c11084824bd29ccca80490aa5";
logging-data="14856"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sDHmHHXKwGNJFHcYVpXxIr+EZ+//KoRg="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
Cancel-Lock: sha1:ZcoexHT3a/uzFQ9WOnmjc4h2F/Y=
In-Reply-To: <8735psqyj2.fsf@nightsong.com>
 by: Brian Fox - Sat, 25 Sep 2021 22:09 UTC

On 2021-09-25 2:51 PM, Paul Rubin wrote:
> Brian Fox <brian.fox@rogers.com> writes:
>> : (S") ( -- c-addr u) R> COUNT 2DUP + ALIGNED >R ;
>
> This is both awesome and terrifying.
>

That made me laugh out loud. :-))
Ya Forth has a few of those.

"Are you nuts? I can't just put things on the hardware stack!"

Re: Show human-readable time

<sioprj$8sf$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14758&group=comp.lang.forth#14758

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Sun, 26 Sep 2021 13:36:20 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sioprj$8sf$1@gioia.aioe.org>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<684bf042-6e5c-4888-8173-69e7a8a02cccn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="9103"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sun, 26 Sep 2021 03:36 UTC

On 26/09/2021 05:02, S Jack wrote:
> On Friday, September 24, 2021 at 9:08:49 PM UTC-5, dxforth wrote:
>> The bigger annoyance is code alignment which some implementations
>> put into ," etc instead of handling it separately. ," is a really
>> handy function for compiling string constant data; but with
>> implementations that variously align, null-terminate and others
>> that don't, standardization becomes impossible.
>
> Agree. Caught myself doing that but fixed it:
> anew cobble ok
> here ," abc" here ," defgh" here ," ij" cr rot tell swap tell tell
> abcdefghij ok

Unsure what tell does but a test showing the differences might be:

: show ( a n ) 0 ?do count 2dup type + loop drop ;

here ," a" ," bc" ," def" ," ghij" cr 4 show

abcdefghij ok

Trying to find the origin of ," the earliest I've been able to place
it is Laxen/Perry F83; which defined it as:

: ," (S -- )
ASCII " PARSE TUCK 'WORD PLACE 1+ ALLOT ALIGN ;

In L&P 'WORD defaulted to HERE and ALIGN defaulted to NOOP. Given
that definition it's no surprise others copied the alignment.
," was a factor of ." and " and while it could potentially be used
for other things there's no indication L&P ever did.

In his first PC forth, Tom Zimmer copied the L&P definition verbatim
but in F-PC reduced it to:

: ," ( -- )
ASCII " PARSE TUCK HERE PLACE 1+ ALLOT ;

Wil Baden did the same for his 2002 toolkit:

: STRING, ( str len -- )
HERE over 1+ chars ALLOT PLACE ;

: ," [char] " PARSE STRING, ; IMMEDIATE

Re: Show human-readable time

<sip1a9$97k$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14759&group=comp.lang.forth#14759

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Sun, 26 Sep 2021 15:43:37 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sip1a9$97k$1@gioia.aioe.org>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <8735psqyj2.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="9460"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sun, 26 Sep 2021 05:43 UTC

On 26/09/2021 04:51, Paul Rubin wrote:
> Brian Fox <brian.fox@rogers.com> writes:
>> : (S") ( -- c-addr u) R> COUNT 2DUP + ALIGNED >R ;
>
> This is both awesome and terrifying.
>

Inlining data was a common technique back in the day. This example from
Borland's CP/M Turbo Pascal compiler which outputs 2 bytes representing
the POP IY instruction and automatically skipping over it:

CALL CmpOutCopy
DEFB 2
POP IY
...

Re: Show human-readable time

<96ce7777-02b9-4509-8121-a2a9b10fb495n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14760&group=comp.lang.forth#14760

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:610:: with SMTP id z16mr16941019qta.101.1632709918572;
Sun, 26 Sep 2021 19:31:58 -0700 (PDT)
X-Received: by 2002:ad4:5541:: with SMTP id v1mr21830547qvy.49.1632709918405;
Sun, 26 Sep 2021 19:31:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 26 Sep 2021 19:31:58 -0700 (PDT)
In-Reply-To: <sioprj$8sf$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:902:de73:8c4b:26a3;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:902:de73:8c4b:26a3
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<684bf042-6e5c-4888-8173-69e7a8a02cccn@googlegroups.com> <sioprj$8sf$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <96ce7777-02b9-4509-8121-a2a9b10fb495n@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Mon, 27 Sep 2021 02:31:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: S Jack - Mon, 27 Sep 2021 02:31 UTC

On Saturday, September 25, 2021 at 10:36:21 PM UTC-5, dxforth wrote:
> Unsure what tell does but a test showing the differences might be:
>
: TELL COUNT TYPE ;
But your right; my example didn't show anything.
(In habit of seeing the code that doesn't show.)

Here's the Fig definition for compiling a counted string outside a
definition:

: ," ASCII " WORD C@ 1+ ALLOT ; IMMEDIATE

The Fig WORD already moved the counted string to HERE so only needed to
bump count by one and allot. And NO alignment done.

However, a counted string compiled inside a definition is aligned and preceded by a
word that will return to the first cell beyond the string. But the string count is not
altered by the alignment. Alignment bytes are NOT included in the string count.

: S, COUNT TUCK HERE SWAP CMOVE ALLOT ; \ compile counted string content
: FOO "FOO::" ;
: BAR "BAR" ;

HERE FOO S, BAR S,
HERE OVER - TYPE \. FOO::BAR (adjacent text)

Primary words compiling data (or text) outside a definition need not align.
Alignment can be dealt with when needed.

Re: Show human-readable time

<d32b044b-f26d-4c5f-8df3-bb17e2c29746n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14761&group=comp.lang.forth#14761

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:409:: with SMTP id 9mr22596790qkp.76.1632714031719;
Sun, 26 Sep 2021 20:40:31 -0700 (PDT)
X-Received: by 2002:ac8:4243:: with SMTP id r3mr16708070qtm.187.1632714031565;
Sun, 26 Sep 2021 20:40:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 26 Sep 2021 20:40:31 -0700 (PDT)
In-Reply-To: <2021Sep25.084456@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:902:de73:8c4b:26a3;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:902:de73:8c4b:26a3
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<2021Sep24.094110@mips.complang.tuwien.ac.at> <877df6aqwm.fsf@nightsong.com>
<2021Sep24.183924@mips.complang.tuwien.ac.at> <87y27lddml.fsf@nightsong.com> <2021Sep25.084456@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d32b044b-f26d-4c5f-8df3-bb17e2c29746n@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Mon, 27 Sep 2021 03:40:31 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: S Jack - Mon, 27 Sep 2021 03:40 UTC

On Saturday, September 25, 2021 at 1:49:22 AM UTC-5, Anton Ertl wrote:
> No. The string is put into the next section, and its address is then
> compiled with LITERAL:

No real magic in sections. The magic is having the string compiled outside the
definition:

HERE ," Hello WORLD " tmp!
: FOO [ tmp@ ] LITERAL COUNT TYPE ;
FOO \. Hello WORLD
--
me

Re: Show human-readable time

<sireib$9o7$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14762&group=comp.lang.forth#14762

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Mon, 27 Sep 2021 13:42:03 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sireib$9o7$1@gioia.aioe.org>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<684bf042-6e5c-4888-8173-69e7a8a02cccn@googlegroups.com>
<sioprj$8sf$1@gioia.aioe.org>
<96ce7777-02b9-4509-8121-a2a9b10fb495n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="9991"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 27 Sep 2021 03:42 UTC

On 27/09/2021 12:31, S Jack wrote:
> On Saturday, September 25, 2021 at 10:36:21 PM UTC-5, dxforth wrote:
>> Unsure what tell does but a test showing the differences might be:
>>
> : TELL COUNT TYPE ;
> But your right; my example didn't show anything.
> (In habit of seeing the code that doesn't show.)
>
> Here's the Fig definition for compiling a counted string outside a
> definition:
>
> : ," ASCII " WORD C@ 1+ ALLOT ; IMMEDIATE
>
> The Fig WORD already moved the counted string to HERE so only needed to
> bump count by one and allot. And NO alignment done.
>
> However, a counted string compiled inside a definition is aligned and preceded by a
> word that will return to the first cell beyond the string. But the string count is not
> altered by the alignment. Alignment bytes are NOT included in the string count.
>
> : S, COUNT TUCK HERE SWAP CMOVE ALLOT ; \ compile counted string content
> : FOO "FOO::" ;
> : BAR "BAR" ;
>
> HERE FOO S, BAR S,
> HERE OVER - TYPE \. FOO::BAR (adjacent text)
>
> Primary words compiling data (or text) outside a definition need not align.
> Alignment can be dealt with when needed.

Unfortunately such things were considered too late - if at all. Whereas most
languages were designed upfront (aka Intelligent Design), Forth seems to have
opted for the Blind Watchmaker route.

Re: Show human-readable time

<062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14767&group=comp.lang.forth#14767

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:816b:: with SMTP id 98mr1528766qvc.37.1632772360353;
Mon, 27 Sep 2021 12:52:40 -0700 (PDT)
X-Received: by 2002:a37:9eca:: with SMTP id h193mr1768753qke.127.1632772360197;
Mon, 27 Sep 2021 12:52:40 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 27 Sep 2021 12:52:39 -0700 (PDT)
In-Reply-To: <2021Sep25.184814@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:18b2:3f06:699e:8f43;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:18b2:3f06:699e:8f43
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org> <2021Sep25.184814@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Mon, 27 Sep 2021 19:52:40 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 29
 by: S Jack - Mon, 27 Sep 2021 19:52 UTC

On Saturday, September 25, 2021 at 11:52:25 AM UTC-5, Anton Ertl wrote:
> dxforth <dxf...@gmail.com> writes:
> >On 24/09/2021 23:43, Brian Fox wrote:
> >> : (S") ( -- c-addr u) R> COUNT 2DUP + ALIGNED >R ;
> ...
> However, this technique incurs a branch misprediction (~20 cycles) on
> return from (S"), so I don't recommend it for native-code systems.
> - anton
> --
Sounds like you're saying:

"any(?) word that modifies its return address will entail a
processor penalty"

Do this include words like LITERAL , as commonly built, that
fetches the compiled value at its return address and then increments its
return address past the compiled value. Or does the modification need
to be greater than some length to be penalized? So jumping around
a single cell is ok but jumping across a string is too much.

Should any return address modification entail a penalty would be an
argument for a third stack, the RACK, for saved data thereby
alleviating return address modifications not having data to branch
around.

If literals are ok and its only a problem with long jumps around strings,
then moving strings out of definitions, such as your use of sections
or by other means, would suffice.
--
me

Re: Show human-readable time

<siu389$p5u$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14771&group=comp.lang.forth#14771

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Tue, 28 Sep 2021 13:47:20 +1000
Organization: Aioe.org NNTP Server
Message-ID: <siu389$p5u$1@gioia.aioe.org>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<2021Sep25.184814@mips.complang.tuwien.ac.at>
<062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="25790"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 28 Sep 2021 03:47 UTC

On 28/09/2021 05:52, S Jack wrote:
> On Saturday, September 25, 2021 at 11:52:25 AM UTC-5, Anton Ertl wrote:
>> dxforth <dxf...@gmail.com> writes:
>> >On 24/09/2021 23:43, Brian Fox wrote:
>> >> : (S") ( -- c-addr u) R> COUNT 2DUP + ALIGNED >R ;
>> ...
>> However, this technique incurs a branch misprediction (~20 cycles) on
>> return from (S"), so I don't recommend it for native-code systems.
>> - anton
>> --
> Sounds like you're saying:
>
> "any(?) word that modifies its return address will entail a
> processor penalty"
>
> Do this include words like LITERAL , as commonly built, that
> fetches the compiled value at its return address and then increments its
> return address past the compiled value. Or does the modification need
> to be greater than some length to be penalized? So jumping around
> a single cell is ok but jumping across a string is too much.
>
> Should any return address modification entail a penalty would be an
> argument for a third stack, the RACK, for saved data thereby
> alleviating return address modifications not having data to branch
> around.
>
> If literals are ok and its only a problem with long jumps around strings,
> then moving strings out of definitions, such as your use of sections
> or by other means, would suffice.

Is it a problem? If inline strings occur infrequently and their
destination is a device, where is the gain? Moving inline strings
to sections is unlikely to have much impact AFAICS. OTOH if one
had sections for other reasons, no harm using it.

Re: Show human-readable time

<2021Sep28.133223@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14773&group=comp.lang.forth#14773

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Tue, 28 Sep 2021 11:32:23 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 46
Message-ID: <2021Sep28.133223@mips.complang.tuwien.ac.at>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com> <sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com> <2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com> <614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org> <2021Sep25.184814@mips.complang.tuwien.ac.at> <062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="09f15a22341798cc2879755d48d25938";
logging-data="17137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nOWYUCQ1kNskuGsqdupgw"
Cancel-Lock: sha1:UfC/J+Sd5xKoy+K/u5JrR+NrnoI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Tue, 28 Sep 2021 11:32 UTC

S Jack <sdwjack69@gmail.com> writes:
>On Saturday, September 25, 2021 at 11:52:25 AM UTC-5, Anton Ertl wrote:
>> dxforth <dxf...@gmail.com> writes:
>> >On 24/09/2021 23:43, Brian Fox wrote:
>> >> : (S") ( -- c-addr u) R> COUNT 2DUP + ALIGNED >R ;
>> ...
>> However, this technique incurs a branch misprediction (~20 cycles) on
>> return from (S"), so I don't recommend it for native-code systems.
>> - anton
>> --
>Sounds like you're saying:
>
>"any(?) word that modifies its return address will entail a
> processor penalty"

Pretty much, yes.

>Do this include words like LITERAL , as commonly built, that
>fetches the compiled value at its return address and then increments its
>return address past the compiled value.

Yes.

>Or does the modification need
>to be greater than some length to be penalized?

No.

The CPU predicts that the return will return reght behind the call.
If it returns elsewhere, there is a misprediction.

>Should any return address modification entail a penalty would be an
>argument for a third stack, the RACK, for saved data thereby
>alleviating return address modifications not having data to branch
>around.

I don't see how that would help for SLITERAL or LITERAL. Pushing
something on the processor stack in the meantime and popping it is
fine, as long as you return right behind the corresponding call.

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

Re: Show human-readable time

<5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14775&group=comp.lang.forth#14775

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:1321:: with SMTP id c1mr6483074qvv.43.1632844538328;
Tue, 28 Sep 2021 08:55:38 -0700 (PDT)
X-Received: by 2002:ac8:5ed1:: with SMTP id s17mr6425278qtx.196.1632844537913;
Tue, 28 Sep 2021 08:55:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 28 Sep 2021 08:55:37 -0700 (PDT)
In-Reply-To: <sijitf$4e1$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com> <sijitf$4e1$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com>
Subject: Re: Show human-readable time
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Tue, 28 Sep 2021 15:55:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 37
 by: Hans Bezemer - Tue, 28 Sep 2021 15:55 UTC

On Friday, September 24, 2021 at 6:07:13 AM UTC+2, dxforth wrote:
One thing is for sure: when coded in 4tH is much more concise. I must admit I changed the functionality a bit - this one leaves two transient strings. Obviously, it is a routine to build others with. E.g. one could add a small thingy that concats both strings, types 'em, make them part of a printf() like routine, etc. Same goes for capitalization.

If somebody goes nitpicking - yes, it uses one of 4tH's libs - if you really need the definition of S/HOUR either ask your kindergarten teacher or be just nice. I'll tell you.

include lib/time.4th

create hours
," twelve" ," one" ," two" ," three"
," four" ," five" ," six" ," seven"
," eight" ," nine" ," ten" ," eleven"
does> swap 12 mod th @c count ;

create minutes
," o'clock" ," five after"
," ten after" ," quarter past"
," twenty after" ," twenty-five after"
," half past" ," twenty-five til"
," twenty til" ," quarter til"
," ten til" ," five til"
does> swap th @c count ;

: s>str ( s -- a1 n1 a2 n2 )
150 + s/hour /mod hours 2>r
s/min / 5 / dup minutes rot 2r> rot if 2swap then
;

: smh>str smh>s s>str ; ( s m h -- a1 n1 a2 n2 )

aka smh>str time>str

Hans Bezemer

Re: Show human-readable time

<bd3c3577-684a-4101-8a0c-2cce070fc3d5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14777&group=comp.lang.forth#14777

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5290:: with SMTP id s16mr9062820qtn.412.1632879600362;
Tue, 28 Sep 2021 18:40:00 -0700 (PDT)
X-Received: by 2002:ac8:151:: with SMTP id f17mr8856964qtg.313.1632879600189;
Tue, 28 Sep 2021 18:40:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 28 Sep 2021 18:39:59 -0700 (PDT)
In-Reply-To: <5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=159.196.67.16; posting-account=tfMFDAoAAAD6y9UWRGYtWxg7698MXMQI
NNTP-Posting-Host: 159.196.67.16
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<sijitf$4e1$1@gioia.aioe.org> <5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bd3c3577-684a-4101-8a0c-2cce070fc3d5n@googlegroups.com>
Subject: Re: Show human-readable time
From: dxfo...@gmail.com (dxforth)
Injection-Date: Wed, 29 Sep 2021 01:40:00 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: dxforth - Wed, 29 Sep 2021 01:39 UTC

On Wednesday, September 29, 2021 at 1:55:39 AM UTC+10, the.bee...@gmail.com wrote:
> One thing is for sure: when coded in 4tH is much more concise.

I assume that's due to 4tH hiding the mechanics. AFAICS compiling a string in 4tH
amounts to compiling a reference to it (the string itself goes into a different section) ?

Re: Show human-readable time

<9ab7b4bb-24b8-4953-89d6-103610eab6aan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14779&group=comp.lang.forth#14779

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:ba06:: with SMTP id k6mr3325038qkf.312.1632885103176;
Tue, 28 Sep 2021 20:11:43 -0700 (PDT)
X-Received: by 2002:a37:ba06:: with SMTP id k6mr3325030qkf.312.1632885103019;
Tue, 28 Sep 2021 20:11:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 28 Sep 2021 20:11:42 -0700 (PDT)
In-Reply-To: <2021Sep28.133223@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:98f7:21be:25f5:df13;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:98f7:21be:25f5:df13
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<2021Sep25.184814@mips.complang.tuwien.ac.at> <062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com>
<2021Sep28.133223@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9ab7b4bb-24b8-4953-89d6-103610eab6aan@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Wed, 29 Sep 2021 03:11:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: S Jack - Wed, 29 Sep 2021 03:11 UTC

On Tuesday, September 28, 2021 at 6:39:11 AM UTC-5, Anton Ertl wrote:

>The CPU predicts that the return will return reght behind the call.
>If it returns elsewhere, there is a misprediction.

If a value does not entail a penalty, then a headless value could
be used in place of LITERAL (disregarding compliance):

\ XVAL ( x -- XT )
\ Headless value
\ Compile a value holding x and returns the XT of the value.

Also make use of a compiling register:
: %R:
CREATE IMMEDIATE 0 , \ space to hold an XT
DOES> COMPILE, ; \ compile the held XT
%R: %R1
(And IS is modified to accept compiling register as valid target)

HERE ," Hello World!" XVAL is %R1
: foo %R1 COUNT TYPE ;

The string address is compiled in a headless value by XVAL .
The XT of the headless value gets compiled into FOO by means
of the compiling register %R1 .

Not compliant but simple constructs with no impact on FORGET
and MARKER .

The same can be applied to a :NONAME phrase:

:NONAME .... ; is %R1
: FOO ... %R1 ... ; \ effectively a quotation

If want to catch/throw the pesudo-quotation then use combination
:NONAME and XVAL :

:NONAME ... ; XVAL is %R1
: FOO ... %R1 catch ... ;
--
me

Re: Show human-readable time

<95936a59-6c5b-4fcd-ad6b-78ad7d9bead2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14783&group=comp.lang.forth#14783

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:484:: with SMTP id 4mr2415956qkr.409.1632922466893; Wed, 29 Sep 2021 06:34:26 -0700 (PDT)
X-Received: by 2002:ac8:7948:: with SMTP id r8mr12200013qtt.360.1632922466427; Wed, 29 Sep 2021 06:34:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 29 Sep 2021 06:34:26 -0700 (PDT)
In-Reply-To: <bd3c3577-684a-4101-8a0c-2cce070fc3d5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com> <sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com> <sijitf$4e1$1@gioia.aioe.org> <5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com> <bd3c3577-684a-4101-8a0c-2cce070fc3d5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <95936a59-6c5b-4fcd-ad6b-78ad7d9bead2n@googlegroups.com>
Subject: Re: Show human-readable time
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 29 Sep 2021 13:34:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 32
 by: Hans Bezemer - Wed, 29 Sep 2021 13:34 UTC

On Wednesday, September 29, 2021 at 3:40:01 AM UTC+2, dxforth wrote:
> On Wednesday, September 29, 2021 at 1:55:39 AM UTC+10, the.bee...@gmail.com wrote:
> > One thing is for sure: when coded in 4tH is much more concise.
> I assume that's due to 4tH hiding the mechanics. AFAICS compiling a string in 4tH
> amounts to compiling a reference to it (the string itself goes into a different section) ?
You're completely correct. The reference goes into the Code Segment (R/O), the string itself in the String Segment (R/O). When fetched with @C it returns an address in the Character Segment (R/W) where the temporary string has been copied to.

Another thing is the interpretation semantics of DOES> - but you can do the same thing with gForth too AFAIK. You can port the whole shebang to vanilla Forth using this routine:

[DEFINED] /STRING-SPACE [IF]
( Reserve STRING-SPACE in data-space )
CREATE STRING-SPACE /STRING-SPACE CHARS ALLOT
VARIABLE NEXT-STRING 0 NEXT-STRING !
( " ccc" -- caddr )
: (S,) PARSE
DUP 1+ NEXT-STRING @ + /STRING-SPACE >
ABORT" String space exhausted"
STRING-SPACE NEXT-STRING @ CHARS + >R
DUP 1+ NEXT-STRING +!
R@ PLACE
R> ,
;

: ," [CHAR] " (S,) ; \ 4TH
: ,| [CHAR] | (S,) ; \ 4TH
[ELSE]
..( Warning: ," undefined, needs /STRING-SPACE) CR
[THEN]

Don't forget to define /STRING-SPACE, though.

Hans Bezemer

Re: Show human-readable time

<b480dd4e-52e5-4321-bd67-0dd7aaa20fe7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14785&group=comp.lang.forth#14785

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2544:: with SMTP id s4mr458463qko.219.1632930839034;
Wed, 29 Sep 2021 08:53:59 -0700 (PDT)
X-Received: by 2002:a37:9581:: with SMTP id x123mr440762qkd.477.1632930838824;
Wed, 29 Sep 2021 08:53:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 29 Sep 2021 08:53:58 -0700 (PDT)
In-Reply-To: <9ab7b4bb-24b8-4953-89d6-103610eab6aan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:24c6:3ed4:7983:bdb9;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:24c6:3ed4:7983:bdb9
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<2021Sep25.184814@mips.complang.tuwien.ac.at> <062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com>
<2021Sep28.133223@mips.complang.tuwien.ac.at> <9ab7b4bb-24b8-4953-89d6-103610eab6aan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b480dd4e-52e5-4321-bd67-0dd7aaa20fe7n@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Wed, 29 Sep 2021 15:53:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 41
 by: S Jack - Wed, 29 Sep 2021 15:53 UTC

On Tuesday, September 28, 2021 at 10:11:44 PM UTC-5, S Jack wrote:
> On Tuesday, September 28, 2021 at 6:39:11 AM UTC-5, Anton Ertl wrote:
>
> >The CPU predicts that the return will return reght behind the call.
> >If it returns elsewhere, there is a misprediction.
> If a value does not entail a penalty, then a headless value could
> be used in place of LITERAL (disregarding compliance):

Another way that will work in a Fig Forth is to use PARM to pass
parameters to a definition. PARM makes use of Fig's compiler security
variable CSP which has the data stack location at the beginning of a
colon definition.

\ XVAL ( x -- XT )
\ Headless value
\ Compile x as a headless value, returns XT of the value.
: XVAL ALIGN DOVAL , HERE SWAP , ;

\ PARM ( n -- )
\ Compiling word
\ Compile the nth parameter that was on the data stack
\ at the beginning of a colon definition
\ Note: The n value is normally placed in brackets as it
\ needs to be used at compile time.
: PARM CELLS CSP @ + @ COMPILE, ; IMMEDIATE

HERE ," Hello World!" XVAL
: FOO [ 0 ] PARM COUNT TYPE ;
CR FOO \ Hello World!

HERE ," BOO " XVAL
:NONAME [ 1 ] PARM COUNT TYPE ;
: BAR [ 0 ] PARM ;
CR BAR \ BOO

HERE ," BATS" XVAL
:NONAME [ 1 ] PARM COUNT TYPE ; XVAL
HERE ," &CATS" XVAL
: KOO [ 1 ] PARM CATCH THROW [ 0 ] PARM COUNT TYPE ;
CR KOO \ BATS&CATS
--
me

Re: Show human-readable time

<sj5crf$4rm$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14788&group=comp.lang.forth#14788

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Show human-readable time
Date: Fri, 1 Oct 2021 08:14:07 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sj5crf$4rm$1@gioia.aioe.org>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<sijitf$4e1$1@gioia.aioe.org>
<5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com>
<bd3c3577-684a-4101-8a0c-2cce070fc3d5n@googlegroups.com>
<95936a59-6c5b-4fcd-ad6b-78ad7d9bead2n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="4982"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 30 Sep 2021 22:14 UTC

On 29/09/2021 23:34, Hans Bezemer wrote:
>
> The reference goes into the Code Segment (R/O), the string
> itself in the String Segment (R/O). When fetched with @C it returns an address in the
> Character Segment (R/W) where the temporary string has been copied to.
>
> Another thing is the interpretation semantics of DOES> - but you can do the same thing
> with gForth too AFAIK. You can port the whole shebang to vanilla Forth using this routine:

If the need is occasional, it could be done on the fly:

: ," [char] " parse here over 1+ allot place ;

: $+ ( a -- a' ) count + ; \ traverse
: $, ( a -- a' ) dup , $+ ;
: $,S ( a -- ) begin dup c@ while $, repeat drop ;

here ( a) dup
," Apr" ," Aug" ," Dec" ," Feb"
," Jan" ," Jul" ," Jun" ," Mar"
," May" ," Nov" ," Oct" ," Sep"
0 c,

create StringData $,s \ strings

create MixedData \ strings & integers
4 , $, 8 , $, 12 , $, 2 , $,
1 , $, 7 , $, 6 , $, 3 , $,
5 , $, 11 , $, 10 , $, 9 , $,
drop

Re: Show human-readable time

<f5322b8d-e7c7-482c-a7cf-6fd68eb11d46n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14789&group=comp.lang.forth#14789

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1d3:: with SMTP id t19mr9849475qtw.128.1633040597014; Thu, 30 Sep 2021 15:23:17 -0700 (PDT)
X-Received: by 2002:a37:41ca:: with SMTP id o193mr7206850qka.187.1633040596850; Thu, 30 Sep 2021 15:23:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 30 Sep 2021 15:23:16 -0700 (PDT)
In-Reply-To: <b480dd4e-52e5-4321-bd67-0dd7aaa20fe7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:b4c9:979f:437a:9b3e; posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:b4c9:979f:437a:9b3e
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com> <sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com> <2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com> <614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org> <2021Sep25.184814@mips.complang.tuwien.ac.at> <062d3f57-4ce2-4769-87cd-09a5f40005dfn@googlegroups.com> <2021Sep28.133223@mips.complang.tuwien.ac.at> <9ab7b4bb-24b8-4953-89d6-103610eab6aan@googlegroups.com> <b480dd4e-52e5-4321-bd67-0dd7aaa20fe7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f5322b8d-e7c7-482c-a7cf-6fd68eb11d46n@googlegroups.com>
Subject: Re: Show human-readable time
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Thu, 30 Sep 2021 22:23:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: S Jack - Thu, 30 Sep 2021 22:23 UTC

On Wednesday, September 29, 2021 at 10:53:59 AM UTC-5, S Jack wrote:
> On Tuesday, September 28, 2021 at 10:11:44 PM UTC-5, S Jack wrote:
> > On Tuesday, September 28, 2021 at 6:39:11 AM UTC-5, Anton Ertl wrote:
The general idea:
create data_space 1000 cells allot
data_space var data_space_ptr
: data_space_here ( -- a ) data_space_ptr @ ;
: data_space_allot ( n -- ) data_space_ptr +! ;
: data_space_align data_space_here aligned data_space_ptr ! ;
: data_space_! ( x -- ) data_space_here ! four data_space_allot ;

: S"
data_space_here
34 word
DUP COUNT data_space_here PLACE C@ 1+ data_space_allot data_space_align
DOVAL data_space_! ( NB 1 )
data_space_here swap data_space_! ( NB 2 , which HERE for xt)
COMPILE, ; IMMEDIATE

: foo S" Hello World! " COUNT TYPE ;
fooHello World!
+echo
Notes:
1. VALUE used in place of LITERAL thus no interruption in
return address flow.
2. My XT was PFA
--
me

Compiling string literals (was: Show human-readable time)

<sj6m2u$n3h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14793&group=comp.lang.forth#14793

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Compiling string literals (was: Show human-readable time)
Date: Fri, 1 Oct 2021 12:57:50 +0300
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <sj6m2u$n3h$1@dont-email.me>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com>
<614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org>
<2021Sep25.184814@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Oct 2021 09:57:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="baabe0543dbc0aaa9bb919061d74b7e6";
logging-data="23665"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Jy5dkA2vKLTeYFcwdIqt6"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.1.2
Cancel-Lock: sha1:NFHANkWYUScxC67runDVQWtXKj8=
In-Reply-To: <2021Sep25.184814@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Fri, 1 Oct 2021 09:57 UTC

On 2021-09-25 19:48, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>> On 24/09/2021 23:43, Brian Fox wrote:
>>> : (S") ( -- c-addr u) R> COUNT 2DUP + ALIGNED >R ;
> ...
>> Even VFX appears to do that.
>
> Yes, surprisingly much return-address manipulation words with native
> code, too. It did not work with gforth-native, because the string
> would land in data space, and the code in code space.
>
> However, this technique incurs a branch misprediction (~20 cycles) on
> return from (S"), so I don't recommend it for native-code systems.

Probably, in native-code systems a native jump over a data block will be
more efficient than return address manipulation.

A native jump can be generated via AHEAD THEN as follows:

: slit, ( c-addr u -- )
>r >r postpone ahead
r> align here r@ allot 0 c, align r@ over >r move
postpone then r> lit, r> lit,
;

: sliteral ( c-addr u -- | c-addr u )
state @ if slit, then
; immediate

Of course, the use of a different section for strings should be even
more efficient, but requires more labor.

Appending the null character at the end makes the Forth string a
null-terminated string at the same time. So when you pass such a string
into external API that requires ASCIIZ, you don't need to make a copy of
this string.

--
Ruvim

Re: Show human-readable time

<c2b1896b-d4c7-4836-a405-f7c4ea792b8dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14795&group=comp.lang.forth#14795

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:4e8f:: with SMTP id 15mr13324397qtp.189.1633100141845;
Fri, 01 Oct 2021 07:55:41 -0700 (PDT)
X-Received: by 2002:ac8:15a:: with SMTP id f26mr12947003qtg.417.1633100141706;
Fri, 01 Oct 2021 07:55:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 1 Oct 2021 07:55:41 -0700 (PDT)
In-Reply-To: <sj5crf$4rm$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com>
<sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com>
<sijitf$4e1$1@gioia.aioe.org> <5c954437-46fa-4919-80cb-83eb96b279c4n@googlegroups.com>
<bd3c3577-684a-4101-8a0c-2cce070fc3d5n@googlegroups.com> <95936a59-6c5b-4fcd-ad6b-78ad7d9bead2n@googlegroups.com>
<sj5crf$4rm$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c2b1896b-d4c7-4836-a405-f7c4ea792b8dn@googlegroups.com>
Subject: Re: Show human-readable time
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Fri, 01 Oct 2021 14:55:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 48
 by: Hans Bezemer - Fri, 1 Oct 2021 14:55 UTC

On Friday, October 1, 2021 at 12:14:12 AM UTC+2, dxforth wrote:
> On 29/09/2021 23:34, Hans Bezemer wrote:
> >
> > The reference goes into the Code Segment (R/O), the string
> > itself in the String Segment (R/O). When fetched with @C it returns an address in the
> > Character Segment (R/W) where the temporary string has been copied to.
> >
> > Another thing is the interpretation semantics of DOES> - but you can do the same thing
> > with gForth too AFAIK. You can port the whole shebang to vanilla Forth using this routine:
> If the need is occasional, it could be done on the fly:
>
> : ," [char] " parse here over 1+ allot place ;
>
> : $+ ( a -- a' ) count + ; \ traverse
> : $, ( a -- a' ) dup , $+ ;
> : $,S ( a -- ) begin dup c@ while $, repeat drop ;
>
> here ( a) dup
> ," Apr" ," Aug" ," Dec" ," Feb"
> ," Jan" ," Jul" ," Jun" ," Mar"
> ," May" ," Nov" ," Oct" ," Sep"
> 0 c,
>
> create StringData $,s \ strings
>
> create MixedData \ strings & integers
> 4 , $, 8 , $, 12 , $, 2 , $,
> 1 , $, 7 , $, 6 , $, 3 , $,
> 5 , $, 11 , $, 10 , $, 9 , $,
> drop

Very true. We visited that one when I wrote an article on this with Ben Hoyt for FD. The routine I listed was primarily intended for back porting 4tH programs. Sizing the string space isn't that hard, because the 4tH decompile lists exactly how much space the String Segment occupies.

4tH message: No errors at word 695
Object size: 695 words
String size: 1379 chars
Variables : 4 cells
Strings : 4096 chars
Symbols : 52 names
Reliable : Yes

Hans Bezemer

Re: Compiling string literals (was: Show human-readable time)

<2021Oct1.190035@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14797&group=comp.lang.forth#14797

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Compiling string literals (was: Show human-readable time)
Date: Fri, 01 Oct 2021 17:00:35 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 28
Message-ID: <2021Oct1.190035@mips.complang.tuwien.ac.at>
References: <8735pvuern.fsf@nightsong.com> <87y27nszv4.fsf@nightsong.com> <sijev1$14c7$1@gioia.aioe.org> <87ilyqbqqf.fsf@nightsong.com> <2021Sep24.082437@mips.complang.tuwien.ac.at> <87ee9ebgof.fsf@nightsong.com> <614DD60B.3080602@rogers.com> <sim0bd$fcq$1@gioia.aioe.org> <2021Sep25.184814@mips.complang.tuwien.ac.at> <sj6m2u$n3h$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="05209f9dd0d64b48841af6379d109ae3";
logging-data="5706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pC4xUneaGQB9OmcbNsubM"
Cancel-Lock: sha1:vFUTnTkeSTii6/SkSM5Rx8he3lc=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 1 Oct 2021 17:00 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>A native jump can be generated via AHEAD THEN as follows:
>
> : slit, ( c-addr u -- )
> >r >r postpone ahead
> r> align here r@ allot 0 c, align r@ over >r move
> postpone then r> lit, r> lit,
> ;
>
> : sliteral ( c-addr u -- | c-addr u )
> state @ if slit, then
> ; immediate

Of course, this can be done in a simpler and less broken way by
leaving the STATE-smartness away, e.g.:

: sliteral ( c-addr u -- | c-addr u )
>r >r postpone ahead
r> align here r@ allot 0 c, align r@ over >r move
postpone then r> lit, r> lit,
; immediate

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

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor