Wintermute_BBS on Nostr: This is a call for help / verification on an alleged #Bug which I may have found in a ...
This is a call for help / verification on an alleged #Bug which I may have found in a #Forth #Programming tutorial online.
It's at beginner level, a bug in an exercise with regards to "flexible arrays".
The original code example and results are shown in the first two screenshots, but I'm dang sure this won't work as there's a 'rot' statement missing eventually resulting in a wrong return address.
When running the original example code, I get addresses with a 1 byte spacing for each array element. This can't be correct.
The last two screenshots show the fixed code with the missing 'rot' command added.
When running the second, fixed example, I get addresses that are spaced by 5 cells (5 * 2 byte). This is what I would expect.
Links:
* Original online version of the tutorial code: http://www.forth.org/svfig/Len/arrays.htm
It's at beginner level, a bug in an exercise with regards to "flexible arrays".
The original code example and results are shown in the first two screenshots, but I'm dang sure this won't work as there's a 'rot' statement missing eventually resulting in a wrong return address.
When running the original example code, I get addresses with a 1 byte spacing for each array element. This can't be correct.
The last two screenshots show the fixed code with the missing 'rot' command added.
When running the second, fixed example, I get addresses that are spaced by 5 cells (5 * 2 byte). This is what I would expect.
Links:
* Original online version of the tutorial code: http://www.forth.org/svfig/Len/arrays.htm