Shop OBEX P1 Docs P2 Docs Learn Events
FPForth — Parallax Forums

FPForth

deSilvadeSilva Posts: 2,967
edited 2007-11-09 15:11 in Propeller 1
"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 smile.gif
(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 smile.gif


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
«1

Comments

  • rjo_rjo_ Posts: 1,825
    edited 2007-09-28 19:50
    deSilva,

    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
  • lnielsenlnielsen Posts: 72
    edited 2007-09-28 19:58
    Two·quick notes on FPForth:
    1. If you are using HyperTerminal you have to disable flow control. I will be trying PuTTY this weekend because I hate HyperTerminal.
    2. The German thread has more information. You can use this·Babelfish link for something that looks like English.·

    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
    1. "Starting Forth"
    2. "Thinking Forth"

    Thanks frohf for developing this and thanks deSilva for keeping up informed!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    BioProp: Robotics - Powered by Bioloids and controlled by the Propeller
  • KeithEKeithE Posts: 957
    edited 2007-09-29 00:55
    Here's another book "Programming Forth" by Stephen Pelcwww.mpeforth.com/arena/ProgramForth.pdf

    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-29 07:49
    Good references!

    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....
  • LeonLeon Posts: 7,620
    edited 2007-09-29 17:08
    I've just tried it. It executes the first command OK, but subsequent commands don't get executed properly. I can't get a colon definition to work because of this problem.

    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
  • rpraverrpraver Posts: 19
    edited 2007-09-30 03:04
    Is there a version that runs on the Hydra?
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-30 07:17
    As it uses pins 30 and 31 only at the moment the difference is just the 10 MHz crystal. I think Frohf will make a version smile.gif
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-02 05:58
    I just uploaded v0.70 - see posting #1. There is now a 5MHz (checked on the Protoboard) and a 10MHz crystal version (checked on the Hydra)
  • LewisDLewisD Posts: 29
    edited 2007-10-04 03:35
    Is the source available?

    I don't wont my time to be wasted like it was on the last Forth I tried...


    LewisD
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-04 07:40
    Be patient!
    FPForth will undergoe still some basic revisions.
    And you cannot waste too much time as long as there is just a binary smile.gif
  • lnielsenlnielsen Posts: 72
    edited 2007-10-04 16:04
    I think what LewisD meant was that without the source code, this could become another abandonded project like Cliff's Forth. It sounds like frohf will be publishing source as soon as the first full release is ready. As I understand it, this will include SD/EEPROM file support and the ability to access spin/asm objects running on other cogs.

    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
  • LeonLeon Posts: 7,620
    edited 2007-10-04 20:23
    See the first message in this thread, bug fixes in 0.70 are listed.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • LewisDLewisD Posts: 29
    edited 2007-10-04 23:45
    Thanks lnielsen

    I am concerned that it may be abandoned.

    I am very interested in using a Forth for my robot projects...

    LewisD
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-05 02:27
    Don't fear!
    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 smile.gif
    <Edit> But after a reconsideration by far less :-( </Edit>

    Post Edited (deSilva) : 10/5/2007 7:00:34 PM GMT
  • rpraverrpraver Posts: 19
    edited 2007-10-07 03:40
    I just load forthhydra_070.binary on my hydra and all
    I get is a blank screen? What am I missing?

    Thanx
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-07 04:00
    This Forth uses the serial connection to the PC for its console. You need to run a program like Hyperterminal on the PC with a connection at 19.2KBaud. There's no support currently for VGA or TV and the PS/2 keyboard.
  • rpraverrpraver Posts: 19
    edited 2007-10-07 04:23
    I load the Hrydra with forth.
    I have started Hyper terminal @ 19.2K and still no joy....
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-07 11:49
    Sorry to hear :-( You can be sure I checked it...
    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!
  • LeonLeon Posts: 7,620
    edited 2007-10-07 13:46
    You also need upper-case, and CR at the end of a line.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-09 20:10
    New version 0.71 (see first posting)
    - 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
    1 DUP DIRA OUTA
    INA .
    CNT COG@
    
    




    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
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-09 21:17
    I just added a short explanation of many of the words in posting #1
  • rpraverrpraver Posts: 19
    edited 2007-10-10 02:53
    It now works fine.
    19.2k, 8 bits, no parity, no handshake
    Did the trick.
    When creating a new connection the handshake defaulted to "HARDWAGE"
  • KeithEKeithE Posts: 957
    edited 2007-10-10 03:33
    Regarding the documentation in the post:

    "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
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-10 04:53
    Yes, Keith, you are right, I shall be more precise... It was translated in a hurry, from Frohf's note which still have some typos in it....

    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)
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-10 08:19
    Added the Hydra variant(therehad been an issuewith it yesterday).
    At last:
    1 DUP OUTA DIRA
  • KeithEKeithE Posts: 957
    edited 2007-10-11 00:11
    Could you add placeholders for:

    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-11 00:26
    Try WORDS
    Most things work as in many FORTHs - exept they could still have issues smile.gif
    More documentation is underway...
  • SapiehaSapieha Posts: 2,964
    edited 2007-10-14 00:16
    Hi deSilva.



    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
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-14 11:59
    Thankl you, Sapieha! This is an already known bug, mentioned in the summary 0.71 in the first posting.
    Shy the stack underflow smile.gif
    Frohf is just fixing it; a new version will be uploaded on Tuesdy.
  • SapiehaSapieha Posts: 2,964
    edited 2007-10-14 12:07
    Hi deSilva.

    Thanks for replay.

    TIME Zeit: <-- Posible in english ??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.

    Sapieha
Sign In or Register to comment.