Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Inconsistent handling of .endmacro #2775

@kugelfuhr

Description

@kugelfuhr

I'm a bit unhappy about the changes done in #2013 and would like to hear some opinions.

#2013 fixes a problem with .endmacro in that it was accepted regardless of its position in a line. This bug fix was definitely necessary. In addition to the bug fix, the PR added a special case handling for .endmacro: If it is at the start of a line it ends the macro definition, if not, it is added to the macro replacement list.

Use cases for this new feature are very rare. One was given as an example. I may be a bit unimaginative but I cannot think of any other use case than this one.

Now the inconsistency is that it won't work in some other situations:

.macro  mac1    name, val
        .macro  name
                .byte   val
        .endmacro
.endmacro

mac1    byte0, 0

Gives:

test.s:5: Error: Unexpected '.ENDMACRO'
test.s:7: Error: '.ENDMACRO' expected for macro 'byte0'

So previously the rule was

a .endmacro can never be embedded in a macro definition, it will always end a macro

which was consistent and easy to understand.

Now the rule is

a .endmacro can sometimes be embedded in a macro definition if you manage to write your macro so that .endmacro is not at the start of a line

which is inconsistent and ugly in my eyes. It means that users have to resort to something like

.macro  mac1    name, val, empty
        .macro  name
                .byte   val
        empty .endmacro
.endmacro

mac1    byte0, 0,

to make the embedded macro work.

I think that it would be better to restore the original behavior of .endmacro (minus the bug of course) and then add something like .embed() to explicitly embed stuff into a macro. The current behavior seems more like a hack to me.

Comments?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions