dasm-assembler / dasm-assembler/dasm

Macro forward-reference failure/inconsistent

Open
#30 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.