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

Rework how local labels work #81

Open
Fubukimaru opened this issue Jan 17, 2021 · 2 comments
Open

Rework how local labels work #81

Fubukimaru opened this issue Jan 17, 2021 · 2 comments
Assignees
Milestone

Comments

@Fubukimaru
Copy link
Owner

Fubukimaru commented Jan 17, 2021

In the case of the macro, you cannot use any label inside because the name will be duplicated. For instance, something stupid like:

LOCO: MACRO #a, #b
    jpnz .nothing
    ld  a, #a
    ld  a, #b
.nothing:
    xor a
ENDMACRO

It will complain .nothing already exists when using the macro twice. I assume that this is not the desired way of working in case we have a loop inside the macro.

My proposal would be to modify how the local labels work. I have seen in some assemblers that they refer to local labels using the previous global, for example: A global named MAN and then a local defined as .GLER. Internally the local label would be MAN.GLER.

This way we would be able to repeat local label names. I have to get more information about other assemblers to check how they behave.

@Fubukimaru Fubukimaru self-assigned this Jan 17, 2021
@Fubukimaru Fubukimaru added this to the Version 1.1.0 milestone Jan 17, 2021
@Fubukimaru
Copy link
Owner Author

Fubukimaru commented Jan 18, 2021

When calling macros we should add the label like:

LOCO 1, 2
LOCO 3, 4

Would be:

LOCO_MACRO_1:
    jpnz .nothing
    ld  a, 1
    ld  a, 2
.nothing:
    xor a
   
LOCO_MACRO_2:
    jpnz .nothing
    ld  a, 3
    ld  a, 4
.nothing:
    xor a

Or directly:

LOCO_1:
    jpnz .nothing
    ld  a, 1
    ld  a, 2
.nothing:
    xor a
   
LOCO_2:
    jpnz .nothing
    ld  a, 3
    ld  a, 4
.nothing:
    xor a

@Fubukimaru
Copy link
Owner Author

There is a bug in how this works at the moment: #88

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

No branches or pull requests

1 participant