Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

May you do Good Magic with Perl. -- Larry Wall's blessing


devel / comp.lang.forth / Re: EXECUTE in various forms

SubjectAuthor
* EXECUTE in various formsKrishna Myneni
+* Re: EXECUTE in various formsRuvim
|`* Re: EXECUTE in various formsKrishna Myneni
| +* Re: EXECUTE in various formsKrishna Myneni
| |`* Re: EXECUTE in various formsJim Peterson
| | `- Re: EXECUTE in various formsKrishna Myneni
| `* Re: EXECUTE in various formsRuvim
|  `* Re: EXECUTE in various formsKrishna Myneni
|   `- Re: EXECUTE in various formsKrishna Myneni
+* Re: EXECUTE in various formsAnton Ertl
|`- Re: EXECUTE in various formsKrishna Myneni
`* Re: EXECUTE in various formsKrishna Myneni
 `- Re: EXECUTE in various formsKrishna Myneni

1
EXECUTE in various forms

<sck1sb$maa$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: EXECUTE in various forms
Date: Tue, 13 Jul 2021 07:44:58 -0500
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <sck1sb$maa$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 13 Jul 2021 12:45:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f8bfeabc3e9c55979c00204427162376";
logging-data="22858"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Wgr2K8HV2qWB/IIwhEAFd"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:B5E1+2Wc29HandBAk1iBCQFieho=
Content-Language: en-US
X-Mozilla-News-Host: snews://news.eternal-september.org:563
 by: Krishna Myneni - Tue, 13 Jul 2021 12:44 UTC

The xt is an abstracted reference to the execution semantics of Forth
code which can be performed by EXECUTE. The execution semantics may be
referenced and represented internally in various ways. For example, the
xt could be the starting address of an indirect threaded code (ITC)
sequence, such as byte code representation of the Forth source which
specifies the execution semantics, or it could be the address of
compiled native code (NC), or it could be an indirect reference to such
addresses.

In kForth (32 and 64 bit versions), I have three words which can execute
code. These are

EXECUTE
EXECUTE-BC
CALL

EXECUTE is the standard word, which takes an xt. Internally, in kForth,
the xt is an indirect reference to ITC byte code. EXECUTE-BC takes as an
argument a direct reference to a byte code sequence which can be
executed by the VM, thereby allowing other methods of generating code,
besides the interpreter. CALL takes as an argument a direct address
reference for native code (machine code).

The non-standard words EXECUTE-BC and CALL may be considered different
versions of EXECUTE and might more properly be named,

EXECUTE-ITC
EXECUTE-NC

Their arguments are also execution tokens, but the xt's for the three
different versions of EXECUTE are obviously not interchangeable. These
words are useful and I expect many Forth systems provide a variant of
EXECUTE-NC. EXECUTE-ITC in particular could be useful for implementing
single step debuggers. Is there a possibility of achieving commonality
in names here, to enable writing portable versions of tools like debuggers?

Krishna Myneni

Re: EXECUTE in various forms

<scm5g8$616$1@dont-email.me>

 copy mid

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

 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: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 10:59:03 +0300
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <scm5g8$616$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jul 2021 07:59:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c65c460a3a4c8c274e6e6b6ce0362b77";
logging-data="6182"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xhClZRbePYYRThWj0cGXj"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:Xo8oO5fySMhxxV3Hhzk9jPytyDI=
In-Reply-To: <sck1sb$maa$1@dont-email.me>
Content-Language: en-US
 by: Ruvim - Wed, 14 Jul 2021 07:59 UTC

On 2021-07-13 15:44, Krishna Myneni wrote:
> The xt is an abstracted reference to the execution semantics of Forth
> code which can be performed by EXECUTE. The execution semantics may be
> referenced and represented internally in various ways. For example, the
> xt could be the starting address of an indirect threaded code (ITC)
> sequence, such as byte code representation of the Forth source which
> specifies the execution semantics, or it could be the address of
> compiled native code (NC), or it could be an indirect reference to such
> addresses.
>
> In kForth (32 and 64 bit versions), I have three words which can execute
> code. These are
>
> EXECUTE
> EXECUTE-BC
> CALL
>
> EXECUTE is the standard word, which takes an xt. Internally, in kForth,
> the xt is an indirect reference to ITC byte code. EXECUTE-BC takes as an
> argument a direct reference to a byte code sequence which can be
> executed by the VM, thereby allowing other methods of generating code,
> besides the interpreter. CALL takes as an argument a direct address
> reference for native code (machine code).
>
> The non-standard words EXECUTE-BC and CALL may be considered different
> versions of EXECUTE and might more properly be named,
>
> EXECUTE-ITC
> EXECUTE-NC
>
> Their arguments are also execution tokens, but the xt's for the three
> different versions of EXECUTE are obviously not interchangeable. These
> words are useful and I expect many Forth systems provide a variant of
> EXECUTE-NC.

A system with STC or native code usually have only one variant of
EXECUTE (the standard one).

Other variants can be in the frame of FFI (foreign function interface).

I use the following words

\ cdecl - C calling convention with 1 result
EXEC-FOREIGN-C1 ( u*x u entry-point -- x )

\ stdcall - Windows API calling convention with 1 result
EXEC-FOREIGN-P1 ( u*x u entry-point -- x )

> EXECUTE-ITC in particular could be useful for implementing
> single step debuggers. Is there a possibility of achieving commonality
> in names here, to enable writing portable versions of tools like debuggers?

To achieve some level of portability, you need not only the consumers,
but also the words that produce the corresponding tokens.

--
Ruvim

Re: EXECUTE in various forms

<scmkli$714$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 07:17:53 -0500
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <scmkli$714$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 14 Jul 2021 12:17:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="28d70d4966d75dc08f3e60e129e18f19";
logging-data="7204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/385ZISDL4+LsRSBaS3d4"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:qBFw6KJAVzleJGdwh1qsJozUyEQ=
In-Reply-To: <scm5g8$616$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Wed, 14 Jul 2021 12:17 UTC

On 7/14/21 2:59 AM, Ruvim wrote:
> On 2021-07-13 15:44, Krishna Myneni wrote:
>> The xt is an abstracted reference to the execution semantics of Forth
>> code which can be performed by EXECUTE. The execution semantics may be
>> referenced and represented internally in various ways. For example,
>> the xt could be the starting address of an indirect threaded code
>> (ITC) sequence, such as byte code representation of the Forth source
>> which specifies the execution semantics, or it could be the address of
>> compiled native code (NC), or it could be an indirect reference to
>> such addresses.
>>
>> In kForth (32 and 64 bit versions), I have three words which can
>> execute code. These are
>>
>> EXECUTE
>> EXECUTE-BC
>> CALL
>>
>> EXECUTE is the standard word, which takes an xt. Internally, in
>> kForth, the xt is an indirect reference to ITC byte code. EXECUTE-BC
>> takes as an argument a direct reference to a byte code sequence which
>> can be executed by the VM, thereby allowing other methods of
>> generating code, besides the interpreter. CALL takes as an argument a
>> direct address reference for native code (machine code).
>>
>> The non-standard words EXECUTE-BC and CALL may be considered different
>> versions of EXECUTE and might more properly be named,
>>
>> EXECUTE-ITC
>> EXECUTE-NC
>>
>> Their arguments are also execution tokens, but the xt's for the three
>> different versions of EXECUTE are obviously not interchangeable. These
>> words are useful and I expect many Forth systems provide a variant of
>> EXECUTE-NC.
>
>
> A system with STC or native code usually have only one variant of
> EXECUTE (the standard one).
>
>
> Other variants can be in the frame of FFI (foreign function interface).
>
> I use the following words
>
>   \ cdecl - C calling convention with 1 result
>   EXEC-FOREIGN-C1 ( u*x u entry-point -- x )
>
>   \ stdcall - Windows API calling convention with 1 result
>   EXEC-FOREIGN-P1 ( u*x u entry-point -- x )
>
>

The word EXECUTE-NC ( currently named CALL in kForth ) is useful in
implementing both the Forth-assembler interface and the Forth-foreign
function interface.

>> EXECUTE-ITC in particular could be useful for implementing single step
>> debuggers. Is there a possibility of achieving commonality in names
>> here, to enable writing portable versions of tools like debuggers?
>
> To achieve some level of portability, you need not only the consumers,
> but also the words that produce the corresponding tokens.
>
>

Yes, that's true -- there are more support words needed. My implicit
assumption here is that both ITC code and other representations such as
native code are generated by the interpreter. The "nt" then becomes
useful as a way of referencing the ITC code representation. A
corresponding VM is needed to run the ITC representation, but that's
trivial to write.

One can imagine then, for the implementation of a portable single step
debugger, that we might do something like this:

: FOO SWAP DUP BAR ... ; \ a word definition

Also DEBUG \ the debug vocabulary is added to the search order

\ XT>ITC ( xt -- addr-itc )
\ STEP ( i*x addr-itc -- j*x addr-itc2 )

' FOO XT>ITC \ convert XT to the direct address of the ITC code
STEP \ executes SWAP using EXECUTE ITC, and displays debug info
STEP \ executes DUP ...
STEP
Entering BAR ... \ displays message and executes first token

and so on.

The full wordset needed to portably implement a single step debugger can
be quite minimal under the assumption that ITC code is generated in
parallel by the interpreter.

Krishna

Re: EXECUTE in various forms

<scmktc$714$2@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 07:22:03 -0500
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <scmktc$714$2@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me>
<scmkli$714$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 14 Jul 2021 12:22:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="28d70d4966d75dc08f3e60e129e18f19";
logging-data="7204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//MJ2vo/yD+ram+JqXt/+V"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:P3w5uBnvWssYu3AlClADpArwsUY=
In-Reply-To: <scmkli$714$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Wed, 14 Jul 2021 12:22 UTC

On 7/14/21 7:17 AM, Krishna Myneni wrote:
> On 7/14/21 2:59 AM, Ruvim wrote:
>> On 2021-07-13 15:44, Krishna Myneni wrote:
>>> The xt is an abstracted reference to the execution semantics of Forth
>>> code which can be performed by EXECUTE. The execution semantics may
>>> be referenced and represented internally in various ways. For
>>> example, the xt could be the starting address of an indirect threaded
>>> code (ITC) sequence, such as byte code representation of the Forth
>>> source which specifies the execution semantics, or it could be the
>>> address of compiled native code (NC), or it could be an indirect
>>> reference to such addresses.
>>>
>>> In kForth (32 and 64 bit versions), I have three words which can
>>> execute code. These are
>>>
>>> EXECUTE
>>> EXECUTE-BC
>>> CALL
>>>
>>> EXECUTE is the standard word, which takes an xt. Internally, in
>>> kForth, the xt is an indirect reference to ITC byte code. EXECUTE-BC
>>> takes as an argument a direct reference to a byte code sequence which
>>> can be executed by the VM, thereby allowing other methods of
>>> generating code, besides the interpreter. CALL takes as an argument a
>>> direct address reference for native code (machine code).
>>>
>>> The non-standard words EXECUTE-BC and CALL may be considered
>>> different versions of EXECUTE and might more properly be named,
>>>
>>> EXECUTE-ITC
>>> EXECUTE-NC
>>>
>>> Their arguments are also execution tokens, but the xt's for the three
>>> different versions of EXECUTE are obviously not interchangeable.
>>> These words are useful and I expect many Forth systems provide a
>>> variant of EXECUTE-NC.
>>
>>
>> A system with STC or native code usually have only one variant of
>> EXECUTE (the standard one).
>>
>>
>> Other variants can be in the frame of FFI (foreign function interface).
>>
>> I use the following words
>>
>>    \ cdecl - C calling convention with 1 result
>>    EXEC-FOREIGN-C1 ( u*x u entry-point -- x )
>>
>>    \ stdcall - Windows API calling convention with 1 result
>>    EXEC-FOREIGN-P1 ( u*x u entry-point -- x )
>>
>>
>
> The word EXECUTE-NC ( currently named CALL in kForth ) is useful in
> implementing both the Forth-assembler interface and the Forth-foreign
> function interface.
>
>
>>> EXECUTE-ITC in particular could be useful for implementing single
>>> step debuggers. Is there a possibility of achieving commonality in
>>> names here, to enable writing portable versions of tools like debuggers?
>>
>> To achieve some level of portability, you need not only the consumers,
>> but also the words that produce the corresponding tokens.
>>
>>
>
> Yes, that's true -- there are more support words needed. My implicit
> assumption here is that both ITC code and other representations such as
> native code are generated by the interpreter. The "nt" then becomes
> useful as a way of referencing the ITC code representation. A
> corresponding VM is needed to run the ITC representation, but that's
> trivial to write.
>
> One can imagine then, for the implementation of a portable single step
> debugger, that we might do something like this:
>
> : FOO SWAP DUP BAR ... ;  \ a word definition
>
> Also DEBUG  \ the debug vocabulary is added to the search order
>
> \ XT>ITC ( xt -- addr-itc )
> \ STEP  ( i*x addr-itc -- j*x addr-itc2 )
>
> ' FOO XT>ITC  \ convert XT to the direct address of the ITC code
> STEP  \ executes SWAP using EXECUTE ITC, and displays debug info
> STEP  \ executes DUP ...
> STEP
> Entering BAR ...  \ displays message and executes first token
>
> and so on.
>
> The full wordset needed to portably implement a single step debugger can
> be quite minimal under the assumption that ITC code is generated in
> parallel by the interpreter.
>

It's worthwhile to point out that such an approach does not assume
standardized tokens for ITC implementations -- that's an internal detail
of the Forth system.

KM

Re: EXECUTE in various forms

<0433cf49-0546-4f80-9eae-d7d0ac0978den@googlegroups.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:596b:: with SMTP id eq11mr10620675qvb.34.1626269837727; Wed, 14 Jul 2021 06:37:17 -0700 (PDT)
X-Received: by 2002:a05:620a:c15:: with SMTP id l21mr10219573qki.15.1626269837493; Wed, 14 Jul 2021 06:37:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.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, 14 Jul 2021 06:37:17 -0700 (PDT)
In-Reply-To: <scmktc$714$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=184.170.72.255; posting-account=kidwfQoAAAAfI20wQGXIy9JZVTNSnVqm
NNTP-Posting-Host: 184.170.72.255
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me> <scmkli$714$1@dont-email.me> <scmktc$714$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0433cf49-0546-4f80-9eae-d7d0ac0978den@googlegroups.com>
Subject: Re: EXECUTE in various forms
From: elkn...@gmail.com (Jim Peterson)
Injection-Date: Wed, 14 Jul 2021 13:37:17 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 41
 by: Jim Peterson - Wed, 14 Jul 2021 13:37 UTC

On Wednesday, July 14, 2021 at 8:22:06 AM UTC-4, Krishna Myneni wrote:
> On 7/14/21 7:17 AM, Krishna Myneni wrote:
> > On 7/14/21 2:59 AM, Ruvim wrote:
> >> On 2021-07-13 15:44, Krishna Myneni wrote:
> >>> The xt is an abstracted reference to the execution semantics of Forth
> >>> code which can be performed by EXECUTE. The execution semantics may
> >>> be referenced and represented internally in various ways. For
> >>> example, the xt could be the starting address of an indirect threaded
> >>> code (ITC) sequence, such as byte code representation of the Forth
> >>> source which specifies the execution semantics, or it could be the
> >>> address of compiled native code (NC), or it could be an indirect
> >>> reference to such addresses.
> >>>
> >>> In kForth (32 and 64 bit versions), I have three words which can
> >>> execute code. These are
> >>>
> >>> EXECUTE
> >>> EXECUTE-BC
> >>> CALL

It's arguable that a single, EXECUTE, word could suffice, so long as an xt was not really an address to execute but rather a pointer to a data structure. The structure could contain not only an execution address but also the type of address it represents... or even an address and a pointer to some native code that will properly execute the address, not only allowing for the methods you describe, but also allowing you to expand the capabilities later on, if desired:

\ xt+0c: routine address
\ xt+1c: native code to execute routine address

: EXECUTE DUP @ SWAP CELL+ @ CALL ;

Tick and FIND could return a pointer to an opaque "word list entry" structure, that has plenty of information about what was just looked up. I think this is what name tokens (nt) were maybe meant to be, but it doesn't seem like the standard prevents xt's from being something similar (or identical).

--Jim

Re: EXECUTE in various forms

<scn00v$l50$1@dont-email.me>

 copy mid

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

 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: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 18:31:42 +0300
Organization: A noiseless patient Spider
Lines: 98
Message-ID: <scn00v$l50$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me>
<scmkli$714$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 14 Jul 2021 15:31:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c65c460a3a4c8c274e6e6b6ce0362b77";
logging-data="21664"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/C2wl1sXp0ZqwDA5FF1xr7"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:NlpmES/h3Q+A251hUAKxqfKpTTQ=
In-Reply-To: <scmkli$714$1@dont-email.me>
Content-Language: en-US
 by: Ruvim - Wed, 14 Jul 2021 15:31 UTC

On 2021-07-14 15:17, Krishna Myneni wrote:
> On 7/14/21 2:59 AM, Ruvim wrote:
>> On 2021-07-13 15:44, Krishna Myneni wrote:
[...]
>>> These words are useful and I expect many Forth systems provide a
>>> variant of EXECUTE-NC.
>>
>>
>> A system with STC or native code usually have only one variant of
>> EXECUTE (the standard one).
>>
>>
>> Other variants can be in the frame of FFI (foreign function interface).
>>
>> I use the following words
>>
>>    \ cdecl - C calling convention with 1 result
>>    EXEC-FOREIGN-C1 ( u*x u entry-point -- x )
>>
>>    \ stdcall - Windows API calling convention with 1 result
>>    EXEC-FOREIGN-P1 ( u*x u entry-point -- x )
>>
>>
>
> The word EXECUTE-NC ( currently named CALL in kForth ) is useful in
> implementing both the Forth-assembler interface and the Forth-foreign
> function interface.

It's unclear how EXECUTE-NC can help to implement various calling
conventions [1] except the cases when the data stack is the same as the
cpu's stack and all the arguments are passed via the stack only.

[1] see-also: https://en.wikipedia.org/wiki/X86_calling_conventions

>>> EXECUTE-ITC in particular could be useful for implementing single
>>> step debuggers. Is there a possibility of achieving commonality in
>>> names here, to enable writing portable versions of tools like debuggers?
>>
>> To achieve some level of portability, you need not only the consumers,
>> but also the words that produce the corresponding tokens.
>>
>>
>
> Yes, that's true -- there are more support words needed. My implicit
> assumption here is that both ITC code and other representations such as
> native code are generated by the interpreter. The "nt" then becomes
> useful as a way of referencing the ITC code representation. A
> corresponding VM is needed to run the ITC representation, but that's
> trivial to write.
>
> One can imagine then, for the implementation of a portable single step
> debugger, that we might do something like this:
>
> : FOO SWAP DUP BAR ... ;  \ a word definition
>
> Also DEBUG  \ the debug vocabulary is added to the search order
>
> \ XT>ITC ( xt -- addr-itc )
> \ STEP  ( i*x addr-itc -- j*x addr-itc2 )
>
> ' FOO XT>ITC  \ convert XT to the direct address of the ITC code
> STEP  \ executes SWAP using EXECUTE ITC, and displays debug info
> STEP  \ executes DUP ...
> STEP
> Entering BAR ...  \ displays message and executes first token
>
> and so on.

A portable standard-compliant step-by-step debugger can be implemented
via a user-defined Forth text interpreter.

It just generates a code as:

: FOO Q SWAP Q DUP Q BAR Q ... ;

Where "Q ( -- )" implements all interactions with the user.

A variation on that is: "QS ( sd-name -- )"
and the generated code as:

: FOO S" SWAP" QS SWAP S" DUP" QS DUP S" BAR" QS BAR ... ;

> The full wordset needed to portably implement a single step debugger can
> be quite minimal under the assumption that ITC code is generated in
> parallel by the interpreter.

A user-defined Forth text interpreter can generate some ITC code in
parallel, but it looks like this technique is more complex.

--
Ruvim

Re: EXECUTE in various forms

<2021Jul14.182816@mips.complang.tuwien.ac.at>

 copy mid

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

 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: EXECUTE in various forms
Date: Wed, 14 Jul 2021 16:28:16 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 45
Message-ID: <2021Jul14.182816@mips.complang.tuwien.ac.at>
References: <sck1sb$maa$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="7d9ce7500600f7bed764a1a35c1c8a33";
logging-data="22102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ApfYdXHKRLFnhfCslyhgP"
Cancel-Lock: sha1:mlrB9VJEejHSukZQ4jxKLgA3rCw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 14 Jul 2021 16:28 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>The xt is an abstracted reference to the execution semantics of Forth
>code which can be performed by EXECUTE. The execution semantics may be
>referenced and represented internally in various ways. For example, the
>xt could be the starting address of an indirect threaded code (ITC)
>sequence, such as byte code representation of the Forth source which
>specifies the execution semantics, or it could be the address of
>compiled native code (NC), or it could be an indirect reference to such
>addresses.
>
>In kForth (32 and 64 bit versions), I have three words which can execute
>code. These are
>
>EXECUTE
>EXECUTE-BC
>CALL
>
>EXECUTE is the standard word, which takes an xt. Internally, in kForth,
>the xt is an indirect reference to ITC byte code. EXECUTE-BC takes as an
>argument a direct reference to a byte code sequence which can be
>executed by the VM, thereby allowing other methods of generating code,
>besides the interpreter. CALL takes as an argument a direct address
>reference for native code (machine code).
>
>The non-standard words EXECUTE-BC and CALL may be considered different
>versions of EXECUTE and might more properly be named,
>
>EXECUTE-ITC
>EXECUTE-NC
>
>Their arguments are also execution tokens, but the xt's for the three
>different versions of EXECUTE are obviously not interchangeable. These
>words are useful and I expect many Forth systems provide a variant of
>EXECUTE-NC.

Gforth only has EXECUTE. fig-Forth only has EXECUTE. I don't see any
particular usefulness in EXECUTE-ITC and EXECUTE-NC; what can they do
that EXECUTE cannot?

- 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: EXECUTE in various forms

<scnpvp$5oa$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 17:54:47 -0500
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <scnpvp$5oa$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me>
<scmkli$714$1@dont-email.me> <scmktc$714$2@dont-email.me>
<0433cf49-0546-4f80-9eae-d7d0ac0978den@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jul 2021 22:54:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bacd27c8a76cbbda6a7b7ed518c2274a";
logging-data="5898"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Jl9M/Wn8F90fNTDwMv8y5"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:EK0jiySGFtUKoBYbYN0p3P5gRa8=
In-Reply-To: <0433cf49-0546-4f80-9eae-d7d0ac0978den@googlegroups.com>
Content-Language: en-US
 by: Krishna Myneni - Wed, 14 Jul 2021 22:54 UTC

On 7/14/21 8:37 AM, Jim Peterson wrote:
> On Wednesday, July 14, 2021 at 8:22:06 AM UTC-4, Krishna Myneni wrote:
>> On 7/14/21 7:17 AM, Krishna Myneni wrote:
>>> On 7/14/21 2:59 AM, Ruvim wrote:
>>>> On 2021-07-13 15:44, Krishna Myneni wrote:
>>>>> The xt is an abstracted reference to the execution semantics of Forth
>>>>> code which can be performed by EXECUTE. The execution semantics may
>>>>> be referenced and represented internally in various ways. For
>>>>> example, the xt could be the starting address of an indirect threaded
>>>>> code (ITC) sequence, such as byte code representation of the Forth
>>>>> source which specifies the execution semantics, or it could be the
>>>>> address of compiled native code (NC), or it could be an indirect
>>>>> reference to such addresses.
>>>>>
>>>>> In kForth (32 and 64 bit versions), I have three words which can
>>>>> execute code. These are
>>>>>
>>>>> EXECUTE
>>>>> EXECUTE-BC
>>>>> CALL
>
> It's arguable that a single, EXECUTE, word could suffice, so long as an xt was not really an address to execute but rather a pointer to a data structure. The structure could contain not only an execution address but also the type of address it represents... or even an address and a pointer to some native code that will properly execute the address, not only allowing for the methods you describe, but also allowing you to expand the capabilities later on, if desired:
>
> \ xt+0c: routine address
> \ xt+1c: native code to execute routine address
>
> : EXECUTE DUP @ SWAP CELL+ @ CALL ;
>
> Tick and FIND could return a pointer to an opaque "word list entry" structure, that has plenty of information about what was just looked up. I think this is what name tokens (nt) were maybe meant to be, but it doesn't seem like the standard prevents xt's from being something similar (or identical).
>

Within the Forth-2012 standard, there is no simple way to access the nt
of a word, from which one can use NAME>INTERPRET to obtain the xt for
its execution semantics. One can obtain the nt of a word through a
procedure using TRAVERSE-WORDLIST, but this is not simple.

With regard to xt being a pointer to a data structure, that's certainly
permissible within the standard.

Krishna

Re: EXECUTE in various forms

<scnqpf$fdg$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 18:08:29 -0500
Organization: A noiseless patient Spider
Lines: 112
Message-ID: <scnqpf$fdg$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me>
<scmkli$714$1@dont-email.me> <scn00v$l50$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 14 Jul 2021 23:08:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bacd27c8a76cbbda6a7b7ed518c2274a";
logging-data="15792"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lE0ECYnfykxkVtDelRE0a"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:OqIBxj1Y99KW2z9/p3R4c1/q7+o=
In-Reply-To: <scn00v$l50$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Wed, 14 Jul 2021 23:08 UTC

On 7/14/21 10:31 AM, Ruvim wrote:
> On 2021-07-14 15:17, Krishna Myneni wrote:
>> On 7/14/21 2:59 AM, Ruvim wrote:
>>> On 2021-07-13 15:44, Krishna Myneni wrote:
> [...]
>>>> These words are useful and I expect many Forth systems provide a
>>>> variant of EXECUTE-NC.
>>>
>>>
>>> A system with STC or native code usually have only one variant of
>>> EXECUTE (the standard one).
>>>
>>>
>>> Other variants can be in the frame of FFI (foreign function interface).
>>>
>>> I use the following words
>>>
>>>    \ cdecl - C calling convention with 1 result
>>>    EXEC-FOREIGN-C1 ( u*x u entry-point -- x )
>>>
>>>    \ stdcall - Windows API calling convention with 1 result
>>>    EXEC-FOREIGN-P1 ( u*x u entry-point -- x )
>>>
>>>
>>
>> The word EXECUTE-NC ( currently named CALL in kForth ) is useful in
>> implementing both the Forth-assembler interface and the Forth-foreign
>> function interface.
>
> It's unclear how EXECUTE-NC can help to implement various calling
> conventions [1] except the cases when the data stack is the same as the
> cpu's stack and all the arguments are passed via the stack only.
>
> [1] see-also: https://en.wikipedia.org/wiki/X86_calling_conventions
>

In kForth, the word CALL (the equivalent of EXECUTE-NC) is used to
define CODE (see asm-x86.4th). CODE words are then defined to provide a
calling interface for functions taking different number of arguments
(see fcalls-x86.4th [2]). Finally, a high-level interface allows Forth
definitions which map to function calls in external compiled libraries
(see lib-interface [3]). The library interface provides both C and
Fortran calling conventions, so it is indeed possible.

>
>
>>>> EXECUTE-ITC in particular could be useful for implementing single
>>>> step debuggers. Is there a possibility of achieving commonality in
>>>> names here, to enable writing portable versions of tools like
>>>> debuggers?
>>>
>>> To achieve some level of portability, you need not only the
>>> consumers, but also the words that produce the corresponding tokens.
>>>
>>>
>>
>> Yes, that's true -- there are more support words needed. My implicit
>> assumption here is that both ITC code and other representations such
>> as native code are generated by the interpreter. The "nt" then becomes
>> useful as a way of referencing the ITC code representation. A
>> corresponding VM is needed to run the ITC representation, but that's
>> trivial to write.
>>
>> One can imagine then, for the implementation of a portable single step
>> debugger, that we might do something like this:
>>
>> : FOO SWAP DUP BAR ... ;  \ a word definition
>>
>> Also DEBUG  \ the debug vocabulary is added to the search order
>>
>> \ XT>ITC ( xt -- addr-itc )
>> \ STEP  ( i*x addr-itc -- j*x addr-itc2 )
>>
>> ' FOO XT>ITC  \ convert XT to the direct address of the ITC code
>> STEP  \ executes SWAP using EXECUTE ITC, and displays debug info
>> STEP  \ executes DUP ...
>> STEP
>> Entering BAR ...  \ displays message and executes first token
>>
>> and so on.
>
>
> A portable standard-compliant step-by-step debugger can be implemented
> via a user-defined Forth text interpreter.
>
> It just generates a code as:
>
>   : FOO Q SWAP Q DUP Q BAR Q ... ;
>
> Where "Q ( -- )" implements all interactions with the user.

Yes, that's one way to do it.

>
>> The full wordset needed to portably implement a single step debugger
>> can be quite minimal under the assumption that ITC code is generated
>> in parallel by the interpreter.
>
>
> A user-defined Forth text interpreter can generate some ITC code in
> parallel, but it looks like this technique is more complex.
>

One would need to create a lookup table to map tokens to native code
addresses. Whether or not the standard permits implementation of both
ITC code generation and writing a VM capable of executing token
sequences in Forth source isn't clear to me at this point, but perhaps
it can be done within the standard.

Krishna

Re: EXECUTE in various forms

<scnr6q$kee$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 18:15:36 -0500
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <scnr6q$kee$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me>
<2021Jul14.182816@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jul 2021 23:15:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bacd27c8a76cbbda6a7b7ed518c2274a";
logging-data="20942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4Gf1oyz8scxNd01uQop1K"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:nlJCKVTisfVMAfZUBCetQ1x5xLw=
In-Reply-To: <2021Jul14.182816@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Krishna Myneni - Wed, 14 Jul 2021 23:15 UTC

On 7/14/21 11:28 AM, Anton Ertl wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>> The xt is an abstracted reference to the execution semantics of Forth
>> code which can be performed by EXECUTE. The execution semantics may be
>> referenced and represented internally in various ways. For example, the
>> xt could be the starting address of an indirect threaded code (ITC)
>> sequence, such as byte code representation of the Forth source which
>> specifies the execution semantics, or it could be the address of
>> compiled native code (NC), or it could be an indirect reference to such
>> addresses.
>>
>> In kForth (32 and 64 bit versions), I have three words which can execute
>> code. These are
>>
>> EXECUTE
>> EXECUTE-BC
>> CALL
>>
>> EXECUTE is the standard word, which takes an xt. Internally, in kForth,
>> the xt is an indirect reference to ITC byte code. EXECUTE-BC takes as an
>> argument a direct reference to a byte code sequence which can be
>> executed by the VM, thereby allowing other methods of generating code,
>> besides the interpreter. CALL takes as an argument a direct address
>> reference for native code (machine code).
>>
>> The non-standard words EXECUTE-BC and CALL may be considered different
>> versions of EXECUTE and might more properly be named,
>>
>> EXECUTE-ITC
>> EXECUTE-NC
>>
>> Their arguments are also execution tokens, but the xt's for the three
>> different versions of EXECUTE are obviously not interchangeable. These
>> words are useful and I expect many Forth systems provide a variant of
>> EXECUTE-NC.
>
> Gforth only has EXECUTE. fig-Forth only has EXECUTE. I don't see any
> particular usefulness in EXECUTE-ITC and EXECUTE-NC; what can they do
> that EXECUTE cannot?
>

For a system which compiles definitions to native code only, adding a
parallel ITC compiler would be analogous to providing the extra
information needed by a debugger in order to step through the native
code at each primitive word. EXECUTE-ITC and a corresponding VM allows
stepping through the ITC code sequences, with meaningful identification
of the word which was executed.

If you mean that an ITC compiler and VM can be written in Forth source
in a standard way, e.g. define EXECUTE-ITC in Forth source, I'm not
aware of anyone who has implemented a debugger in that manner.

Krishna

Re: EXECUTE in various forms

<scnrd3$mlv$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Wed, 14 Jul 2021 18:18:57 -0500
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <scnrd3$mlv$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <scm5g8$616$1@dont-email.me>
<scmkli$714$1@dont-email.me> <scn00v$l50$1@dont-email.me>
<scnqpf$fdg$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jul 2021 23:18:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bacd27c8a76cbbda6a7b7ed518c2274a";
logging-data="23231"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18q93j+Huoo4f7UyTjgjB14"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:1L0nOrb+J33pf5zJfxMa1JRvGCI=
In-Reply-To: <scnqpf$fdg$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Wed, 14 Jul 2021 23:18 UTC

On 7/14/21 6:08 PM, Krishna Myneni wrote:
....
> In kForth, the word CALL (the equivalent of EXECUTE-NC) is used to
> define CODE (see asm-x86.4th). CODE words are then defined to provide a
> calling interface for functions taking different number of arguments
> (see fcalls-x86.4th [2]). Finally, a high-level interface allows Forth
> definitions which map to function calls in external compiled libraries
> (see lib-interface [3]). The library interface provides both C and
> Fortran calling conventions, so it is indeed possible.
>
....

Here are the references I forgot to include in my previous message:

1. https://github.com/mynenik/kForth-32/blob/master/forth-src/asm-x86.4th

2.
https://github.com/mynenik/kForth-32/blob/master/forth-src/fcalls-x86.4th

3.
https://github.com/mynenik/kForth-32/blob/master/forth-src/lib-interface.4th

KM

Re: EXECUTE in various forms

<sd3ppf$r1a$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Mon, 19 Jul 2021 07:05:01 -0500
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <sd3ppf$r1a$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Jul 2021 12:05:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cd498574a769ff750d6ea43fc18e3f3d";
logging-data="27690"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XKx4Zkymrl/AUTPdGREis"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:HTDGPkptmuF2PFkY23qVX3mI040=
In-Reply-To: <sck1sb$maa$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Mon, 19 Jul 2021 12:05 UTC

On 7/13/21 7:44 AM, Krishna Myneni wrote:
....
> The non-standard words EXECUTE-BC and CALL may be considered different
> versions of EXECUTE and might more properly be named,
>
> EXECUTE-ITC
> EXECUTE-NC
>
> Their arguments are also execution tokens, but the xt's for the three
> different versions of EXECUTE are obviously not interchangeable. These
> words are useful and I expect many Forth systems provide a variant of
> EXECUTE-NC. EXECUTE-ITC in particular could be useful for implementing
> single step debuggers. Is there a possibility of achieving commonality
> in names here, to enable writing portable versions of tools like debuggers?
>

Following my original post, I have added a preliminary SEE facility and
Single-Step Debugger, in Forth source, to the kForth-64 (0.2.x) and
kForth-32 (2.x) packages. A good bit of common code is needed for both
SEE and single step debugging for an ITC Forth -- the same might be true
for a native code Forth.

The code is somewhat dirty and needs additional factoring and use of
structure member references ( rather than hard coded "n cells +" ), but
it's also relatively simple to implement. In particular, for ITC code,
there are two words which are necessary to implement both SEE and the
single-step debugger

XT>ITC ( xt -- addr-itc )
XT>NC ( xt -- addr-nc )

Some of the definitions are kForth-specific and rely on the specific
details of the ITC implementation.

https://github.com/mynenik/kForth-64/blob/master/forth-src/ssd.4th

KM

Re: EXECUTE in various forms

<sdbk75$6ra$1@dont-email.me>

 copy mid

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

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: EXECUTE in various forms
Date: Thu, 22 Jul 2021 06:18:59 -0500
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <sdbk75$6ra$1@dont-email.me>
References: <sck1sb$maa$1@dont-email.me> <sd3ppf$r1a$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Jul 2021 11:19:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d58b47826c2bc7299117702410889bf1";
logging-data="7018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zmspRBpv6W3qr3ZQC5s4q"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:EC0BphEHFiP8lax2HfZrROCJCYo=
In-Reply-To: <sd3ppf$r1a$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Thu, 22 Jul 2021 11:18 UTC

On 7/19/21 7:05 AM, Krishna Myneni wrote:
> On 7/13/21 7:44 AM, Krishna Myneni wrote:
....
> Following my original post, I have added a preliminary SEE facility and
> Single-Step Debugger, in Forth source, to the kForth-64 (0.2.x) and
> kForth-32 (2.x) packages. A good bit of common code is needed for both
> SEE and single step debugging for an ITC Forth -- the same might be true
> for a native code Forth.
>
> The code is somewhat dirty and needs additional factoring and use of
> structure member references ( rather than hard coded "n cells +" ), but
> it's also relatively simple to implement. In particular, for ITC code,
> there are two words which are necessary to implement both SEE and the
> single-step debugger
>
> XT>ITC  ( xt -- addr-itc )
> XT>NC   ( xt -- addr-nc  )
> ...

The code has been cleaned up and the single step debugger needs
considerable work to be made useful beyond simple toy examples. However,
SEE is quite usable now (example below). Each line of the SEE output
corresponds to one execution step for the single-step debugger. The
XT>ITC word is the primary non-standard word required to implement SEE
in standard Forth source for an ITC Forth. That is not to say that one
can write a portable SEE or single-step debugger just with this word,
but it is an essential one -- in kForth, we also need XT>NC.

-- KM

( From the kForth example program, qm/lsterms.4th )

\ Given a list of allowed total quantum numbers { ( M_L M_S ) },
\ return a list of allowed terms.

: qs>terms ( 'MLMS -- 'terms )
nil swap
BEGIN dup nil? 0= WHILE \ -- 'terms 'MLMS
dup >r
min_MLMS
2dup 2>r min_qns>term swap cons 2r>
min_qns>list r>
BEGIN over nil? 0= WHILE \ -- 'terms 'list 'MLMS
over first swap remove_MLMS
swap rest swap
REPEAT
nip
REPEAT
drop ;

SEE qs>terms
559B98B33970 NIL
559B98B33979 SWAP
559B98B3397A DUP
559B98B3397B NIL?
559B98B33984 0=
559B98B33985 JZ $6B
559B98B3398E DUP
559B98B3398F >R
559B98B33990 MIN_MLMS
559B98B33999 2DUP
559B98B3399A 2>R
559B98B3399B MIN_QNS>TERM
559B98B339A4 SWAP
559B98B339A5 CONS
559B98B339AE 2R>
559B98B339AF MIN_QNS>LIST
559B98B339B8 R>
559B98B339B9 OVER
559B98B339BA NIL?
559B98B339C3 0=
559B98B339C4 JZ $22
559B98B339CD OVER
559B98B339CE CELL+
559B98B339CF A@
559B98B339D0 SWAP
559B98B339D1 REMOVE_MLMS
559B98B339DA SWAP
559B98B339DB A@
559B98B339DC SWAP
559B98B339DD JMP $-24
559B98B339E6 NIP
559B98B339E7 JMP $-6D
559B98B339F0 DROP
559B98B339F1 RET
ok

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor