Hardware
Firmware
Software
Anywhere
  Home Sensors Software Contact Us 
 
 
 
 
JDForth - Forth Dialect
Summary
• JDForth is a compiled forth.
• It has no concept of PAD or HERE.
• It uses three stacks.
• Literals come in several flavours.
• Usage of fetch @ and store ! has been extended over a traditional forth.
A Compiled Forth
Being a compiled Forth has several implications:

Advantages:
  • JDForth can be relatively easily mixed with Spin.
  • The literal and postfix extension syntax is quite programmer friendly, but would be harder to write in a traditional forth interpreter.
  • Assembly code is easily mixed in with JDForth without requiring an extra cog.
  • Assembly code is almost standard Parallax format! Postfix assembly language looks terrible!
  • JDForth doesn't require complete control of the propeller.
  • The propeller memory footprint of JDForth is quite reasonable.


  • Disadvantages:
  • Word names need to be unique.
  • The dictionary is not available for searching at run time.
  • The traditional interactive Forth development environment is not available.
  • Stacks (3 of them)
    JDForth has three stacks:
    The stacks in JDForth all grow from low memory to high memory.

    1) Parameter Stack
    The traditional forth parameter stack.

    2) Return Stack
    The traditional forth return stack.

    3) Algorithm Stack
    The all-new algorithm stack. Some forth variants include a third stack, but it is not common. The algorithm stack has been included in JDForth to compensate for the lack of HERE and PAD.

    The definitions for <#, #, #S and #> in SYSTEM.JD4 provide an example for writing these words using the algorithm stack instead of PAD.
    Literals come in several flavours
    Literals may be entered in source code in one of the following forms:
    Number BaseExamples
    # - Decimal
    5 #10 #80_000_000 -20 -100_000
    (The leading # is only required for literals defined in PASM code)
    $ - Hexadecimal
    $F00D $0_C0FFEE_0 
    % - Binary
    %100_100_100
    " - Character
    "?" "-" "1TAF"
    (1-4 characters - the right most character is least significant, and placed in the lowest memory location)
    e or . - Float
    3.141 1e6 -1.234e-5
    • The _ (underscore) character may be freely used in decimal, hexadecimal and binary literals.
    • The literal is automatically stored as either 16bit or 32bit - using the minimum amount of memory.
    Compiler postfix for @ (fetch) and ! (store)
    The use of constants and variables is for the most part interchangable in JDForth. Constants offer much faster retrieval at the cost of making the source code more ambiguous. The interchangability is enhanced if the items are post-fixed with @ and !. As per the following table:
    Storage SpecifierNormal AccessCompiler Postfix
    VAR16 MyVarMyVar H@MyVar@
    MyVar H!MyVar!
    VAR32 MyVarMyVar @MyVar@
    MyVar !MyVar!
    123 CON16 MyVarMyVarMyVar@
    ['] MyVar CON16!MyVar!
    123 CON32 MyVarMyVarMyVar@
    ['] MyVar CON32!MyVar!
    USER MyVarMyVar H@MyVar@
    MyVar H!MyVar!