added logging

This commit is contained in:
Lauchmelder 2021-10-22 17:49:20 +02:00
parent 0f62079193
commit f872e19707
6 changed files with 341 additions and 268 deletions

View file

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.8)
add_executable (nesemu "main.c" "cpu.h" "types.h" "bus.h" "bus.c" "cartridge.h" "cpu.c" "cartridge.c" "opcodes.c")
add_executable (nesemu "main.c" "cpu.h" "types.h" "bus.h" "bus.c" "cartridge.h" "cpu.c" "cartridge.c" "opcodes.c" "log.c")
if(MSVC)
target_compile_definitions(nesemu PUBLIC _CRT_SECURE_NO_WARNINGS)

View file

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "log.h"
#include "bus.h"
struct CPU* createCPU(struct Bus* parent)
@ -16,6 +17,14 @@ struct CPU* createCPU(struct Bus* parent)
// TODO: THIS IS JUST FOR THE TEST ROM
cpu->pc = 0xC000;
cpu->status.raw = 0x34;
cpu->acc = 0;
cpu->x = 0;
cpu->y = 0;
cpu->remainingCycles = 7;
cpu->totalCycles = 0;
cpu->bus = parent;
return cpu;
}
@ -25,27 +34,29 @@ void destroyCPU(struct CPU* cpu)
free(cpu);
}
void tickCPU(struct CPU* cpu)
int tickCPU(struct CPU* cpu)
{
if (cpu->fetchedVal != 0)
cpu->remainingCycles--;
cpu->totalCycles += 1;
if (cpu->remainingCycles == 0)
{
cpu->fetchedVal--;
return;
fetch(cpu);
execute(cpu);
return 1;
}
fetch(cpu);
execute(cpu);
return 0;
}
void tickInstr(struct CPU* cpu)
{
while (cpu->remainingCycles > 1)
tickCPU(cpu);
while (!tickCPU(cpu));
}
void fetch(struct CPU* cpu)
{
Byte opcodeVal = readBus(cpu->bus, cpu->pc);
Byte opcodeVal = readBus(cpu->bus, cpu->pc++);
cpu->currentOpcode = OPCODE_TABLE + opcodeVal;
if (cpu->currentOpcode->op == XXX)
@ -164,6 +175,8 @@ void fetch(struct CPU* cpu)
void execute(struct CPU* cpu)
{
LOG_BUS(cpu->bus);
switch (cpu->currentOpcode->op)
{
case JMP:

View file

@ -27,6 +27,7 @@ struct Opcode
enum Operation op;
enum AddrMode addr;
Byte cycles;
Byte length;
const char str[4];
};
@ -59,6 +60,7 @@ struct CPU
Word pc;
Byte remainingCycles;
size_t totalCycles;
Byte fetchedVal;
Word fetchedAddress;
@ -72,7 +74,7 @@ struct CPU
struct CPU* createCPU(struct Bus* parent);
void destroyCPU(struct CPU* cpu);
void tickCPU(struct CPU* cpu);
int tickCPU(struct CPU* cpu);
void tickInstr(struct CPU* cpu);
void fetch(struct CPU* cpu);

44
NES Emulator/log.c Normal file
View file

@ -0,0 +1,44 @@
#include "log.h"
#include <stdio.h>
#include "bus.h"
#include "cpu.h"
void logBusState(struct Bus* bus)
{
const char buffer[32];
Word oldPC = bus->cpu->pc - bus->cpu->currentOpcode->length;
printf("%04X ", oldPC);
Word instructionBytes[3];
for (int i = 0; i < bus->cpu->currentOpcode->length; i++)
{
instructionBytes[i] = readBus(bus, oldPC + i);
sprintf(buffer + 3 * i, "%02X ", instructionBytes[i]);
}
printf("%-10s%s ", buffer, bus->cpu->currentOpcode->str);
switch (bus->cpu->currentOpcode->addr)
{
case ACC: sprintf(buffer, "A"); break;
case ABS: sprintf(buffer, "$%04X", bus->cpu->fetchedAddress); break;
case ABX: sprintf(buffer, "$%04X, X -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
case ABY: sprintf(buffer, "$%04X, Y -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
case IMM: sprintf(buffer, "#$%04X", bus->cpu->fetchedVal); break;
case IMP: sprintf(buffer, ""); break;
case IND: sprintf(buffer, "($%04X) -> $%04x", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
case INDX: sprintf(buffer, "($%04X, X) -> $%04x", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
case INDY: sprintf(buffer, "($%04X), Y -> $%04x", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
case REL: sprintf(buffer, "$%02X", bus->cpu->fetchedRelAddress); break;
case ZPG: sprintf(buffer, "$%02X", bus->cpu->fetchedAddress); break;
case ZPX: sprintf(buffer, "$%02X, X -> $%02X", instructionBytes[1], bus->cpu->fetchedAddress); break;
case ZPY: sprintf(buffer, "$%02X, Y -> $%02X", instructionBytes[1], bus->cpu->fetchedAddress); break;
}
printf("%-28s", buffer);
printf("A:%02X X:%02X Y:%02X SP:%02X P:%02X CYC:%zu\n", bus->cpu->acc, bus->cpu->x, bus->cpu->y, bus->cpu->sp, bus->cpu->status.raw, bus->cpu->totalCycles);
}

14
NES Emulator/log.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef _LOG_H_
#define _LOG_H_
struct Bus;
void logBusState(struct Bus* bus);
#ifndef NDEBUG
#define LOG_BUS(b) logBusState(b)
#else
#define LOG_BUS(b)
#endif // NDEBUG
#endif // _LOG_H_

View file

@ -1,278 +1,278 @@
#include "cpu.h"
#define NEW_OPCODE(op, addr, cyc) {op, addr, cyc, #op}
#define NEW_OPCODE(op, addr, cyc, len) {op, addr, cyc, len, #op}
const struct Opcode OPCODE_TABLE[256] =
{
/* 00 */ NEW_OPCODE(BRK, IMP, 7),
/* 01 */ NEW_OPCODE(ORA, INDX, 6),
/* 02 */ NEW_OPCODE(XXX, IMP, 0),
/* 03 */ NEW_OPCODE(XXX, IMP, 0),
/* 04 */ NEW_OPCODE(XXX, IMP, 0),
/* 05 */ NEW_OPCODE(ORA, ZPG, 3),
/* 06 */ NEW_OPCODE(ASL, ZPG, 5),
/* 07 */ NEW_OPCODE(XXX, IMP, 0),
/* 08 */ NEW_OPCODE(PHP, IMP, 3),
/* 09 */ NEW_OPCODE(ORA, IMM, 2),
/* 0A */ NEW_OPCODE(ASL, ACC, 2),
/* 0B */ NEW_OPCODE(XXX, IMP, 0),
/* 0C */ NEW_OPCODE(XXX, IMP, 0),
/* 0D */ NEW_OPCODE(ORA, ABS, 4),
/* 0E */ NEW_OPCODE(ASL, ABS, 6),
/* 0F */ NEW_OPCODE(XXX, IMP, 0),
/* 00 */ NEW_OPCODE(BRK, IMP, 7, 1),
/* 01 */ NEW_OPCODE(ORA, INDX, 6, 2),
/* 02 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 03 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 04 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 05 */ NEW_OPCODE(ORA, ZPG, 3, 2),
/* 06 */ NEW_OPCODE(ASL, ZPG, 5, 2),
/* 07 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 08 */ NEW_OPCODE(PHP, IMP, 3, 1),
/* 09 */ NEW_OPCODE(ORA, IMM, 2, 2),
/* 0A */ NEW_OPCODE(ASL, ACC, 2, 1),
/* 0B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 0C */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 0D */ NEW_OPCODE(ORA, ABS, 4, 3),
/* 0E */ NEW_OPCODE(ASL, ABS, 6, 3),
/* 0F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 10 */ NEW_OPCODE(BPL, REL, 2),
/* 11 */ NEW_OPCODE(ORA, INDY, 5),
/* 12 */ NEW_OPCODE(XXX, IMP, 0),
/* 13 */ NEW_OPCODE(XXX, IMP, 0),
/* 14 */ NEW_OPCODE(XXX, IMP, 0),
/* 15 */ NEW_OPCODE(ORA, ZPX, 4),
/* 16 */ NEW_OPCODE(ASL, ZPX, 6),
/* 17 */ NEW_OPCODE(XXX, IMP, 0),
/* 18 */ NEW_OPCODE(CLC, IMP, 2),
/* 19 */ NEW_OPCODE(ORA, ABY, 4),
/* 1A */ NEW_OPCODE(XXX, IMP, 0),
/* 1B */ NEW_OPCODE(XXX, IMP, 0),
/* 1C */ NEW_OPCODE(XXX, IMP, 0),
/* 1D */ NEW_OPCODE(ORA, ABX, 4),
/* 1E */ NEW_OPCODE(ASL, ABX, 7),
/* 1F */ NEW_OPCODE(XXX, IMP, 0),
/* 10 */ NEW_OPCODE(BPL, REL, 2, 2),
/* 11 */ NEW_OPCODE(ORA, INDY, 5, 2),
/* 12 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 13 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 14 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 15 */ NEW_OPCODE(ORA, ZPX, 4, 2),
/* 16 */ NEW_OPCODE(ASL, ZPX, 6, 2),
/* 17 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 18 */ NEW_OPCODE(CLC, IMP, 2, 1),
/* 19 */ NEW_OPCODE(ORA, ABY, 4, 3),
/* 1A */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 1B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 1C */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 1D */ NEW_OPCODE(ORA, ABX, 4, 3),
/* 1E */ NEW_OPCODE(ASL, ABX, 7, 3),
/* 1F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 20 */ NEW_OPCODE(JSR, ABS, 6),
/* 21 */ NEW_OPCODE(AND, INDX, 6),
/* 22 */ NEW_OPCODE(XXX, IMP, 0),
/* 23 */ NEW_OPCODE(XXX, IMP, 0),
/* 24 */ NEW_OPCODE(BIT, ZPG, 3),
/* 25 */ NEW_OPCODE(AND, ZPG, 3),
/* 26 */ NEW_OPCODE(ROL, ZPG, 5),
/* 27 */ NEW_OPCODE(XXX, IMP, 0),
/* 28 */ NEW_OPCODE(PLP, IMP, 4),
/* 29 */ NEW_OPCODE(AND, IMM, 2),
/* 2A */ NEW_OPCODE(ROL, ACC, 2),
/* 2B */ NEW_OPCODE(XXX, IMP, 0),
/* 2C */ NEW_OPCODE(BIT, ABS, 4),
/* 2D */ NEW_OPCODE(AND, ABS, 4),
/* 2E */ NEW_OPCODE(ROL, ABS, 6),
/* 2F */ NEW_OPCODE(XXX, IMP, 0),
/* 20 */ NEW_OPCODE(JSR, ABS, 6, 3),
/* 21 */ NEW_OPCODE(AND, INDX, 6, 2),
/* 22 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 23 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 24 */ NEW_OPCODE(BIT, ZPG, 3, 2),
/* 25 */ NEW_OPCODE(AND, ZPG, 3, 2),
/* 26 */ NEW_OPCODE(ROL, ZPG, 5, 2),
/* 27 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 28 */ NEW_OPCODE(PLP, IMP, 4, 1),
/* 29 */ NEW_OPCODE(AND, IMM, 2, 2),
/* 2A */ NEW_OPCODE(ROL, ACC, 2, 1),
/* 2B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 2C */ NEW_OPCODE(BIT, ABS, 4, 3),
/* 2D */ NEW_OPCODE(AND, ABS, 4, 3),
/* 2E */ NEW_OPCODE(ROL, ABS, 6, 3),
/* 2F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 30 */ NEW_OPCODE(BMI, REL, 2),
/* 31 */ NEW_OPCODE(AND, INDY, 5),
/* 32 */ NEW_OPCODE(XXX, IMP, 0),
/* 33 */ NEW_OPCODE(XXX, IMP, 0),
/* 34 */ NEW_OPCODE(XXX, IMP, 0),
/* 35 */ NEW_OPCODE(AND, ZPX, 4),
/* 36 */ NEW_OPCODE(ROL, ZPX, 6),
/* 37 */ NEW_OPCODE(XXX, IMP, 0),
/* 38 */ NEW_OPCODE(SEC, IMP, 2),
/* 39 */ NEW_OPCODE(AND, ABY, 4),
/* 3A */ NEW_OPCODE(XXX, IMP, 0),
/* 3B */ NEW_OPCODE(XXX, IMP, 0),
/* 3C */ NEW_OPCODE(XXX, IMP, 0),
/* 3D */ NEW_OPCODE(AND, ABX, 4),
/* 3E */ NEW_OPCODE(ROL, ABX, 7),
/* 3F */ NEW_OPCODE(XXX, IMP, 0),
/* 30 */ NEW_OPCODE(BMI, REL, 2, 2),
/* 31 */ NEW_OPCODE(AND, INDY, 5, 2),
/* 32 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 33 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 34 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 35 */ NEW_OPCODE(AND, ZPX, 4, 2),
/* 36 */ NEW_OPCODE(ROL, ZPX, 6, 2),
/* 37 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 38 */ NEW_OPCODE(SEC, IMP, 2, 1),
/* 39 */ NEW_OPCODE(AND, ABY, 4, 3),
/* 3A */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 3B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 3C */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 3D */ NEW_OPCODE(AND, ABX, 4, 3),
/* 3E */ NEW_OPCODE(ROL, ABX, 7, 3),
/* 3F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 40 */ NEW_OPCODE(RTI, IMP, 6),
/* 41 */ NEW_OPCODE(EOR, INDX, 6),
/* 42 */ NEW_OPCODE(XXX, IMP, 0),
/* 43 */ NEW_OPCODE(XXX, IMP, 0),
/* 44 */ NEW_OPCODE(XXX, IMP, 0),
/* 45 */ NEW_OPCODE(EOR, ZPG, 3),
/* 46 */ NEW_OPCODE(LSR, ZPG, 5),
/* 47 */ NEW_OPCODE(XXX, IMP, 0),
/* 48 */ NEW_OPCODE(PHA, IMP, 3),
/* 49 */ NEW_OPCODE(EOR, IMM, 2),
/* 4A */ NEW_OPCODE(LSR, ACC, 2),
/* 4B */ NEW_OPCODE(XXX, IMP, 0),
/* 4C */ NEW_OPCODE(JMP, ABS, 3),
/* 4D */ NEW_OPCODE(EOR, ABS, 4),
/* 4E */ NEW_OPCODE(LSR, ABS, 6),
/* 4F */ NEW_OPCODE(XXX, IMP, 0),
/* 40 */ NEW_OPCODE(RTI, IMP, 6, 1),
/* 41 */ NEW_OPCODE(EOR, INDX, 6, 2),
/* 42 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 43 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 44 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 45 */ NEW_OPCODE(EOR, ZPG, 3, 2),
/* 46 */ NEW_OPCODE(LSR, ZPG, 5, 2),
/* 47 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 48 */ NEW_OPCODE(PHA, IMP, 3, 1),
/* 49 */ NEW_OPCODE(EOR, IMM, 2, 2),
/* 4A */ NEW_OPCODE(LSR, ACC, 2, 1),
/* 4B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 4C */ NEW_OPCODE(JMP, ABS, 3, 3),
/* 4D */ NEW_OPCODE(EOR, ABS, 4, 3),
/* 4E */ NEW_OPCODE(LSR, ABS, 6, 3),
/* 4F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 50 */ NEW_OPCODE(BVC, REL, 2),
/* 51 */ NEW_OPCODE(EOR, INDY, 5),
/* 52 */ NEW_OPCODE(XXX, IMP, 0),
/* 53 */ NEW_OPCODE(XXX, IMP, 0),
/* 54 */ NEW_OPCODE(XXX, IMP, 0),
/* 55 */ NEW_OPCODE(EOR, ZPX, 4),
/* 56 */ NEW_OPCODE(LSR, ZPX, 6),
/* 57 */ NEW_OPCODE(XXX, IMP, 0),
/* 58 */ NEW_OPCODE(CLI, IMP, 2),
/* 59 */ NEW_OPCODE(EOR, ABY, 4),
/* 5A */ NEW_OPCODE(XXX, IMP, 0),
/* 5B */ NEW_OPCODE(XXX, IMP, 0),
/* 5C */ NEW_OPCODE(XXX, IMP, 0),
/* 5D */ NEW_OPCODE(EOR, ABX, 4),
/* 5E */ NEW_OPCODE(LSR, ABX, 7),
/* 5F */ NEW_OPCODE(XXX, IMP, 0),
/* 50 */ NEW_OPCODE(BVC, REL, 2, 2),
/* 51 */ NEW_OPCODE(EOR, INDY, 5, 2),
/* 52 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 53 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 54 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 55 */ NEW_OPCODE(EOR, ZPX, 4, 2),
/* 56 */ NEW_OPCODE(LSR, ZPX, 6, 2),
/* 57 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 58 */ NEW_OPCODE(CLI, IMP, 2, 1),
/* 59 */ NEW_OPCODE(EOR, ABY, 4, 3),
/* 5A */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 5B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 5C */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 5D */ NEW_OPCODE(EOR, ABX, 4, 3),
/* 5E */ NEW_OPCODE(LSR, ABX, 7, 3),
/* 5F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 60 */ NEW_OPCODE(RTS, IMP, 6),
/* 61 */ NEW_OPCODE(ADC, INDX, 6),
/* 62 */ NEW_OPCODE(XXX, IMP, 0),
/* 63 */ NEW_OPCODE(XXX, IMP, 0),
/* 64 */ NEW_OPCODE(XXX, IMP, 0),
/* 65 */ NEW_OPCODE(ADC, ZPG, 3),
/* 66 */ NEW_OPCODE(ROR, ZPG, 5),
/* 67 */ NEW_OPCODE(XXX, IMP, 0),
/* 68 */ NEW_OPCODE(PLA, IMP, 4),
/* 69 */ NEW_OPCODE(ADC, IMM, 2),
/* 6A */ NEW_OPCODE(ROR, ACC, 2),
/* 6B */ NEW_OPCODE(XXX, IMP, 0),
/* 6C */ NEW_OPCODE(JMP, IND, 5),
/* 6D */ NEW_OPCODE(ADC, ABS, 4),
/* 6E */ NEW_OPCODE(ROR, ABS, 6),
/* 6F */ NEW_OPCODE(XXX, IMP, 0),
/* 60 */ NEW_OPCODE(RTS, IMP, 6, 1),
/* 61 */ NEW_OPCODE(ADC, INDX, 6, 2),
/* 62 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 63 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 64 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 65 */ NEW_OPCODE(ADC, ZPG, 3, 2),
/* 66 */ NEW_OPCODE(ROR, ZPG, 5, 2),
/* 67 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 68 */ NEW_OPCODE(PLA, IMP, 4, 1),
/* 69 */ NEW_OPCODE(ADC, IMM, 2, 2),
/* 6A */ NEW_OPCODE(ROR, ACC, 2, 1),
/* 6B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 6C */ NEW_OPCODE(JMP, IND, 5, 3),
/* 6D */ NEW_OPCODE(ADC, ABS, 4, 3),
/* 6E */ NEW_OPCODE(ROR, ABS, 6, 3),
/* 6F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 70 */ NEW_OPCODE(BVS, REL, 2),
/* 71 */ NEW_OPCODE(ADC, INDY, 5),
/* 72 */ NEW_OPCODE(XXX, IMP, 0),
/* 73 */ NEW_OPCODE(XXX, IMP, 0),
/* 74 */ NEW_OPCODE(XXX, IMP, 0),
/* 75 */ NEW_OPCODE(ADC, ZPX, 4),
/* 76 */ NEW_OPCODE(ROR, ZPX, 6),
/* 77 */ NEW_OPCODE(XXX, IMP, 0),
/* 78 */ NEW_OPCODE(SEI, IMP, 2),
/* 79 */ NEW_OPCODE(ADC, ABY, 4),
/* 7A */ NEW_OPCODE(XXX, IMP, 0),
/* 7B */ NEW_OPCODE(XXX, IMP, 0),
/* 7C */ NEW_OPCODE(XXX, IMP, 0),
/* 7D */ NEW_OPCODE(ADC, ABX, 4),
/* 7E */ NEW_OPCODE(ROR, ABX, 7),
/* 7F */ NEW_OPCODE(XXX, IMP, 0),
/* 70 */ NEW_OPCODE(BVS, REL, 2, 2),
/* 71 */ NEW_OPCODE(ADC, INDY, 5, 2),
/* 72 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 73 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 74 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 75 */ NEW_OPCODE(ADC, ZPX, 4, 2),
/* 76 */ NEW_OPCODE(ROR, ZPX, 6, 2),
/* 77 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 78 */ NEW_OPCODE(SEI, IMP, 2, 1),
/* 79 */ NEW_OPCODE(ADC, ABY, 4, 3),
/* 7A */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 7B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 7C */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 7D */ NEW_OPCODE(ADC, ABX, 4, 3),
/* 7E */ NEW_OPCODE(ROR, ABX, 7, 3),
/* 7F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 80 */ NEW_OPCODE(XXX, IMP, 0),
/* 81 */ NEW_OPCODE(STA, INDX, 6),
/* 82 */ NEW_OPCODE(XXX, IMP, 0),
/* 83 */ NEW_OPCODE(XXX, IMP, 0),
/* 84 */ NEW_OPCODE(STY, ZPG, 3),
/* 85 */ NEW_OPCODE(STA, ZPG, 3),
/* 86 */ NEW_OPCODE(STX, ZPG, 3),
/* 87 */ NEW_OPCODE(XXX, IMP, 0),
/* 88 */ NEW_OPCODE(DEY, IMP, 2),
/* 89 */ NEW_OPCODE(XXX, IMP, 0),
/* 8A */ NEW_OPCODE(TXA, IMP, 2),
/* 8B */ NEW_OPCODE(XXX, IMP, 0),
/* 8C */ NEW_OPCODE(STY, ABS, 4),
/* 8D */ NEW_OPCODE(STA, ABS, 4),
/* 8E */ NEW_OPCODE(STX, ABS, 4),
/* 8F */ NEW_OPCODE(XXX, IMP, 0),
/* 80 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 81 */ NEW_OPCODE(STA, INDX, 6, 2),
/* 82 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 83 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 84 */ NEW_OPCODE(STY, ZPG, 3, 2),
/* 85 */ NEW_OPCODE(STA, ZPG, 3, 2),
/* 86 */ NEW_OPCODE(STX, ZPG, 3, 2),
/* 87 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 88 */ NEW_OPCODE(DEY, IMP, 2, 1),
/* 89 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 8A */ NEW_OPCODE(TXA, IMP, 2, 1),
/* 8B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 8C */ NEW_OPCODE(STY, ABS, 4, 3),
/* 8D */ NEW_OPCODE(STA, ABS, 4, 3),
/* 8E */ NEW_OPCODE(STX, ABS, 4, 3),
/* 8F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 90 */ NEW_OPCODE(BCC, REL, 2),
/* 91 */ NEW_OPCODE(STA, INDY, 6),
/* 92 */ NEW_OPCODE(XXX, IMP, 0),
/* 93 */ NEW_OPCODE(XXX, IMP, 0),
/* 94 */ NEW_OPCODE(STY, ZPX, 4),
/* 95 */ NEW_OPCODE(STA, ZPX, 4),
/* 96 */ NEW_OPCODE(STX, ZPY, 4),
/* 97 */ NEW_OPCODE(XXX, IMP, 0),
/* 98 */ NEW_OPCODE(TYA, IMP, 2),
/* 99 */ NEW_OPCODE(STA, ABY, 5),
/* 9A */ NEW_OPCODE(TXS, IMP, 2),
/* 9B */ NEW_OPCODE(XXX, IMP, 0),
/* 9C */ NEW_OPCODE(XXX, IMP, 0),
/* 9D */ NEW_OPCODE(STA, ABX, 5),
/* 9E */ NEW_OPCODE(XXX, IMP, 0),
/* 9F */ NEW_OPCODE(XXX, IMP, 0),
/* 90 */ NEW_OPCODE(BCC, REL, 2, 2),
/* 91 */ NEW_OPCODE(STA, INDY, 6, 2),
/* 92 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 93 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 94 */ NEW_OPCODE(STY, ZPX, 4, 2),
/* 95 */ NEW_OPCODE(STA, ZPX, 4, 2),
/* 96 */ NEW_OPCODE(STX, ZPY, 4, 2),
/* 97 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 98 */ NEW_OPCODE(TYA, IMP, 2, 1),
/* 99 */ NEW_OPCODE(STA, ABY, 5, 3),
/* 9A */ NEW_OPCODE(TXS, IMP, 2, 1),
/* 9B */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 9C */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 9D */ NEW_OPCODE(STA, ABX, 5, 3),
/* 9E */ NEW_OPCODE(XXX, IMP, 0, 1),
/* 9F */ NEW_OPCODE(XXX, IMP, 0, 1),
/* A0 */ NEW_OPCODE(LDY, IMM, 2),
/* A1 */ NEW_OPCODE(LDA, INDX, 6),
/* A2 */ NEW_OPCODE(LDX, IMM, 2),
/* A3 */ NEW_OPCODE(XXX, IMP, 0),
/* A4 */ NEW_OPCODE(LDY, ZPG, 3),
/* A5 */ NEW_OPCODE(LDA, ZPG, 3),
/* A6 */ NEW_OPCODE(LDX, ZPG, 3),
/* A7 */ NEW_OPCODE(XXX, IMP, 0),
/* A8 */ NEW_OPCODE(TAY, IMP, 2),
/* A9 */ NEW_OPCODE(LDA, IMM, 2),
/* AA */ NEW_OPCODE(TAX, IMP, 2),
/* AB */ NEW_OPCODE(XXX, IMP, 0),
/* AC */ NEW_OPCODE(LDY, ABS, 4),
/* AD */ NEW_OPCODE(LDA, ABS, 4),
/* AE */ NEW_OPCODE(LDX, ABS, 4),
/* AF */ NEW_OPCODE(XXX, IMP, 0),
/* A0 */ NEW_OPCODE(LDY, IMM, 2, 2),
/* A1 */ NEW_OPCODE(LDA, INDX, 6, 2),
/* A2 */ NEW_OPCODE(LDX, IMM, 2, 2),
/* A3 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* A4 */ NEW_OPCODE(LDY, ZPG, 3, 2),
/* A5 */ NEW_OPCODE(LDA, ZPG, 3, 2),
/* A6 */ NEW_OPCODE(LDX, ZPG, 3, 2),
/* A7 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* A8 */ NEW_OPCODE(TAY, IMP, 2, 1),
/* A9 */ NEW_OPCODE(LDA, IMM, 2, 2),
/* AA */ NEW_OPCODE(TAX, IMP, 2, 1),
/* AB */ NEW_OPCODE(XXX, IMP, 0, 1),
/* AC */ NEW_OPCODE(LDY, ABS, 4, 3),
/* AD */ NEW_OPCODE(LDA, ABS, 4, 3),
/* AE */ NEW_OPCODE(LDX, ABS, 4, 3),
/* AF */ NEW_OPCODE(XXX, IMP, 0, 1),
/* B0 */ NEW_OPCODE(BCS, REL, 2),
/* B1 */ NEW_OPCODE(LDA, INDY, 5),
/* B2 */ NEW_OPCODE(XXX, IMP, 0),
/* B3 */ NEW_OPCODE(XXX, IMP, 0),
/* B4 */ NEW_OPCODE(LDY, ZPX, 4),
/* B5 */ NEW_OPCODE(LDA, ZPX, 4),
/* B6 */ NEW_OPCODE(LDX, ZPY, 4),
/* B7 */ NEW_OPCODE(XXX, IMP, 0),
/* B8 */ NEW_OPCODE(CLV, IMP, 2),
/* B9 */ NEW_OPCODE(LDA, ABY, 4),
/* BA */ NEW_OPCODE(TSX, IMP, 2),
/* BB */ NEW_OPCODE(XXX, IMP, 0),
/* BC */ NEW_OPCODE(LDY, ABX, 4),
/* BD */ NEW_OPCODE(LDA, ABX, 4),
/* BE */ NEW_OPCODE(LDX, ABY, 4),
/* BF */ NEW_OPCODE(XXX, IMP, 0),
/* B0 */ NEW_OPCODE(BCS, REL, 2, 2),
/* B1 */ NEW_OPCODE(LDA, INDY, 5, 2),
/* B2 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* B3 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* B4 */ NEW_OPCODE(LDY, ZPX, 4, 2),
/* B5 */ NEW_OPCODE(LDA, ZPX, 4, 2),
/* B6 */ NEW_OPCODE(LDX, ZPY, 4, 2),
/* B7 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* B8 */ NEW_OPCODE(CLV, IMP, 2, 1),
/* B9 */ NEW_OPCODE(LDA, ABY, 4, 3),
/* BA */ NEW_OPCODE(TSX, IMP, 2, 1),
/* BB */ NEW_OPCODE(XXX, IMP, 0, 1),
/* BC */ NEW_OPCODE(LDY, ABX, 4, 3),
/* BD */ NEW_OPCODE(LDA, ABX, 4, 3),
/* BE */ NEW_OPCODE(LDX, ABY, 4, 3),
/* BF */ NEW_OPCODE(XXX, IMP, 0, 1),
/* C0 */ NEW_OPCODE(CPY, IMM, 2),
/* C1 */ NEW_OPCODE(CMP, INDX, 6),
/* C2 */ NEW_OPCODE(XXX, IMP, 0),
/* C3 */ NEW_OPCODE(XXX, IMP, 0),
/* C4 */ NEW_OPCODE(CPY, ZPG, 3),
/* C5 */ NEW_OPCODE(CMP, ZPG, 3),
/* C6 */ NEW_OPCODE(DEC, ZPG, 5),
/* C7 */ NEW_OPCODE(XXX, IMP, 0),
/* C8 */ NEW_OPCODE(INY, IMP, 2),
/* C9 */ NEW_OPCODE(CMP, IMM, 2),
/* CA */ NEW_OPCODE(DEX, IMP, 2),
/* CB */ NEW_OPCODE(XXX, IMP, 0),
/* CC */ NEW_OPCODE(CPY, ABS, 4),
/* CD */ NEW_OPCODE(CMP, ABS, 4),
/* CE */ NEW_OPCODE(DEC, ABS, 6),
/* CF */ NEW_OPCODE(XXX, IMP, 0),
/* C0 */ NEW_OPCODE(CPY, IMM, 2, 2),
/* C1 */ NEW_OPCODE(CMP, INDX, 6, 2),
/* C2 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* C3 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* C4 */ NEW_OPCODE(CPY, ZPG, 3, 2),
/* C5 */ NEW_OPCODE(CMP, ZPG, 3, 2),
/* C6 */ NEW_OPCODE(DEC, ZPG, 5, 2),
/* C7 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* C8 */ NEW_OPCODE(INY, IMP, 2, 1),
/* C9 */ NEW_OPCODE(CMP, IMM, 2, 2),
/* CA */ NEW_OPCODE(DEX, IMP, 2, 1),
/* CB */ NEW_OPCODE(XXX, IMP, 0, 1),
/* CC */ NEW_OPCODE(CPY, ABS, 4, 3),
/* CD */ NEW_OPCODE(CMP, ABS, 4, 3),
/* CE */ NEW_OPCODE(DEC, ABS, 6, 3),
/* CF */ NEW_OPCODE(XXX, IMP, 0, 1),
/* D0 */ NEW_OPCODE(BNE, REL, 2),
/* D1 */ NEW_OPCODE(CMP, INDY, 5),
/* D2 */ NEW_OPCODE(XXX, IMP, 0),
/* D3 */ NEW_OPCODE(XXX, IMP, 0),
/* D4 */ NEW_OPCODE(XXX, IMP, 0),
/* D5 */ NEW_OPCODE(CMP, ZPX, 4),
/* D6 */ NEW_OPCODE(DEC, ZPX, 6),
/* D7 */ NEW_OPCODE(XXX, IMP, 0),
/* D8 */ NEW_OPCODE(CLD, IMP, 2),
/* D9 */ NEW_OPCODE(CMP, ABY, 4),
/* DA */ NEW_OPCODE(XXX, IMP, 0),
/* DB */ NEW_OPCODE(XXX, IMP, 0),
/* DC */ NEW_OPCODE(XXX, IMP, 0),
/* DD */ NEW_OPCODE(CMP, ABX, 4),
/* DE */ NEW_OPCODE(DEC, ABX, 7),
/* DF */ NEW_OPCODE(XXX, IMP, 0),
/* D0 */ NEW_OPCODE(BNE, REL, 2, 2),
/* D1 */ NEW_OPCODE(CMP, INDY, 5, 2),
/* D2 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* D3 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* D4 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* D5 */ NEW_OPCODE(CMP, ZPX, 4, 2),
/* D6 */ NEW_OPCODE(DEC, ZPX, 6, 2),
/* D7 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* D8 */ NEW_OPCODE(CLD, IMP, 2, 1),
/* D9 */ NEW_OPCODE(CMP, ABY, 4, 3),
/* DA */ NEW_OPCODE(XXX, IMP, 0, 1),
/* DB */ NEW_OPCODE(XXX, IMP, 0, 1),
/* DC */ NEW_OPCODE(XXX, IMP, 0, 1),
/* DD */ NEW_OPCODE(CMP, ABX, 4, 3),
/* DE */ NEW_OPCODE(DEC, ABX, 7, 3),
/* DF */ NEW_OPCODE(XXX, IMP, 0, 1),
/* E0 */ NEW_OPCODE(CPX, IMM, 2),
/* E1 */ NEW_OPCODE(SBC, INDX, 6),
/* E2 */ NEW_OPCODE(XXX, IMP, 0),
/* E3 */ NEW_OPCODE(XXX, IMP, 0),
/* E4 */ NEW_OPCODE(CPX, ZPG, 3),
/* E5 */ NEW_OPCODE(SBC, ZPG, 3),
/* E6 */ NEW_OPCODE(INC, ZPG, 5),
/* E7 */ NEW_OPCODE(XXX, IMP, 0),
/* E8 */ NEW_OPCODE(INX, IMP, 2),
/* E9 */ NEW_OPCODE(SBC, IMM, 2),
/* EA */ NEW_OPCODE(NOP, IMP, 2),
/* EB */ NEW_OPCODE(XXX, IMP, 0),
/* EC */ NEW_OPCODE(CPX, ABS, 4),
/* ED */ NEW_OPCODE(SBC, ABS, 4),
/* EE */ NEW_OPCODE(INC, ABS, 6),
/* EF */ NEW_OPCODE(XXX, IMP, 0),
/* E0 */ NEW_OPCODE(CPX, IMM, 2, 2),
/* E1 */ NEW_OPCODE(SBC, INDX, 6, 2),
/* E2 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* E3 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* E4 */ NEW_OPCODE(CPX, ZPG, 3, 2),
/* E5 */ NEW_OPCODE(SBC, ZPG, 3, 2),
/* E6 */ NEW_OPCODE(INC, ZPG, 5, 2),
/* E7 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* E8 */ NEW_OPCODE(INX, IMP, 2, 1),
/* E9 */ NEW_OPCODE(SBC, IMM, 2, 2),
/* EA */ NEW_OPCODE(NOP, IMP, 2, 1),
/* EB */ NEW_OPCODE(XXX, IMP, 0, 1),
/* EC */ NEW_OPCODE(CPX, ABS, 4, 3),
/* ED */ NEW_OPCODE(SBC, ABS, 4, 3),
/* EE */ NEW_OPCODE(INC, ABS, 6, 3),
/* EF */ NEW_OPCODE(XXX, IMP, 0, 1),
/* F0 */ NEW_OPCODE(BEQ, REL, 2),
/* F1 */ NEW_OPCODE(SBC, INDY, 5),
/* F2 */ NEW_OPCODE(XXX, IMP, 0),
/* F3 */ NEW_OPCODE(XXX, IMP, 0),
/* F4 */ NEW_OPCODE(XXX, IMP, 0),
/* F5 */ NEW_OPCODE(SBC, ZPX, 4),
/* F6 */ NEW_OPCODE(INC, ZPX, 6),
/* F7 */ NEW_OPCODE(XXX, IMP, 0),
/* F8 */ NEW_OPCODE(SED, IMP, 2),
/* F9 */ NEW_OPCODE(SBC, ABY, 4),
/* FA */ NEW_OPCODE(XXX, IMP, 0),
/* FB */ NEW_OPCODE(XXX, IMP, 0),
/* FC */ NEW_OPCODE(XXX, IMP, 0),
/* FD */ NEW_OPCODE(SBC, ABX, 4),
/* FE */ NEW_OPCODE(INC, ABX, 7),
/* FF */ NEW_OPCODE(XXX, IMP, 0)
/* F0 */ NEW_OPCODE(BEQ, REL, 2, 2),
/* F1 */ NEW_OPCODE(SBC, INDY, 5, 2),
/* F2 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* F3 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* F4 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* F5 */ NEW_OPCODE(SBC, ZPX, 4, 2),
/* F6 */ NEW_OPCODE(INC, ZPX, 6, 2),
/* F7 */ NEW_OPCODE(XXX, IMP, 0, 1),
/* F8 */ NEW_OPCODE(SED, IMP, 2, 1),
/* F9 */ NEW_OPCODE(SBC, ABY, 4, 3),
/* FA */ NEW_OPCODE(XXX, IMP, 0, 1),
/* FB */ NEW_OPCODE(XXX, IMP, 0, 1),
/* FC */ NEW_OPCODE(XXX, IMP, 0, 1),
/* FD */ NEW_OPCODE(SBC, ABX, 4, 3),
/* FE */ NEW_OPCODE(INC, ABX, 7, 3),
/* FF */ NEW_OPCODE(XXX, IMP, 0, 1)
};