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. |
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)
The definitions forLiterals come in several flavours
Advantages:
Disadvantages:
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 may be entered in source code in one of the following forms:
Compiler postfix for @ (fetch) and ! (store)
Number Base | Examples |
# - 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.
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 Specifier | Normal Access | Compiler Postfix |
VAR16 MyVar | MyVar H@ | MyVar@ |
MyVar H! | MyVar! | |
VAR32 MyVar | MyVar @ | MyVar@ |
MyVar ! | MyVar! | |
123 CON16 MyVar | MyVar | MyVar@ |
['] MyVar CON16! | MyVar! | |
123 CON32 MyVar | MyVar | MyVar@ |
['] MyVar CON32! | MyVar! | |
USER MyVar | MyVar H@ | MyVar@ |
MyVar H! | MyVar! |