Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13858
| Date | 2012-07-11 21:11 +0200 |
|---|---|
| From | Fanzo <cristianof6@gmail.com> |
| Newsgroups | comp.lang.forth |
| Subject | Re: colon colon |
| References | <4ffc6c61$0$1375$4fafbaef@reader2.news.tin.it> <jtjbpa$udi$1@speranza.aioe.org> |
| Message-ID | <4ffdcf39$0$1378$4fafbaef@reader2.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
Rod Pemberton wrote:
> "Fanzo" <cristianof6@gmail.com> wrote in message
> news:4ffc6c61$0$1375$4fafbaef@reader2.news.tin.it...
>> Developing my own forth, im tring to make all definitions as possible
>> from inside the minimal interpreter.
>>
>> So the result is "write only language"
>>
>> I had difficulties to understand what i did one month ago
>> to define "colon"
>>
>>
>> createheader :
>> 1301 ,
>> 32 word createheader find
>> now 501 ,n 801 ,n execute , | compile DROP on the fly
>> 1301 ,
>> 32 word smudge find
>> now execute ,
>> 1301 ,
>> 32 word ] find
>> now execute ,
>> 801 ,
>>
>> 101 load
>
> Did you have a question?
>
> If you did, it might be:
>
> 1) can you tell me what I did?
> 2) can you post a high level version of what I did?
> 3) is this done correctly?
>
> I'm not sure exactly what you're doing. It's too custom to your Forth.
> You'd have to explain it to me. If I take a guess, then it looks like you
> tried to define : (colon) without having : (colon) defined. Defining
> : (colon) and ; (semis) without them already being defined can be done.
> This
> will definately not be for ANS. I don't know what "now" is or "1301". I
> can assume 1301 is ENTER or DOCOL.
>
>
> Instead of posting : (colon) in terms of : (colon) you might post your
> high-level Forth definition for : (colon).
>
> It could look something like this:
>
> : : (CREATE) COMPILE ENTER ] SMUDGE ;
>
> Then, you'll need to expand the definitions used within until the definition
> is in terms of low-level words or primitives. It'll also need to work
> interactively. Next, you'll need to rework it to work without using :
> (colon) and ; (semis). You need some method to look up and compile words,
> either " ' SMUDGE , " or " BL WORD FIND " in order to compile ENTER
> or it's equivalent.
>
>
> If we break it down:
>
>> createheader :
>
> This likely creates a dictionary entry for : (colon). "createheader"
> appears to be your low-level or primitive for CREATE. Some Forth's
> call it (CREATE). I.e.,
>
> (CREATE) :
>
>> 1301 ,
>
> Stores 1301 into the definition... What is 1301? It might be ENTER or
> DOCOL. E.g.,
>
> LIT ENTER ,
>
> Unfortunately, you've used "1301 ," three times, so "LIT ENTER ," doesn't
> make much sense to me...
>
>> 32 word createheader find
>
> BL WORD (CREATE) FIND
>
> This FINDs the XT for createheader.
>
>> now 501 ,n 801 ,n execute , | compile DROP on the fly
>
> I guess it "compile[s] DROP on the fly". This would be to get rid of the
> flag from FIND.
>
>> 1301 ,
> ...
>
>> 32 word smudge find
>
> BL WORD SMUDGE FIND
>
> This FINDs the XT for SMUDGE
>
>> now execute ,
>
> I still don't know what "now" does. It seems to be used like LIT. E.g.,
>
> LIT EXECUTE ,
>
> If so, then "now execute ," compiles the XT for EXECUTE which will execute
> the XT for SMUDGE.
>
>> 1301 ,
>
> ...
>
>> 32 word ] find
>
> BL WORD ] FIND
>
> This FINDs the XT for ]
>
>> now execute ,
>
> Still assuming "now" is LIT, then "" compiles the XT for EXECUTE which will
> execute the XT for ].
>
>> 801 ,
>
> Stores 801 into the definition... Either 501 or 801 is DROP, but I'm not
> sure which is which. It's possible 501 is DROP and 801 is ; (semis).
>
>> 101 load
> ...
>
> Even though you used "1301 ," three times, it still seems to be a definition
> for : (colon) without : (colon). As best I can tell, you did something
> similar to this:
> (CREATE) :
> LIT DOCOL , BL WORD (CREATE) FIND DROP ,
> LIT DOCOL , BL WORD SMUDGE FIND LIT EXECUTE ,
> LIT DOCOL , BL WORD ] FIND LIT EXECUTE , LIT ;S ,
>
> I suspect I've converted something incorrectly...
>
> Anyway, I think it should be something closer to this:
> (CREATE) :
> LIT DOCOL ,
> BL WORD (CREATE) FIND DROP ,
> LIT LIT , LIT DOCOL , LIT , ,
> BL WORD SMUDGE FIND DROP ,
> BL WORD ] FIND DROP ,
>
> But, I'm not an expert on that ...
>
>
> Rod Pemberton
>
>
>
>
>
It was not a question, just my enjoying in the trying to reduce my Forth
interpreter to a minimum.
Your analisys is very detailed considering the specific of my
implementation (not ANS).
It is not threaded, it is like this:
CALL xt CALL xt CALL xt OPCODE OPCODE OPCODE .... RET
There is not threads (then no ENTERs), i dont kown how it is called.
Every "definitions" are the same, only opcodes; a typical definition is
a sequence of CALL xt.
createheader : | create a word header (link, len/flags, name)
1301 , | opcode for CALL
32 word createheader find | correct as you said
now 501 ,n 801 ,n execute ,
1301 ,
32 word smudge find
now execute ,
1301 ,
32 word ] find
now execute ,
801 , | opcode for RET
"now" and ",n" are a custom words to compile a temporary routine with
opcodes in a persistent reusable buffer. "Now" reset the compiling index
and leaves the xt on the stack that execute will calls.
It Is an experiment. This is because i still dont have DROP defined
501 is POP, 801 is RET.
Anyway colon is still defined at that moment.
My future direction is to define as maximum, a block editor then a
a basic compiler with definitions for every OPCODE (24), literals, and
five or six auxiliary immediate words.
Goodbye
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
colon colon Fanzo <cristianof6@gmail.com> - 2012-07-10 19:58 +0200
Re: colon colon "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-11 04:01 -0400
Re: colon colon Mark Wills <markrobertwills@yahoo.co.uk> - 2012-07-11 02:01 -0700
Re: colon colon Fanzo <cristianof6@gmail.com> - 2012-07-11 21:11 +0200
Re: colon colon "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-12 05:15 -0400
Re: colon colon Fanzo <cristianof6@gmail.com> - 2012-07-12 19:58 +0200
csiph-web