User Tools

Site Tools


en:pfw:kangoeroe

Kangaroo method

The “lone” DOES> is used for the creation of only one word rather than for the creation of a category of words. simple example in noForth

create .DAY ( n -- )  s" SunMonTueWedThuFriSat ? " m, align
    does> swap 7 umin 3 * + 3 type ;

example in noForth

create :
    assembler   ip push   w ip mov   next   forth   \ DOCOL
    does> create here cell- doer! ] ;               \ Action

or

:noname     does> create here cell- doer! ] ;
create :
    assembler   ip push   w ip mov   next   forth
execute

“faraway” DOES> for forward references in metacompiler

create :
    assembler   ip push   w ip mov   next   forth
    ... \ many other definitions
TELL : TO-DO: create here cell- doer! ] ;

literal pool in assembler words with CODE>

code !RP0  ( -- )
    ramadr: RP0 ,       \ register w points to this literal
    code>   day  w ) ldr,
            day  day ) ldr,
            rp day mov,
    next, end-code

(an)

Please add your comments below.

Discussion

Ulrich Hoffmann, 2023-07-24 18:32, 2023-07-24 18:33

The same technique works in gforth:

create .DAY ( n -- )  s" SunMonTueWedThuFriSat ? " here over allot swap cmove
   does> swap 7 umin 3 * + 3 type ;

0 .DAY ( Sun ok )
5 .DAY ( Fri ok )
You could leave a comment if you were logged in.
en/pfw/kangoeroe.txt · Last modified: 2023-09-04 18:16 by uho