-
Notifications
You must be signed in to change notification settings - Fork 58
Description
https://github.com/jamesbowman/swapforth/blob/master/j1a/cross.fs#L167
AFAICT, this piece of code means "If any of the previous instructions branches to end-of-word, do a return trick on it."
However,
i tbranches @ tdp @ = if
i tbranches @ shortcut and
then
is by construction (i tbranches @
== tdp @
) equivalent to
i tbranches @ tdp @ = if
tdp @ shortcut and
then
which doesn't make sense, as it attempts to shortcut an instruction yet unwritten.
If I understand the code correctly, this is supposed to mean "if an instruction at address i
branches to here (as would happen if the last word in a word definition is then
), then apply the return-hack to that instruction". The correct if-statement in this case would be something like
i tbranches @ tdp @ = if
i shortcut and
then
if I am not mistaken.
P.S. "shortcut" for this case should probably also replace unconditional-jump to exit location with "exit".
P.P.S. Could the enclosing do-loop be changed from tdp @ 0
to tdp @ wordstart @
?