Skip to content

6502 disassembler inconsistent with LDA addr,X #201

Description

@tautology0

Describe the bug
6502 has an instruction: LDA addr,X and LDA addr,Y which loads the assembler with the contents of address (addr + X) or (addr + Y). When this is disassembled sometimes the results has a label, sometimes it doesn't.

An example is shown below, from the same binary:

            078f bd 00 0c        LDA        $0xc00,X
            0792 c9 20           CMP        #0x20
            0794 d0 f8           BNE        LAB_078e
            0796 86 02           STX        $PORTC
                             LAB_0798                                        XREF[1]:     077e(j)  
            0798 a2 00           LDX        #0x0
                             LAB_079a                                        XREF[1]:     07a3(j)  
            079a bd 00 0c        LDA        $DAT_0c00,X
            079d 20 ee ff        JSR        OSWRCH                                           void OSWRCH(byte character)

As can be seen, the entry at 0x78f uses 0xc00 whereas the entry at 0x79a uses the label $DAT_0c00. Looking at the Instruction Info dialogue, it appears that on the one with a label it decides that 0xc00 is an address, but doesn't on the one without a label.

In all cases with 6502, 0xbd means that the passed 16-bit parameter is an address.

To Reproduce
Disassemble a binary with multiple LDA addr,X in it. Look for inconsistencies.

Expected behavior
In all cases the mnemonic should have the parameter being an address and use the label.

Environment (please complete the following information):

  • Ghidra Version: 9.0

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions