Skip to content
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

Feature idea: conditional GO TO using labels #4

Open
patters-match opened this issue Nov 20, 2022 · 3 comments
Open

Feature idea: conditional GO TO using labels #4

patters-match opened this issue Nov 20, 2022 · 3 comments

Comments

@patters-match
Copy link

patters-match commented Nov 20, 2022

Compensating for the lack of IF THEN ELSE in Sinclair BASIC, some programmers use arithmetic GO TO jumps within nested conditional logic as below:

    let s=3: \
    let f=not f: \
    let x=x-1: \
    let t=attr (y,x): \
    if t then \
        let x=u: \
        if t>64 then \
            go to 40+(10 and t>78)

Would it be possible to express this with labels, and have zmakebas work out the necessary arithmetic operation automatically?

e.g. something like:

goto @firstlabel ( @secondlabel and t>78 )

or maybe:

goto @firstlabel or ( @secondlabel and t>78 )

resulting in:

go to @firstlabel (sign( @secondlabel - @firstlabel ))(( @secondlabel - @firstlabel ) and t>78 )
@patters-match patters-match changed the title Feature request: conditional GO TO using labels Feature idea: conditional GO TO using labels Nov 20, 2022
@patters-match
Copy link
Author

patters-match commented Nov 22, 2022

If I ensure there is whitespace surrounding the label names I can work around this using the following approach, but it is adding some additional computation to the program:

goto @died + (( @cont - @died ) and t>78)

I think this would be ideal if it could be implemented:

goto @died or (@cont and t>78)

@patters-match
Copy link
Author

This is what I was using zmakebas for:
https://github.com/patters-syno/microprof

@ohnosec
Copy link
Owner

ohnosec commented Dec 1, 2022

The current zmakebas doesn't really do parsing as such. Instead of parsing it simply substitutes strings with tokens. However I really like your idea so I'll have a go at implementing it without a rewrite :)

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

2 participants