Skip to content

Reorganize OpcodeConstants for better maintainability #4

Description

@wfd3

Description

The OpcodeConstants class in 6502/6502.h (lines 124-277) lists opcodes in a seemingly random order, making them difficult to find and maintain.

Current State

Opcodes are scattered throughout the class definition with no clear organization:

constexpr static Byte BRK_IMP = 0x00;
constexpr static Byte ORA_IDX = 0x01;
constexpr static Byte ASL_ACC = 0x0a;
constexpr static Byte ADC_ZP  = 0x65;  // Jump to 0x65
constexpr static Byte ROR_ZP  = 0x66;
// ...

Suggested Improvements

Option 1: Numerical order (0x00 → 0xFF)

Sort all opcodes by their hex value for easy lookup.

Option 2: Group by instruction

Group all variants of each instruction together:

// ADC variants
constexpr static Byte ADC_IMM = 0x69;
constexpr static Byte ADC_ZP  = 0x65;
constexpr static Byte ADC_ZPX = 0x75;
constexpr static Byte ADC_ABS = 0x6d;
constexpr static Byte ADC_ABX = 0x7d;
constexpr static Byte ADC_ABY = 0x79;
constexpr static Byte ADC_IDX = 0x61;
constexpr static Byte ADC_IDY = 0x71;

Benefits

  • Easier to find specific opcodes
  • Easier to verify completeness
  • Better maintainability

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions