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

conditional IF/ENDIF bug? #92

Closed
richardturnnidge opened this issue Nov 15, 2024 · 8 comments
Closed

conditional IF/ENDIF bug? #92

richardturnnidge opened this issue Nov 15, 2024 · 8 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@richardturnnidge
Copy link

Not a major issue, but noting for future or for docs...

I have a section of code which is only needed if debugging, as it only gets called if debugging. No point in including extra bytes if not needed in the binary.

eg.

debugging: equ 0
...

if debugging
...routine here
...do this code, etc
localVariableUsed: .db 0
endif

If debugging is 1, then the routine gets assembled correctly.

If debugging is 0, then I get an error that 'localVariableUsed' is an unknown label, even though it is only ever called from within this routine.
If I put 'debugging: equ 0' outside the if/endif section, then it assembles without error.

@envenomator
Copy link
Owner

This might be explained somewhat better in the docs. The intention has always been to select a block to assemble, depending on the value of the if statement.
In pre 1.10, this didn't properly include data statements, nor properly handle labels. The intention, as implemented starting 1.10, is illustrated by this example:

.if 1
    .db 1,2,3,4,5
localvar: .db 1
.else
    .db 1,2
localvar: .db 0
.endif

creates a different localvar label, depending on the block that it is in. In pre 1.10 versions, this wasn't working correctly.

@envenomator envenomator added the documentation Improvements or additions to documentation label Nov 20, 2024
@envenomator envenomator self-assigned this Nov 20, 2024
@envenomator
Copy link
Owner

Grief. By trying to provide an example in the docs, I'm running up to something that doesn't work correctly in an ELSE block. Considering how I wasn't planning to include if/else/endif originally, but included a PR that in retrospect wasn't nearly complete, I'm learning something about including other people's work from a PR.

@richardturnnidge
Copy link
Author

I only stumbled on it by chance, doesn't affect my code as I know how to get round, but mentioned it FYI... remove the feature if it's a pain!
Maybe it isn't used much if I'm the only one who has found it!!!

@envenomator
Copy link
Owner

Don't get me wrong, it's good that you mention it. The behavior has indeed changed, so if you were relying on the previous behavior, it understandable that this is now different than before and other people may run into this.

@richardturnnidge
Copy link
Author

Actually, this was the first time I had tried using conditional assembly with IF/ENDIF

In fact, at first when I looked at the .LST file trying to work out what was going on, I thought that ez80asm had included all the conditional code in the final binary... until I realised that the target address had not changed for that code! I almost filed a bug report on that... doh...

@envenomator
Copy link
Owner

Fixing a couple of (hopefully) last issues in the conditional assembly section now. ASCIZ was always outputting a zero, regardless of selection and a isolated label without any code didn't work when used in both if/else blocks. After I upload a new release in the next week or so, I'll update the docs with a good example using conditional assembly

@richardturnnidge
Copy link
Author

Fabulous. I can confidently build Mac versions now, so I am happy.

@envenomator
Copy link
Owner

Released as v1.11

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

No branches or pull requests

2 participants