Account Options

  1. Sign in
Google Groups Home
« Groups Home
Message from discussion Build your own Forth for Microchip PIC (Episode 838): Threading
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
none Byron Jeff  
View profile  
 More options Jun 24 2007, 8:40 am
Newsgroups: comp.lang.forth
From: byron@upstairs.(none) (Byron Jeff)
Date: Sun, 24 Jun 2007 07:40:31 -0500
Local: Sun, Jun 24 2007 8:40 am
Subject: Re: Build your own Forth for Microchip PIC (Episode 838): Threading
In article <1182664370.207959.205...@w5g2000hsg.googlegroups.com>,
Bruce McFarling  <agil...@netscape.net> wrote:

>On Jun 23, 6:32 pm, byron@upstairs.(none) (Byron Jeff) wrote:
>> 48 words. Ouch! When bootstrapping the primitives are critical.

>They can be reduced. Some by simply omitting them, when they are
>primitives because they cannot be synthesized from other words, but
>you do not require them. If there is no dictionary and no interpreter
>in the PIC, then that may increase the number of primitives that may
>be dispensed with.

Possibly. But you have to analyze the entire core tree to determine if a
word is in fact not needed.

>Others by synthesizing them from a simpler Forth model.

This is what I've been looking for. A factored primitive model that is
architecture independent along with a coding of core words from that
model.

For example:
---------

>A ... from data stack to an address pointer

A> ... from pointer to data stack.

A! ... store cell on stack at address in A
A@ ... fetch cell at address in A and write to stack

A+ ... increment value in A

>R ... from data stack to return stack, and

R> ... from return stack to data stack
-----------

Now that's an easily implementable model. Only one question:

1. From the description above for A! and the descriptions for ! and 2!
below the value to store is in A and the address is on the stack, right?
Something doesn't match up.

: DROP ( x -- ) >A ;
: DUP ( x -- x x ) >A A> A> ;
: OVER ( xa xb -- xa xb xa ) >R >A A> R> A> ;
: SWAP ( xa xb -- xb xa ) >R >A R> A> ;
: ROT ( xa xb xc -- xb xc xa ) >R >R >A R> R> A> ;
: @ ( a -- x ) >A A@ ;
: ! ( x a -- ) >A A! ;

\ two address units per cell
: 2@ ( a -- xl xh ) >A A@ >R A+ A+ A@ R> ;
: 2! ( xl xh a -- ) >A A! A+ A+ A! ;

\ one address unit per cell
: 2@ ( a -- xl xh ) >A A@ >R A+ A@ R> ;
: 2! ( xl xh a -- ) >A A! A+ A! ;

: 1+ ( x -- x+1 ) >A A+ A> ;
: 2+ ( x -- x+2) >A A+ A+ A> ;

: R@ ( -- x | R: x -- ) R> >A A> A> R> ;
: 2>R ( xl xh -- | R: -- xl xh ) >A >R A> >R ;
: 2R> ( -- xl xh | R: xl xh -- ) R> >A R> A> ;

>etc. ... presumably in this context, after getting the boostrap up and
>running, the more cumbersome definitions may be replaced.

Exactly.

Thanks.

BAJ


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.