dasm-assembler / dasm-assembler/dasm

Nested macro definitions

Open
#74 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
257
Forks
55
PR merge metrics
No merged PRs in 30d

Description

The docs say:

GENERAL:
    Most everything is recursive.  You cannot have a macro DEFINITION
    within a macro definition, but can nest macro calls, repeat loops,
    and include files.

Actually to have such a facility is useful sometimes. Digital's Macro-11 assembler allows it. One way this is commonly used (well, common for a specific assembler for an obsolete CPU architecture) is use-once macros. A macro, if it is used, re-defines itself to be empty. Something like this: (see also https://gitlab.com/Rhialto/macro11/-/blob/master/tests/test-endm.lst.ok for a listing output)

;;;;;
;
; Test nested macros and name on .ENDM
;

    .macro      M1
    .word       1
    .endm       M1      ; ok

    M1

    .macro      M2
    .word       2
    .macro      M3
    .word       3
    .endm       M3      ; ok
    .endm       M2      ; ok

    M2
    M3

    .macro      M4
    .word       4
    .macro      M4
    .endm       M4      ; ok
    .endm       M4      ; ok

    M4
    M4                  ; should be empty now

    .macro      M5
    .word       5
    .macro      M5
    .endm       notM5   ; wrong; detected when M5 is expanded
    .endm       M5      ; ok

    M5
    M5

    .macro      M6
    .endm       notM6   ; wrong

    .endm               ; end without macro
    .endr               ; end without repetition
    .endc               ; end without condition

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the macro-definition behavior described in the issue and compare it with the referenced Macro-11 test listing. Trace the assembler's macro parsing and expansion entry points, then use the nested, redefinition, and mismatched-end cases in the example to define the expected behavior and completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.