Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #13886

Re: colon colon

From "Rod Pemberton" <do_not_have@notemailnot.cmm>
Newsgroups comp.lang.forth
Subject Re: colon colon
Date 2012-07-12 05:15 -0400
Organization Aioe.org NNTP Server
Message-ID <jtm4g7$dr9$1@speranza.aioe.org> (permalink)
References <4ffc6c61$0$1375$4fafbaef@reader2.news.tin.it> <jtjbpa$udi$1@speranza.aioe.org> <4ffdcf39$0$1378$4fafbaef@reader2.news.tin.it>

Show all headers | View raw


"Fanzo" <cristianof6@gmail.com> wrote in message
news:4ffdcf39$0$1378$4fafbaef@reader2.news.tin.it...
>
> 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).

I recently tried to implement both : (colon) and ; (semis) in terms of
primitives or low-level words.

I have them as high-level Forth in my definitions file which gets parsed,
but that requires many words to already be defined just to parse the high
level definitions for them.

I also have them as pre-compiled Forth words so the Forth interpreter can
startup or bootstrap.  Without them, I can't parse my definitions file.

So, I was attempting to implement them first in my definitions file in terms
of primitives or low-level words.  Then, I could eliminated the pre-compiled
versions.

The solution is not completed yet, but seems close.

> It is not threaded, it is like this:
>
> CALL xt CALL xt CALL xt OPCODE OPCODE OPCODE .... RET

In the context of Forth, that's called STC, i.e., Subroutine Threaded Code.
It's just assembly.

> There is not threads (then no ENTERs), i dont kown how it is called.

For STC, you're using normal assembly.  You don't have an interpreter.  So,
interpreter words like ENTER or DOCOL or EXIT are unneeded.

> CALL xt CALL xt CALL xt OPCODE OPCODE OPCODE .... RET

For DTC or ITC, that would would be comprised of two words.

The first part of that word would just be the addresses or xt's:
xt xt xt xt

The OPCODEs above would be replaced by an xt for the routine.  That will
be interpreted.

The routine part would also be it's own word:
OPCODE OPCODE OPCODE ... RET

For DTC or ITC, the CFA field tells whether to execute or interpret the
word.  So, the first word of xt's is interpreted and the second word with
OPCODEs is executed.  It's called a primitive or low-level word.  The first
word has it's CFA set to ENTER.  ENTER is an address interpreter.
Basically, ENTER calls the xt's.  The second word has it's CFA set to the
address of the routine.

> 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.
>

DROP can be an unused POP.  Do you have a spare register?

DROP might be implementable in others ways, e.g.:

 0 AND OR

 >R RDROP

 A!  \ store into variable

> 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.
>

Good luck,


Rod Pemberton


Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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