Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #38844
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: FORTH - How Does It Work? |
| Date | 2015-05-05 11:36 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2015May5.133634@mips.complang.tuwien.ac.at> (permalink) |
| References | <058a96b0-8a32-476d-b062-a8db0be69130@googlegroups.com> <HJCdnZxcKOLXItrInZ2dnUU7-emdnZ2d@supernews.com> <5547c4e0$0$3072$e4fe514c@dreader35.news.xs4all.nl> <op.xx4yb92nwa0t4m@localhost> |
"Rod Pemberton" <bork@lllljunkqwer.cpm> writes:
>On Mon, 04 May 2015 15:13:36 -0400, Albert van der Horst
><albert@spenarnc.xs4all.nl> wrote:
>
>> Well the OP suggest this to people who want to know how Forth
>> works on the inside. An alternative is to randomly start SEE-ing
>> some code in a Forth you use.
>> For an extreme example take this:
>>
>> Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
>> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
>> Type `bye' to exit
>> SEE TO
>> noname :
>> ' dup >definer 140003129076120 >definer =
>> IF 16 + !
>> ELSE -32 throw
>> THEN ;
>> latestxt
>>
>> noname :
>> COMP' drop dup >definer 140003129076120 >definer over =
>> IF drop 16 + POSTPONE ALiteral 6396632 compile,
>> ELSE 140003129105440 >definer over =
>> IF drop 6397824 compile, 16 + @ lp-offset, 6396656 compile,
>> ELSE 140003129105608 >definer over =
>> IF drop 6397824 compile, 16 + @ lp-offset, 6396632
>> compile,
>>
>> ELSE 140003129105496 >definer over =
>> IF drop 6397824 compile, 16 + @ lp-offset,
>> 6396664
>> compile,
>> ELSE 140003129105552 >definer over =
>> IF drop 6397824 compile, 16 + @
>> lp-offset,
>> 6397288 compile,
>> ELSE -32 throw drop
>> THEN
>> THEN
>> THEN
>> THEN
>> THEN ;
>> latestxt
>> interpret/compile: TO ok
>>
>> Compared to Ting's books this is pretty intimidating.
I guess Ting's books do not cover TO for locals of different types,
plus values.
The source code for this code is:
also locals-types
\ these "locals" are used for comparison in TO
c: some-clocal 2drop
d: some-dlocal 2drop
f: some-flocal 2drop
w: some-wlocal 2drop
:noname
' dup >definer [ ' locals-wordlist ] literal >definer =
if
>body !
else
-&32 throw
endif ;
:noname
comp' drop dup >definer
case
[ ' locals-wordlist ] literal >definer \ value
OF >body POSTPONE Aliteral POSTPONE ! ENDOF
\ !! dependent on c: etc. being does>-defining words
\ this works, because >definer uses >does-code in this case,
\ which produces a relocatable address
[ comp' some-clocal drop ] literal >definer
OF POSTPONE laddr# >body @ lp-offset, POSTPONE c! ENDOF
[ comp' some-wlocal drop ] literal >definer
OF POSTPONE laddr# >body @ lp-offset, POSTPONE ! ENDOF
[ comp' some-dlocal drop ] literal >definer
OF POSTPONE laddr# >body @ lp-offset, POSTPONE 2! ENDOF
[ comp' some-flocal drop ] literal >definer
OF POSTPONE laddr# >body @ lp-offset, POSTPONE f! ENDOF
-&32 throw
endcase ;
interpret/compile: TO ( c|w|d|r "name" -- ) \ core-ext,local
The code is pretty opaque, because it deals with a number of issues,
like how to determine whether a word is a value, or a local, and if
so, of which type; or how to write this code so that it works with the
image relocation scheme that Gforth uses; or how locals are
implemented.
>It seems that the constants beginning with digit '6' might be XTs
>due to COMPILE, . I could guess that >DEFINER takes the constants
>which begin with '14', but what is >DEFINER ?
The numbers starting with 6 are xts of primitives like C!. The
numbers starting with 14 are addresses in the dictionary; in this
case, I think that they are all xts. Concerning >DEFINER, here's the
documentation:
|>definer xt -- definer gforth '>definer'
|
|Definer is a unique identifier for the way the xt was defined. Words
|defined with different does>-codes have different definers. The
|definer can be used for comparison and in definer!.
>
>Are the large constants the XTs of primitive words?
>Are they the XTs of NONAME words?
>
>Can I execute '6397824'? (Yes.)
>Can I execute '140003129105440'? ...
>Can I display their name or SEE their code?
Try it. XT-SEE ( xt -- ) may help you with SEEing it.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
FORTH - How Does It Work? Jason Damisch <jasondamisch@yahoo.com> - 2015-05-04 09:44 -0700
FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-04 10:21 -0700
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-04 11:00 -0700
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-05 03:03 -0700
Re: FORTH - How Does It Work? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-05-05 11:31 +0000
Re: FORTH - How Does It Work? lehs <skydda.barnen@gmail.com> - 2015-05-05 01:31 -0700
Re: FORTH - How Does It Work? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-05-05 08:49 +0000
Re: FORTH - How Does It Work? Lars Brinkhoff <lars.spam@nocrew.org> - 2015-05-05 11:16 +0200
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-05 02:33 -0700
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-04 08:49 -1000
Re: FORTH - How Does It Work? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-05-04 19:13 +0000
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-04 20:35 +0100
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-04 10:43 -1000
Re: FORTH - How Does It Work? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-05-05 08:52 +0000
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-05 10:54 +0100
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-05 10:56 +0100
Re: FORTH - How Does It Work? "Rod Pemberton" <bork@lllljunkqwer.cpm> - 2015-05-04 20:01 -0400
Re: FORTH - How Does It Work? Jason Damisch <jasondamisch@yahoo.com> - 2015-05-04 17:23 -0700
Re: FORTH - How Does It Work? Jason Damisch <jasondamisch@yahoo.com> - 2015-05-04 17:34 -0700
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-05 00:25 -0700
Re: FORTH - How Does It Work? Coos Haak <chforth@hccnet.nl> - 2015-05-05 12:41 +0200
Re: FORTH - How Does It Work? "Rod Pemberton" <bork@lllljunkqwer.cpm> - 2015-05-05 03:31 -0400
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-05 08:41 +0100
Re: FORTH - How Does It Work? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-05-05 11:36 +0000
Re: FORTH - How Does It Work? "HAA" <someone@microsoft.com> - 2015-05-07 11:26 +1000
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-06 16:46 -1000
Re: FORTH - How Does It Work? lehs <skydda.barnen@gmail.com> - 2015-05-07 00:06 -0700
Re: FORTH - How Does It Work? "HAA" <someone@microsoft.com> - 2015-05-10 12:57 +1000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-09 21:36 -0700
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-09 18:36 -1000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-09 22:09 -0700
Re: FORTH - How Does It Work? Walter Banks <walter@bytecraft.com> - 2015-05-10 13:38 -0400
Re: FORTH - How Does It Work? Richard Owlett <rowlett@cloud85.net> - 2015-05-10 14:23 -0500
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-10 20:51 +0100
Re: FORTH - How Does It Work? Coos Haak <chforth@hccnet.nl> - 2015-05-11 01:18 +0200
Apology to Walter Banks - was [Re: FORTH - How Does It Work?] Richard Owlett <rowlett@cloud85.net> - 2015-05-10 23:09 -0500
Re: Apology to Walter Banks - was [Re: FORTH - How Does It Work?] Walter Banks <walter@bytecraft.com> - 2015-05-11 07:24 -0400
Re: Apology to Walter Banks - was [Re: FORTH - How Does It Work?] rickman <gnuarm@gmail.com> - 2015-05-11 11:34 -0400
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-10 19:18 -0700
Re: FORTH - How Does It Work? Walter Banks <walter@bytecraft.com> - 2015-05-11 07:50 -0400
Re: FORTH - How Does It Work? beeflo <beeflobill@gmail.com> - 2015-05-11 09:37 -0700
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 11:32 -0700
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-12 05:21 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-12 14:08 +0100
Re: FORTH - How Does It Work? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-05-12 14:52 +0000
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-12 17:18 +0100
Re: FORTH - How Does It Work? Lars Brinkhoff <lars.spam@nocrew.org> - 2015-05-13 08:41 +0200
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-13 08:07 +0100
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-13 19:29 -0700
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-12 08:10 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-12 17:13 +0100
Re: FORTH - How Does It Work? Jason Damisch <jasondamisch@yahoo.com> - 2015-05-12 09:33 -0700
Re: FORTH - How Does It Work? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-05-12 15:38 +0000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-12 21:51 -0700
Re: FORTH - How Does It Work? "WJ" <w_a_x_man@yahoo.com> - 2015-05-12 16:05 +0000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-14 17:26 -0700
Re: FORTH - How Does It Work? bettilyona@gmail.com - 2015-06-02 10:21 -0700
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-06-02 20:39 -0700
Re: FORTH - How Does It Work? bettilyona@gmail.com - 2015-06-08 13:14 -0700
Re: FORTH - How Does It Work? Hans Bezemer <the.beez.speaks@gmail.com> - 2015-06-20 13:15 +0200
Re: FORTH - How Does It Work? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-06-20 14:37 +0000
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-06-20 08:23 -1000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-06-20 19:24 -0700
Re: FORTH - How Does It Work? Hans Bezemer <the.beez.speaks@gmail.com> - 2015-06-21 12:30 +0200
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-06-21 20:58 +0100
Re: FORTH - How Does It Work? Bernd Paysan <bernd.paysan@gmx.de> - 2015-06-22 00:13 +0200
Re: FORTH - How Does It Work? "HAA" <someone@microsoft.com> - 2015-05-11 12:10 +1000
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 11:35 -0400
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-11 16:52 +0100
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-11 08:12 -1000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 12:37 -0700
Re: FORTH - How Does It Work? Walter Banks <walter@bytecraft.com> - 2015-05-11 15:59 -0400
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-11 21:34 +0100
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 16:42 -0400
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-11 21:52 +0100
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 14:55 -0700
Re: FORTH - How Does It Work? "WJ" <w_a_x_man@yahoo.com> - 2015-05-12 16:22 +0000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-12 22:42 -0700
Re: FORTH - How Does It Work? Jason Damisch <jasondamisch@yahoo.com> - 2015-05-13 11:18 -0700
Re: FORTH - How Does It Work? "WJ" <w_a_x_man@yahoo.com> - 2015-05-25 15:04 +0000
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 20:38 -0400
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 14:31 -0700
Re: FORTH - How Does It Work? Walter Banks <walter@bytecraft.com> - 2015-05-12 07:06 -0400
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-11 21:30 +0100
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 14:52 -0700
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 20:40 -0400
Re: FORTH - How Does It Work? Bernd Paysan <bernd.paysan@gmx.de> - 2015-05-12 03:38 +0200
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 22:10 -0400
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 20:25 -0700
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-12 01:13 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-12 11:03 +0100
Re: FORTH - How Does It Work? Bernd Paysan <bernd.paysan@gmx.de> - 2015-05-12 16:08 +0200
Re: FORTH - How Does It Work? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-05-12 14:04 +0000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 19:08 -0700
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 22:46 -0400
Re: FORTH - How Does It Work? "HAA" <someone@microsoft.com> - 2015-05-14 18:30 +1000
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-13 22:55 -1000
Re: FORTH - How Does It Work? "HAA" <someone@microsoft.com> - 2015-05-16 05:08 +1000
Re: FORTH - How Does It Work? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-15 09:54 -1000
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-20 13:59 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-14 10:40 +0100
Re: FORTH - How Does It Work? Mark Wills <markwills1970@gmail.com> - 2015-05-14 03:12 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-14 12:03 +0100
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-10 22:09 -0700
Re: FORTH - How Does It Work? Jason Damisch <jasondamisch@yahoo.com> - 2015-05-11 10:12 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-11 18:57 +0100
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-11 11:48 -0700
Re: FORTH - How Does It Work? "Alex McDonald" <blog@rivadpm.com> - 2015-05-11 20:28 +0100
Re: FORTH - How Does It Work? hughaguilar96@gmail.com - 2015-05-12 21:28 -0700
Re: FORTH - How Does It Work? rickman <gnuarm@gmail.com> - 2015-05-11 11:29 -0400
Re: FORTH - How Does It Work? Ching-Tang Tseng <ilikeforth@gmail.com> - 2015-05-04 19:40 -0700
Re: FORTH - How Does It Work? tthomas@duelcraft2.com - 2015-05-08 16:22 -0700
csiph-web