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

Label definition during macro expansion problematic for local/anonymous labels #103

Open
envenomator opened this issue Dec 11, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@envenomator
Copy link
Owner

  1. During a macro expansion, a local label like @Local currently doesn't have a 'scope'. If the same macro is expanded twice within the same caller's scope (before any global label, between two global labels, or after the last global label in a file) - a collision will occur.

  2. During a macro expansion, a anonymous label will immediate collide if the caller is also using anonymous labels 'surrounding' it's expansion. Something like this is problematic:

    .macro test
    @@:
    ld a, 0
    .endmacro

@@: ld a, 1 test jp @b; <= this will jump to the local label IN THE MACRO DEFINITION

This behavior is unintended and needs to change.
Going forward, only local labels will be allowed in a macro body. Global labels were not allowed before and will continue to not be allowed. Local labels will be allowed and internally be extended with a 'macro expansion ID' to create a unique expansion scope that will also work during recursive macro invocations.

@envenomator envenomator added the enhancement New feature or request label Dec 11, 2024
@envenomator envenomator self-assigned this Dec 11, 2024
@envenomator
Copy link
Owner Author

50b9cce

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

No branches or pull requests

1 participant