dasm-assembler / dasm-assembler/dasm
SUBROUTINE lost inside macros
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 257
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
The SUBROUTINE pseudo-op allows the definition of "local" labels. It's very useful.
However, it does not seem to "survive" being embedded in a macro.
processor 6502
org $1000
MAC TEST
SUBROUTINE
ENDM
.exit
SUBROUTINE ; disable this line to get an error
TEST
jmp .exit
.exit
In the above test code, the ".exit" is defined twice as a local label. The jmp would be expected to hit the second instance, as SUBROUTINE defines a local-label boundary just after the first ".exit". The above code assembles OK.
BUT, if you disable that SUBROUTINE just under the first ".exit", then we have a macro (TEST) which also declares "SUBROUTINE". This does not work - the line is not so much ignored, I think but perhaps the macro is automatically de-scoping local levels/labels at the ENDM? Just a guess.
It would be INCREDIBLY USEFUL to me to have SUBROUTINE working inside macros, and allow me to define the start of local scope with it, which survives outside the macro itself.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the 6502 example using the MAC, SUBROUTINE, and ENDM directives, comparing assembly with and without the first SUBROUTINE. Trace the macro expansion and local-label scope handling to determine where the boundary is lost. Done means the sample assembles and the jmp resolves to the second .exit label when SUBROUTINE is declared inside the macro.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100