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

Improve macro parameter handling #15

Open
thrust26 opened this issue Sep 27, 2019 · 5 comments
Open

Improve macro parameter handling #15

thrust26 opened this issue Sep 27, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@thrust26
Copy link
Member

Currently parameters are passed as strings without any option to operate on them. The following enhancements would be very useful:

  1. string operations (substrings and iterations)
  2. convert strings into values
@thrust26 thrust26 added the enhancement New feature or request label Sep 27, 2019
@andrew-davie
Copy link
Member

Use case... creating lo/hi tables using just the single 'definition'...

    MAC LOHI ;@label
    IF STAGE = 0
        .byte <{1}
    ELSE
        .byte >{1}
    ENDIF
    ENDM


; Create two tables - one for low bytes, the other for high bytes
; Fill the tables using LOHI macro

STAGE SET 0
    REPEAT 2
    IF STAGE = 0
LOTable
    ELSE
HITable
    ENDIF
        LOHI lab1
        LOHI lab2
        LOHI lab3
STAGE SET STAGE+1
    REPEND

lab1 ;data...
lab2 ;data...
lab3 ;data...

@andrew-davie
Copy link
Member

Well maybe not a use-case for strings, per se.
But it would be nice to be able to do the above

@andrew-davie
Copy link
Member

Dammit, that actually works already.
I'm sure I've tried this before... ??? Ha

@thrust26
Copy link
Member Author

What did you expect not to work here?

@andrew-davie
Copy link
Member

andrew-davie commented Jan 10, 2020

Did you know if you pass a parameter as an actual quoted string, then it does not get evaluated?
For example...

    MAC OVERLAY ; {name}
OVERLAY_NAME SET {1}
  ECHO "NAME IS", OVERLAY_NAME
    ENDM

if you call this with

OVERLAY "test"

Then the output will be
NAME IS test

If you call this with

OVERLAY test

Then the output will be
NAME IS

The point being, if you quote the parameter as a quoted string, then you can treat it as a string. This may be obvious...? But in any case, I use this in macros to assign the STRING to a label, and then use that (stirng) label later on for something else (for example, to print diagnostics/stats about the assembly).

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

2 participants