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

Macros with .data definitions can only be used once #18

Closed
qrno opened this issue Sep 3, 2021 · 2 comments
Closed

Macros with .data definitions can only be used once #18

qrno opened this issue Sep 3, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@qrno
Copy link

qrno commented Sep 3, 2021

The following macro causes problems when called more than once. The second call's .data supersedes the first and in the final program "lemon" is printed twice.

.macro print_string(%str)
.data
var: .string %str

.text
    li a7 4
    la a0 var
    ecall
.end_macro

.text
    print_string("apple")
    print_string("lemon")

RARS solves this problem by adding a _M{#} suffix to the .data definitions inside of macros, so that the macros above would define var_M0 and var_M1 respectively. This counter is global, if a different macro call also defines var, it'll call it var_M2.

@LeoRiether
Copy link
Owner

Wow I had no idea you could do that!

@LeoRiether LeoRiether self-assigned this May 29, 2023
@LeoRiether LeoRiether added the bug Something isn't working label May 29, 2023
@LeoRiether
Copy link
Owner

Update more than a year later: this will be fixed in the new parser rewrite 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants