Skip to content

Feature: Support nested macros in ca45 assembler #232

Description

@CTalkobt

Feature Request

Component: ca45 (45GS02 Assembler)

Description:
Add support for nested macro definitions and invocations in the ca45 assembler.

Currently, ca45 supports basic macro definitions via the preprocessor, but does not support macros defined within other macros (nested macro definitions) or macros that invoke other macros at multiple levels of nesting.

Use Case:
Complex assembly routines often benefit from hierarchical macro abstractions. For example:

  • Define a base macro for common operations (e.g., push_regs)
  • Define specialized macros that call the base macro multiple times
  • Allow parameterized macros to generate other macro invocations at compile time

Example Desired Syntax:

.macro push_regs_and_save_zp
  pha
  phx
  phy
.endmacro

.macro setup_environment
  push_regs_and_save_zp  ; nested macro invocation
  ; additional setup code
.endmacro

Implementation Considerations:

  • Ensure macro parameter expansion works correctly across nesting levels
  • Prevent infinite recursion with reasonable nesting depth limits or cycle detection
  • Maintain backward compatibility with existing single-level macros
  • Consider performance impact on assembly time

Related Documentation:

Priority: Medium (performance/code organization improvement)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions