Hi John,
There is no issue with nesting or recursion and the design choice to
branch to an address, rather than to an offset.
|F=./fac.f
|S| 1|: factorial ( n -- n! )
|S| 2| dup 2 < if \ base case: if n < 2, return 1
|S| 3| drop 1
|S| 4| else
|S| 5| dup 1- \ compute n-1
|S| 6| recurse \ recursive call: factorial(n-1)
|S| 7| * \ multiply n * factorial(n-1)
|S| 8| then ;
10 factorial u.
3628800 ok
There are situations nowadays where relative branches would make things
easier, but I'm unconvinced these situations really existed on the
target hardware in 2007. However, it is 2026 not 2007, and so is it
worth looking at again? Certainly, and since AmForth is an open source
project, we all have that opportunity.
Best wishes,
Tristan
On 2026-02-02 18:30, John Sarabacha wrote:
Hi Everyone,
There is an issue (or a lack of a useful feature) in the Amforth
distribution (32 bit riscv & arm, since they share the same secondary
hand
compiled words), I have made the adjustments to the secondary words
(which
I have not released yet, as I am verifying its impact). I suspect these
are
causing some of your tests to fail. This revolves around the use of
BRANCH
and CONDBRANCH primary words and the addresses they are using, they
should
be relative addresses and not absolute addresses specified in
.word(...)
after the BRANCH or CONDBRANCH. If there is no nesting or recursion
involving these words then no problem, but then you are limiting what
you
can do.
Hope this helps,
John S
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel