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

Variable number of arguments for a macro #87

Open
vitococl opened this issue Sep 12, 2020 · 0 comments
Open

Variable number of arguments for a macro #87

vitococl opened this issue Sep 12, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@vitococl
Copy link

From the manual:

Macros are instantiated by using the macro’s name (case-insensitive),
followed by an optional list of arguments. The body of the macro definition
can refer to arguments passed with the format “{#}”, where # is replaced by
the argument number. The first argument passed to a macro is therefore {1}.
{0} represents an exact substitution of the entire instantiation line.

If a macro is instantiated with more arguments than the used ones, there is no problem, but if you try to use an argument that it was not provided, DASM raises an exception.

It could be nice a way to check for the number of arguments, for instance {N}, allowing to write macros like this:

    macro addwords
        clc
        lda {1}
        adc {2}
        if {n} = 3
            sta {3}
            lda {1}+1
            adc {2}+1
            sta {3}+1
        else
            sta {1}
            lda {1}+1
            adc {2}+1
            sta {1}+1
        endif
    endm

    addwords $80,$82,$84 ; Result in $84
    addwords $80,$82     ; Result in $80

NOTE: currently, {N} returns the same as {0}, i.e. the placeholder is replaced by the full list of arguments. Bug?
NOTE2: if the condition expression is a comma separated list of argments, the IF is evaluated as "true". Bug?

@thrust26 thrust26 added the enhancement New feature or request label Apr 13, 2021
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