dasm-assembler / dasm-assembler/dasm

borked nested #if

Open
#39 3 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

There's a bit of an issue with the #if directive
I ran across a case where I had pseudo-code inside an #if 0
my way of doing an extended comment, basically.
But if the pseudocode also contains the word 'if' (note, not #if) then the preprocessor actually processes it. I think the preprocessor should ignore EVERYTHING inside an "#if 0" except for #endif

Test code...

    processor 6502
    org $1000

#if 0
    some pseudocode
    if this works properly, we should see code!
#endif

    lda #1  ; does not get assembled
;eof

Assemble it and you don't get the "lda #1" generated, as dasm thinks its inside the #if 0

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 by reproducing the provided 6502 assembly snippet and inspect the preprocessor handling for #if 0 and nested text. Done means plain-language “if” inside the excluded block is ignored and the later lda #1 is assembled; add or update coverage for this case if the existing test structure identifies a suitable location.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.