Build your own Forth for Microchip PIC (Episode 838): Threading : Forth
This is a discussion on Build your own Forth for Microchip PIC (Episode 838): Threading within the Forth forums in Programming Languages category; In article <1182664370.207959.205430 @ w5g2000hsg.googlegroups.com>, Bruce McFarling <agila61 @ 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 ****yze the entire core tree to determine if a word is ...
| Forth Forth programming language |
![]() |
| | LinkBack | Thread Tools |
|
#11
| |||
| |||
| Bruce McFarling <agila61@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 ****yze 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 |
|
#12
| |||
| |||
| On Jun 24, 8:40 am, byron@upstairs.(none) (Byron Jeff) wrote: > Possibly. But you have to ****yze the entire core tree > to determine if a word is in fact not needed. That ****ysis would be possible with a text editor with a search function. Start at the back, go to the definition you want to omit in the colon definition model that rests on the 48 primitives, do a text search for the word, and it quickly becomes clear if it is used. Delete it if not. Keep going up until the colon definitions are trimmed down. Then start at the primitives, and do the same search ... through the colon definition file, since the primitives in MAF are defined using the underlying Forth-94 system. Then reduce the primitives as below ... I don't think the primitives should reduce below 16, but they could definitely get below 32. > 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? No, the address is in A, and the value is on the stack. ! has the address on top and the value to store underneath it. That was off the top of my heads (I used some of those to save space in trying to implement a STC for a 6502, part of it is attractive) ... maybe the mneumonic is properly @A and !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 ; These are the ones that I can recall off the top of my head, because given the size of 2@ and 2! with an X-indexed data stack on the 65C02, "A" as a 16-bit zero page location is attractive for cutting the size of the kernel. |
|
#13
| |||
| |||
| In article <1182717845.090300.9860@p77g2000hsh.googlegroups.com>, Bruce McFarling <agila61@netscape.net> wrote: >On Jun 24, 8:40 am, byron@upstairs.(none) (Byron Jeff) wrote: >> Possibly. But you have to ****yze the entire core tree >> to determine if a word is in fact not needed. > >That ****ysis would be possible with a text editor with a search >function. > >Start at the back, go to the definition you want to omit in the colon >definition model that rests on the 48 primitives, do a text search for >the word, and it quickly becomes clear if it is used. Delete it if >not. Keep going up until the colon definitions are trimmed down. > >Then start at the primitives, and do the same search ... through the >colon definition file, since the primitives in MAF are defined using >the underlying Forth-94 system. OK. That makes sense. >Then reduce the primitives as below ... I don't think the primitives >should reduce below 16, but they could definitely get below 32. > >> 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? > >No, the address is in A, and the value is on the stack. ! has >the address on top and the value to store underneath it. >That was off the top of my heads (I used some of those to >save space in trying to implement a STC for a 6502, part >of it is attractive) ... maybe the mneumonic is properly @A >and !A You are of course correct. For some reason I imprinted in my mind that the TOS was on the left. That's what I get for not actually reading the description of the notation. Some kind soul pointed out to me on my bytecode description post. > >> : @ ( 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 ; > >These are the ones that I can recall off the top of >my head, because given the size of 2@ and 2! with an >X-indexed data stack on the 65C02, "A" as a 16-bit >zero page location is attractive for cutting the >size of the kernel. It's very helpful. Thanks. I'll think it through as I'm working through the MAF definitions. BAJ |
![]() |
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ADO episode | usenet | ADO DAO RDO RDS | 5 | 10-05-2007 10:35 AM |
| Build your own Forth for Microchip PIC (Episode 837) | usenet | Forth | 95 | 07-21-2007 10:06 AM |
| Build your own Forth for microchip PIC (Episode 839) | usenet | Forth | 8 | 06-24-2007 12:45 PM |
| [RBtv] Episode 4: Entering the Tic Tac Factory | usenet | basic.visual | 0 | 06-08-2007 07:05 PM |
| Re: Build your own Forth for Microchip PIC: the nature of metacompilation | usenet | Forth | 0 | 01-01-1970 12:00 AM |


