dasm-assembler / dasm-assembler/dasm

Two issues with macro CLEAN_START in macro.h

Open
#155 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

  1. The use of the Illegal Opcode LXA #0 appears not to work in Stella 7.0. I noticed the prior thread here discussing the stability of this op-code when CLEAN_START was modified to include it in 2020. While this issue is due to Stella not implementing this Illegal opcode correctly (and I'm reporting that separately), I think that including illegal opcodes in Macros by default is a poor choice. Better to opt in rather than opt out. Possibly difficult to change that without breaking other peoples code though, so I suggest removing the conditional compilation of LXA from CLEAN_START as the code isn't time critical. The workaround is to always define NO_ILLEGAL_OPCODES equ 1 (or wait and see if it gets fixed in Stella).

  2. There is a spurious TAY instruction in CLEAN_START which is probably left over from an earlier implementation which didn't use the SP to implement the memory clear. I think this can be removed.
    Edit: On second thoughts, I think this is on purpose to set Y to zero on existing CLEAN_START.

Note that if CLEAN_START is executed immediately after Reset, then Register A is likely to be zero and the code clears the TIA and RAM correctly in Stella. Mine had extra banking switching code before CLEAN_START resulting in $FF in the register A, and the Stella bug resulted in all the TIA registers and RAM being set to $FF. Thus many people will not have seen this issue.

macro.h

        MAC CLEAN_START
            sei
            cld
        
            IFNCONST NO_ILLEGAL_OPCODES
                **lxa #0**
            ELSE
                ldx #0
                txa
            ENDIF
            **tay**

.CLEAR_STACK dex
txs
pha
bne .CLEAR_STACK ; SP=$FF, X = A = Y = 0

        ENDM

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

Open macro.h and inspect CLEAN_START, including the NO_ILLEGAL_OPCODES branch and the TAY placement. Review the issue thread about LXA stability and the later clarification about TAY, then confirm the intended default behavior and whether existing code compatibility is affected.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.