FPForth
deSilva
Posts: 2,967
"frohf" has now finally posted his first Forth for the Propeller.
(a) Use it from a terminal window @19,200 baud. Ariba is just testing a new PropTerminal for it
(b) Details see below; some "FORTH for Dummies" will follow
(c) There are obviously some problems with the early versions... I try to keep you up to date so you need not wonder
Status FPForth 0.72
- stack underflow issue has been fixed
- auto Hydra recognition, so there is no extra binary for the hydra any longer!
- Frohf has prepared a short but comprehensiv PDF with a list of all implemented WORDs
Issues
- ." does not work correctly
Some WORDs explained - (0.71):
WORD ( Stack before -- Stack after ; <string> ) C/I/COG
C = Compile only
I = Immediate
COG = executed inside the COG without any internal reference to the HUB
"Stack Notation" as standard with FORTH, using the following data descriptors:
! ( w a -- ) COG
Stores 16 bit of a value value w to address a
# ( d -- d )
Converts one character of a number. The number is converted according to actual number base
#> ( d -- b u )
Limits output string. Yields string address u and length b.
#S ( ud -- 0 0 )
Generates number string by calling # until the number is converted.
' ( -- ca ; <string> )
Displays code address ca of the trailing word <string>
( ( -- ; <string> ) I
Starts a comment upto next ')'
* ( n n -- n ) COG
16 bit (!) multiplication
+ ( w w -- w ) COG
addition
+! ( n a -- )
Add n to (16 bit??) cell at address a.
- ( w w -- w )
Subtraction
. ( n -- )
Display 32bit number after convertion according to actual number base
/ ( n n -- q )
32 bit division
/MOD ( n1 n2 -- n3 n4 ) COG
n1/n2 = n3 remainder n4.
0< ( n -- t ) COG
TRUE if n<0
< ( n1 n2 -- t ) COG
TRUE if n1<n2
= ( w1 w2 -- t ) COG
TRUE if W1==w2
@ ( a -- w ) COG
pushes the 16bit value from address a
2/ ( n -- n ) COG
fast divide by 2
2* ( n -- n ) COG
fast multiply with 2
2! ( w a -- ) COG
Store 32bit value w to address a
2@ ( a -- w ) COG
pushes the 32 bit value from address a
0 1 2 -1 COG
the very numbers 0, 1, 2, and -1
1+ ( n -- n ) COG
fast plus 1
1- ( n -- n ) COG
fast minus 1
2+ ( n -- n ) COG
fast plus 2
2- ( n -- n ) COG
fast minus 2
@EXECUTE ( a -- ) COG
executes any token <> 0 at address a.
ABS ( n -- +n ) COG.
AND ( w w -- w ) COG
BL ( -- c )
pushes a space ("blank character")
C! ( c b -- ) COG
stores 8 bit value c at address b
C@ ( b -- c ) COG
pushes 8 bit value from address b
COG! ( w cca -- ) COG
stores a 32bit value w to COG register cca.
COG@ ( cca -- w ) COG
pushes a 32bit value w from COG register cca.
BINARY ( -- )
Set number base to 2
DIRA ( n -- ) COG
EMIT ( w -- )
send w to the standard serial port
DECIMAL ( -- )
Set number base to 10
DROP ( w -- ) COG
DUMP ( a u -- )
Display u characters starting at address a
DUP ( w -- w w ) COG
HEX ( -- )
set number base to 16
I ( -- w ;R -- ) COG
copies value w from the return stack to the data stack.
I+ ( R n -- n+ )
increment return address
I- ( R n -- n- )
decrement return address
OUTA ( -- n ) COG
MAX ( n1 n2 -- n )
MIN ( n1 n2 -- n )
MOD ( n1 n2 -- n )
remainder
NEGATE ( n -- n )
NOP ( -- )
no operation
NOT ( n -- n ) COG
inverts each bit
OUTA ( n -- ) COG
OR ( w w -- w ) COG
OCTAL ( -- )
Set numbert base to 8
OVER ( w1 w2 -- w1 w2 w1 ) COG
R> ( -- w ;R w -- ) COG
removes return address and pushes it to the data stack.
R@ ( -- w ;R -- ) COG
pushes return address to the data stack without removing it
ROT ( w1 w2 w3 -- w2 w3 w1 ) COG
SWAP ( w1 w2 -- w2 w1 ) COG
TRUE ( -- T ) COG
same as -1
WITHIN ( u lo hi -- t )
TRUE if lo<=u<=hi
WAITTICKS ( n -- ) COG
as WAITCNT(CNT+n)
WORDS ( -- )
lists all defined words
XOR ( w w -- w ) COG
Post Edited (deSilva) : 10/16/2007 6:31:54 PM GMT
(a) Use it from a terminal window @19,200 baud. Ariba is just testing a new PropTerminal for it
(b) Details see below; some "FORTH for Dummies" will follow
(c) There are obviously some problems with the early versions... I try to keep you up to date so you need not wonder
Status FPForth 0.72
- stack underflow issue has been fixed
- auto Hydra recognition, so there is no extra binary for the hydra any longer!
- Frohf has prepared a short but comprehensiv PDF with a list of all implemented WORDs
Issues
- ." does not work correctly
Some WORDs explained - (0.71):
WORD ( Stack before -- Stack after ; <string> ) C/I/COG
C = Compile only
I = Immediate
COG = executed inside the COG without any internal reference to the HUB
"Stack Notation" as standard with FORTH, using the following data descriptors:
a Aligned Address b Byte Address c Character f Flag, TRUE or FALSE n Signed integer t Flag, TRUE or FALSE u Unsigned integer w general value T TRUE F FALSE na Name Address la Link Address ca Code Address cca COG Address <string> indicates a specific use of the trailing characters, e.g. SEE WORDS
! ( w a -- ) COG
Stores 16 bit of a value value w to address a
# ( d -- d )
Converts one character of a number. The number is converted according to actual number base
#> ( d -- b u )
Limits output string. Yields string address u and length b.
#S ( ud -- 0 0 )
Generates number string by calling # until the number is converted.
' ( -- ca ; <string> )
Displays code address ca of the trailing word <string>
( ( -- ; <string> ) I
Starts a comment upto next ')'
* ( n n -- n ) COG
16 bit (!) multiplication
+ ( w w -- w ) COG
addition
+! ( n a -- )
Add n to (16 bit??) cell at address a.
- ( w w -- w )
Subtraction
. ( n -- )
Display 32bit number after convertion according to actual number base
/ ( n n -- q )
32 bit division
/MOD ( n1 n2 -- n3 n4 ) COG
n1/n2 = n3 remainder n4.
0< ( n -- t ) COG
TRUE if n<0
< ( n1 n2 -- t ) COG
TRUE if n1<n2
= ( w1 w2 -- t ) COG
TRUE if W1==w2
@ ( a -- w ) COG
pushes the 16bit value from address a
2/ ( n -- n ) COG
fast divide by 2
2* ( n -- n ) COG
fast multiply with 2
2! ( w a -- ) COG
Store 32bit value w to address a
2@ ( a -- w ) COG
pushes the 32 bit value from address a
0 1 2 -1 COG
the very numbers 0, 1, 2, and -1
1+ ( n -- n ) COG
fast plus 1
1- ( n -- n ) COG
fast minus 1
2+ ( n -- n ) COG
fast plus 2
2- ( n -- n ) COG
fast minus 2
@EXECUTE ( a -- ) COG
executes any token <> 0 at address a.
ABS ( n -- +n ) COG.
AND ( w w -- w ) COG
BL ( -- c )
pushes a space ("blank character")
C! ( c b -- ) COG
stores 8 bit value c at address b
C@ ( b -- c ) COG
pushes 8 bit value from address b
COG! ( w cca -- ) COG
stores a 32bit value w to COG register cca.
COG@ ( cca -- w ) COG
pushes a 32bit value w from COG register cca.
BINARY ( -- )
Set number base to 2
DIRA ( n -- ) COG
EMIT ( w -- )
send w to the standard serial port
DECIMAL ( -- )
Set number base to 10
DROP ( w -- ) COG
DUMP ( a u -- )
Display u characters starting at address a
DUP ( w -- w w ) COG
HEX ( -- )
set number base to 16
I ( -- w ;R -- ) COG
copies value w from the return stack to the data stack.
I+ ( R n -- n+ )
increment return address
I- ( R n -- n- )
decrement return address
OUTA ( -- n ) COG
MAX ( n1 n2 -- n )
MIN ( n1 n2 -- n )
MOD ( n1 n2 -- n )
remainder
NEGATE ( n -- n )
NOP ( -- )
no operation
NOT ( n -- n ) COG
inverts each bit
OUTA ( n -- ) COG
OR ( w w -- w ) COG
OCTAL ( -- )
Set numbert base to 8
OVER ( w1 w2 -- w1 w2 w1 ) COG
R> ( -- w ;R w -- ) COG
removes return address and pushes it to the data stack.
R@ ( -- w ;R -- ) COG
pushes return address to the data stack without removing it
ROT ( w1 w2 w3 -- w2 w3 w1 ) COG
SWAP ( w1 w2 -- w2 w1 ) COG
TRUE ( -- T ) COG
same as -1
WITHIN ( u lo hi -- t )
TRUE if lo<=u<=hi
WAITTICKS ( n -- ) COG
as WAITCNT(CNT+n)
WORDS ( -- )
lists all defined words
XOR ( w w -- w ) COG
Post Edited (deSilva) : 10/16/2007 6:31:54 PM GMT
Comments
Thanks for all of your contributions to the forum.
Would it be possible to add a "bignum" function to FPForth... I would like to do completely unscaled integer math on the Prop. For example... adding two integers the size of the Encyclopedia Britanica together.
Rich
It has been years since I have done anything in Forth so I have some relearning to do. Someone else might have some better recommendations but I am starting by reading two·of Leo Brodie's books·that are available on the Internet
Thanks frohf for developing this and thanks deSilva for keeping up informed!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BioProp: Robotics - Powered by Bioloids and controlled by the Propeller
Any chance that this propeller forth will support CREATE ... DOES> ? Last that I looked on the German forum I didn't see DOES> present. I don't know if it's missing due to technical difficulty, ideology (e.g. Ting's eForth), or maybe I just missed it.
I added the list of implemented words. There is no specific limit to it: Frohf will will most likely implement what he needs and where a request is for...
Note that there is a small kernel of words totally implemented inside the COG.
It might be important to know that the complete stack is also allocated inside the COG, limiting its size considerably, but without any bad effects so far....
Leon
Edit:
I had the terminal program set for CR/LF. Changing it to CR only got it working properly.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Post Edited (Leon) : 9/29/2007 5:44:24 PM GMT
I don't wont my time to be wasted like it was on the last Forth I tried...
LewisD
FPForth will undergoe still some basic revisions.
And you cannot waste too much time as long as there is just a binary
Personally I am waiting for Propeller Terminal support via PC_Interface and the ability to call my own Bioloid communication driver code. In the mean time, I am re-learning Forth and working on my driver and sensor code.
By the way, What was changed in version 0.70 other than the·crystal speed?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BioProp: Robotics - Powered by Bioloids and controlled by the Propeller
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
I am concerned that it may be abandoned.
I am very interested in using a Forth for my robot projects...
LewisD
Of course this can always happen with any one-man-project...
But we think it has first to get some internal stabiliity before it should be allowed to "spawn" into variants...
The community is small.. In fact I have no idea how large at all!? This forum has 10,000 users, so 20k to 30 k may be a good guess - but may be not...
<Edit> My mistake!! 10 k is the count for ALL Parallax forums, impossible to separate them. So according to popularity, history, and the "feeling" from the Propeller forum, I should say there are 1k interested in propeller rather than 10k ... So there is no justification for jumping to 20k to 30k as I did the other day... </Edit>
I should say - and this is again a guess, not even an "educated" one:
75% SPIN only
10% SPIN with mixture of assembly language
10% with high interest in C-Compiler, now messing arround with SPIN and assembly
4% interested in an alternative high performance development system for dedicated and customized Propeller solutions; FORTH being their favourit, but willing to change to C when it's good, or stay with assembly if FORTH does not perform...
1% FORTH addicts
Well 1% is around 200.. not so bad
<Edit> But after a reconsideration by far less :-( </Edit>
Post Edited (deSilva) : 10/5/2007 7:00:34 PM GMT
I get is a blank screen? What am I missing?
Thanx
I have started Hyper terminal @ 19.2K and still no joy....
But with Aribas new PropTerminal only, which autoconfigures to FPForth and also shows a larger screen.
When you use Hyperterminal the Propeller is reset, so if you have loaded Forth to RAM rather than saved it to EEPROM there is nothing to see....
19.2k, 8 bits, no parity, no handshake!
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
- also displays number of used stack elements
- DIRA, INA , OUTA now work!
- new words:
CHAR
[noparse][[/noparse]CHAR]
COG@ -- to be used with Propeller constants, see below
COG!
DOES>
I+
I-
I
WAITTICKS
On the Hydra there is an LED an I/O 0
Constants (in fact register numbers)
PAR, CNT, CTRA, CTRB, FRQA,
FRQB, PHSA, PHSB, VCFG, VSCL
Note: INA, OUTA, and DIRA are not constants but implemented as somewhat faster instructions
Post Edited (deSilva) : 10/9/2007 8:27:51 PM GMT
19.2k, 8 bits, no parity, no handshake
Did the trick.
When creating a new connection the handshake defaulted to "HARDWAGE"
"COG = executed inside the COG without any reference to the HUP
w···general·value·(32·bit)
! ( w a -- ) COG
Stores a 16bit value w to address a
@ ( a -- w ) COG
pushes the 16bit value at address a"
Is the ! and @ documentation correct? At first it says that "w" is 32-bit, then later it says that ! and @ store/load 16-bit values, but uses "w" in the stack comment.
Also I think that the "COG" implies no HUB access, but aren't these accessing RAM through the hub? Maybe it really means that the word exists solely in the COG, but it can still take actions that require the use of the hub?
Also DOES> didn't make it into the list at the top. Glad to see that it was added to the forth though.
Regards,
Keith
The rules are:
Everything that is stored in or loaded from HUB is a 16-bit value (or a character)
Everything handled in the COG (and on the stack, which is COG based) is a 32 bit value.
The attribute "COG", means just that the FORTH interpretation needs no access to the HUB (extended dictionary)
At last:
1 DUP OUTA DIRA
CHAR
[noparse][[/noparse]CHAR]
DOES>
In your top post? Also is CREATE in the image?
Has any work been done on things like VARIABLE or ALLOT ?
I haven't actually played with this yet.
Most things work as in many FORTHs - exept they could still have issues
More documentation is underway...
Posible stack BUG!
·( 1 ) ok
·( 1 ) ok
TIME Zeit: 3, 2357 mS
·( 0 ) ok
TIME Zeit: 429496, 7295 mS
· underflow?
·( 0 ) ok
·( 0 ) ok
·( 0 ) ok
·( 0 ) ok
WORDS ( 5 ) ok
·( 5 ) ok
·( 5 ) ok
TIME ( 9 ) ok
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
Shy the stack underflow
Frohf is just fixing it; a new version will be uploaded on Tuesdy.
Thanks for replay.
TIME Zeit: <-- Posible in english ??
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha