void SetCpu(string cpu) { if (!SupportedCPUs.Contains(cpu)) { var error = string.Format($"Invalid CPU {cpu} specified"); throw new ArgumentException(error); } _cpu = cpu; switch (_cpu) { case "65816": _selectedInstructions = _opcodes6502.Concat(_opcodes65C02) .Concat(_opcodesW65C02) .Concat(_opcodes65816) .ToDictionary(k => k.Key, k => k.Value); break; case "HuC6280": _selectedInstructions = _opcodes6502.Concat(_opcodes65C02.Where(o => (o.Value.Opcode & 0x0f) != 0x02)) .Concat(_opcodesR65C02) .Concat(_opcodesW65C02) .Concat(_opcodesHuC6280) .ToDictionary(k => k.Key, k => k.Value); break; case "65CE02": _selectedInstructions = _opcodes6502.Where(o => (o.Value.Opcode & 0x1f) != 0x10) // exclude 6502 branch instructions .Concat(_opcodes65C02.Where(o => o.Value.Opcode != 0x80 && (o.Value.Opcode & 0x0f) != 0x02)) .Concat(_opcodesR65C02) .Concat(_opcodes65CE02) .ToDictionary(k => k.Key, k => k.Value); break; case "R65C02": _selectedInstructions = _opcodes6502.Concat(_opcodes65C02) .Concat(_opcodesR65C02) .ToDictionary(k => k.Key, k => k.Value); break; case "65CS02": _selectedInstructions = _opcodes6502.Concat(_opcodes65C02) .Concat(_opcodesW65C02) .ToDictionary(k => k.Key, k => k.Value); break; case "W65C02": _selectedInstructions = _opcodes6502.Concat(_opcodes65C02) .Concat(_opcodesR65C02) .Concat(_opcodesW65C02) .ToDictionary(k => k.Key, k => k.Value); break; case "65C02": _selectedInstructions = _opcodes6502.Concat(_opcodes65C02) .ToDictionary(k => k.Key, k => k.Value); break; case "6502i": _selectedInstructions = _opcodes6502.Concat(_opcodes6502i) .ToDictionary(k => k.Key, k => k.Value); break; default: _selectedInstructions = new Dictionary <MnemMode, CpuInstruction>(_opcodes6502); break; } // if any cpu change is done within pass, look at saved accumulator and index // modes. if (_m16) { SetImmediate(3, 'a'); } if (_x16) { SetImmediate(3, 'x'); SetImmediate(3, 'y'); } }
void SetCpu(CpuChangedEventArgs args) { if (args.Line.Operand.EnclosedInQuotes() == false && !args.Line.SourceString.Equals(ConstStrings.COMMANDLINE_ARG)) { Assembler.Log.LogEntry(args.Line, ErrorStrings.QuoteStringNotEnclosed); return; } var cpu = args.Line.Operand.Trim('"'); if (!SupportedCPUs.Contains(cpu)) { var error = string.Format("Invalid CPU '{0}' specified", cpu); if (args.Line.SourceString.Equals(ConstStrings.COMMANDLINE_ARG)) { throw new Exception(string.Format(error)); } Assembler.Log.LogEntry(args.Line, error); return; } _cpu = cpu; switch (_cpu) { case "65816": _filteredOpcodes = _opcodes6502.Concat(_opcodes65C02) .Concat(_opcodes65816) .ToDictionary(k => k.Key, k => k.Value, Assembler.Options.StringComparar); break; case "65CE02": _filteredOpcodes = _opcodes6502.Where(o => (o.Value.Opcode & 0x1f) != 0x10) // exclude 6502 branch instructions .Concat(_opcodes65C02.Where(o => o.Value.Opcode != 0x80 && (o.Value.Opcode & 0x0f) != 0x02)) .Concat(_opcodesR65C02) .Concat(_opcodes65CE02) .ToDictionary(k => k.Key, k => k.Value, Assembler.Options.StringComparar); break; case "R65C02": _filteredOpcodes = _opcodes6502.Concat(_opcodes65C02) .Concat(_opcodesR65C02) .ToDictionary(k => k.Key, k => k.Value, Assembler.Options.StringComparar); break; case "65C02": _filteredOpcodes = _opcodes6502.Concat(_opcodes65C02) .ToDictionary(k => k.Key, k => k.Value, Assembler.Options.StringComparar); break; case "6502i": _filteredOpcodes = _opcodes6502.Concat(_opcodes6502i) .ToDictionary(k => k.Key, k => k.Value, Assembler.Options.StringComparar); break; default: _filteredOpcodes = new OpcodeTable(_opcodes6502, Assembler.Options.StringComparar); break; } if (_m16) { SetImmediateA(3); } if (_x16) { SetImmediateXY(3); } }