dasm-assembler / dasm-assembler/dasm
Macro forward-reference failure/inconsistent
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 257
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
Split to a new issue from issue #29
Forward references to macros are not allowed. They generate an assembly error (undefined mnemonic). It would be nice to allow forward references, but in any case, the error is suppressed under some circumstances which can be confusing...
If you have a forward-reference to a macro, then yes you get an error with details. But if you trigger a 2nd pass of the assembler by having a forward label reference TOO, then you don't get the error details. Sample code shows this in action. Enable/comment out the "jmp" and you get the two variants.
; Unknown mnemonic/macro
processor 6502
ORG $1000
jmp .forward
lda #1
TEST
lda #1
MAC TEST
lda #2
ENDM
.forward
; EOF
Output with the "jmp" enabled...
boo@Andrews-MacBook-Pro chess % ../dasm/bin/dasm ./test.asm -f3 -o./test.bin
Unrecoverable error(s) in pass, aborting assembly!
Complete.
Output with the "jmp" disabled...
boo@Andrews-MacBook-Pro chess % ../dasm/bin/dasm ./test.asm -f3 -o./test.bin
./test.asm (10): error: Unknown Mnemonic 'TEST'.
Unrecoverable error(s) in pass, aborting assembly!
Complete.
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
Reproduce the issue with the supplied 6502 assembly sample using the shown dasm command, first with the forward jmp enabled and then disabled. Trace the assembler's pass handling, label resolution, and macro lookup to identify why the unknown-macro diagnostic disappears on the second pass. Done means the intended forward-reference behavior is established and the resulting error handling is consistent and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100