8000 Suspicious code in cross.fs · Issue #80 · jamesbowman/swapforth · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Suspicious code in cross.fs #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ElectronicRU opened this issue Mar 5, 2023 · 0 comments
Open

Suspicious code in cross.fs #80

ElectronicRU opened this issue Mar 5, 2023 · 0 comments

Comments

@ElectronicRU
Copy link

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 @?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0