diff --git a/cmos.txt b/cmos.txt new file mode 100644 index 0000000..a2d670e --- /dev/null +++ b/cmos.txt @@ -0,0 +1,1401 @@ +override void opcode18() +{ +peek(programCounter); +flag.carry = false; +} + +override void opcode38() +{ +peek(programCounter); +flag.carry = true; +} + +override void opcode58() +{ +peek(programCounter); +flag.interrupt = false; +} + +override void opcode78() +{ +peek(programCounter); +flag.interrupt = true; +} + +override void opcodeB8() +{ +peek(programCounter); +flag.overflow = false; +} + +override void opcodeD8() +{ +peek(programCounter); +flag.decimal = false; +} + +override void opcodeF8() +{ +peek(programCounter); +flag.decimal = true; +} + +override void opcodeEA() +{ +peek(programCounter); + +} + +override void opcode08() +{ +peek(programCounter); +push(flag.toByte()); +} + +override void opcode28() +{ +peek(programCounter); +flag.fromByte(pull()); +} + +override void opcode48() +{ +peek(programCounter); +push(accumulator); +} + +override void opcode9A() +{ +peek(programCounter); +stackPointer = xIndex; +} + +override void opcode68() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = pull()); +} + +override void opcodeBA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex = stackPointer); +} + +override void opcodeAA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex = accumulator); +} + +override void opcode8A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = xIndex); +} + +override void opcodeCA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex -= 1); +} + +override void opcodeE8() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex += 1); +} + +override void opcodeA8() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex = accumulator); +} + +override void opcode98() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = yIndex); +} + +override void opcode88() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex -= 1); +} + +override void opcodeC8() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex += 1); +} + +override void opcode10() +{ +readByteOperand(); +if (flag.negative_ < 0x80) addrRelative(cast(byte)operand1); +} + +override void opcode30() +{ +readByteOperand(); +if (flag.negative_ > 0x7F) addrRelative(cast(byte)operand1); +} + +override void opcode50() +{ +readByteOperand(); +if (!flag.overflow) addrRelative(cast(byte)operand1); +} + +override void opcode70() +{ +readByteOperand(); +if (flag.overflow) addrRelative(cast(byte)operand1); +} + +override void opcode90() +{ +readByteOperand(); +if (!flag.carry) addrRelative(cast(byte)operand1); +} + +override void opcodeB0() +{ +readByteOperand(); +if (flag.carry) addrRelative(cast(byte)operand1); +} + +override void opcodeD0() +{ +readByteOperand(); +if (flag.zero_ != 0) addrRelative(cast(byte)operand1); +} + +override void opcodeF0() +{ +readByteOperand(); +if (flag.zero_ == 0) addrRelative(cast(byte)operand1); +} + +override void opcode0A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = shiftLeft(accumulator)); +} + +override void opcode2A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = rotateLeft(accumulator)); +} + +override void opcode4A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = shiftRight(accumulator)); +} + +override void opcode6A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = rotateRight(accumulator)); +} + +override void opcodeA1() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeA5() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeA9() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcodeAD() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeB1() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeB5() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeB9() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeBD() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} + +override void opcode01() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode05() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode09() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcode0D() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode11() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode15() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode19() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode1D() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} + +override void opcode21() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode25() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode29() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcode2D() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode31() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode35() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode39() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode3D() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} + +override void opcode41() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode45() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode49() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcode4D() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode51() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode55() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode59() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode5D() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} + +override void opcode61() +{ +addrIndirectX(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode65() +{ +addrZeropage(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode69() +{ +primaryAddress = programCounter++; +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +operand1 = readVal; +} +override void opcode6D() +{ +addrAbsolute(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode71() +{ +addrIndirectY(false); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode75() +{ +addrZeropageX(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode79() +{ +addrAbsoluteY(false); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode7D() +{ +addrAbsoluteX(false); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} + +override void opcodeE1() +{ +addrIndirectX(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeE5() +{ +addrZeropage(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeE9() +{ +primaryAddress = programCounter++; +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +operand1 = readVal; +} +override void opcodeED() +{ +addrAbsolute(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeF1() +{ +addrIndirectY(false); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeF5() +{ +addrZeropageX(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeF9() +{ +addrAbsoluteY(false); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeFD() +{ +addrAbsoluteX(false); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} + +override void opcodeC1() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeC5() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeC9() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +operand1 = readVal; +} +override void opcodeCD() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeD1() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeD5() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeD9() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeDD() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} + +override void opcode81() +{ +addrIndirectX(); +writeFinal(primaryAddress, accumulator); +} +override void opcode85() +{ +addrZeropage(); +writeFinal(primaryAddress, accumulator); +} +override void opcode8D() +{ +addrAbsolute(); +writeFinal(primaryAddress, accumulator); +} +override void opcode91() +{ +addrIndirectY(true); +writeFinal(primaryAddress, accumulator); +} +override void opcode95() +{ +addrZeropageX(); +writeFinal(primaryAddress, accumulator); +} +override void opcode99() +{ +addrAbsoluteY(true); +writeFinal(primaryAddress, accumulator); +} +override void opcode9D() +{ +addrAbsoluteX(true); +writeFinal(primaryAddress, accumulator); +} + +override void opcodeA2() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcodeA6() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeAE() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeB6() +{ +addrZeropageY(); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeBE() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} + +override void opcodeA0() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcodeA4() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeAC() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeB4() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeBC() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} + +override void opcodeE0() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (compare(xIndex, (readVal = readFinal(primaryAddress)))); +operand1 = readVal; +} +override void opcodeE4() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (compare(xIndex, (readVal = readFinal(primaryAddress)))); +} +override void opcodeEC() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (compare(xIndex, (readVal = readFinal(primaryAddress)))); +} + +override void opcodeC0() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (compare(yIndex, (readVal = readFinal(primaryAddress)))); +operand1 = readVal; +} +override void opcodeC4() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (compare(yIndex, (readVal = readFinal(primaryAddress)))); +} +override void opcodeCC() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (compare(yIndex, (readVal = readFinal(primaryAddress)))); +} + +override void opcode86() +{ +addrZeropage(); +writeFinal(primaryAddress, xIndex); +} +override void opcode8E() +{ +addrAbsolute(); +writeFinal(primaryAddress, xIndex); +} +override void opcode96() +{ +addrZeropageY(); +writeFinal(primaryAddress, xIndex); +} + +override void opcode84() +{ +addrZeropage(); +writeFinal(primaryAddress, yIndex); +} +override void opcode8C() +{ +addrAbsolute(); +writeFinal(primaryAddress, yIndex); +} +override void opcode94() +{ +addrZeropageX(); +writeFinal(primaryAddress, yIndex); +} + +override void opcode24() +{ +addrZeropage(); +bitTest(readVal = readFinal(primaryAddress)); +} +override void opcode2C() +{ +addrAbsolute(); +bitTest(readVal = readFinal(primaryAddress)); +} + +override void opcode06() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftLeft(readVal = read(primaryAddress)))); +} +override void opcode0E() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftLeft(readVal = read(primaryAddress)))); +} +override void opcode16() +{ +addrZeropageX(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftLeft(readVal = read(primaryAddress)))); +} +override void opcode1E() +{ +addrAbsoluteX(false); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftLeft(readVal = read(primaryAddress)))); +} + +override void opcode46() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftRight(readVal = read(primaryAddress)))); +} +override void opcode4E() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftRight(readVal = read(primaryAddress)))); +} +override void opcode56() +{ +addrZeropageX(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftRight(readVal = read(primaryAddress)))); +} +override void opcode5E() +{ +addrAbsoluteX(false); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = shiftRight(readVal = read(primaryAddress)))); +} + +override void opcode26() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateLeft(readVal = read(primaryAddress)))); +} +override void opcode2E() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateLeft(readVal = read(primaryAddress)))); +} +override void opcode36() +{ +addrZeropageX(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateLeft(readVal = read(primaryAddress)))); +} +override void opcode3E() +{ +addrAbsoluteX(false); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateLeft(readVal = read(primaryAddress)))); +} + +override void opcode66() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateRight(readVal = read(primaryAddress)))); +} +override void opcode6E() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateRight(readVal = read(primaryAddress)))); +} +override void opcode76() +{ +addrZeropageX(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateRight(readVal = read(primaryAddress)))); +} +override void opcode7E() +{ +addrAbsoluteX(false); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = rotateRight(readVal = read(primaryAddress)))); +} + +override void opcodeE6() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = increment(readVal = read(primaryAddress)))); +} +override void opcodeEE() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = increment(readVal = read(primaryAddress)))); +} +override void opcodeF6() +{ +addrZeropageX(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = increment(readVal = read(primaryAddress)))); +} + +override void opcodeC6() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = decrement(readVal = read(primaryAddress)))); +} +override void opcodeCE() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = decrement(readVal = read(primaryAddress)))); +} +override void opcodeD6() +{ +addrZeropageX(); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = decrement(readVal = read(primaryAddress)))); +} + +override void opcodeFE() +{ +addrAbsoluteX(true); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = increment(readVal = read(primaryAddress)))); +} + +override void opcodeDE() +{ +addrAbsoluteX(true); +peek(primaryAddress); +writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = decrement(readVal = read(primaryAddress)))); +} + +override void opcode34() +{ +addrZeropageX(); +bitTest(readVal = readFinal(primaryAddress)); +} +override void opcode3C() +{ +addrAbsoluteX(false); +bitTest(readVal = readFinal(primaryAddress)); +} + +override void opcode12() +{ +addrZeropageI(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} + +override void opcode32() +{ +addrZeropageI(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} + +override void opcode52() +{ +addrZeropageI(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} + +override void opcodeB2() +{ +addrZeropageI(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} + +override void opcodeD2() +{ +addrZeropageI(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} + +override void opcode72() +{ +addrZeropageI(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} + +override void opcodeF2() +{ +addrZeropageI(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} + +override void opcode92() +{ +addrZeropageI(); +writeFinal(primaryAddress, accumulator); +} + +override void opcode3A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator -= 1); +} + +override void opcode1A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator += 1); +} + +override void opcodeDA() +{ +peek(programCounter); +push(xIndex); +} + +override void opcode5A() +{ +peek(programCounter); +push(yIndex); +} + +override void opcodeFA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex = pull()); +} + +override void opcode7A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex = pull()); +} + +override void opcode80() +{ +readByteOperand(); +if (true) addrRelative(cast(byte)operand1); +} + +override void opcode14() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, testReset(readVal = read(primaryAddress))); +} +override void opcode1C() +{ +addrAbsolute; +peek(primaryAddress); +writeFinal(primaryAddress, testReset(readVal = read(primaryAddress))); +} + +override void opcode04() +{ +addrZeropage(); +peek(primaryAddress); +writeFinal(primaryAddress, testSet(readVal = read(primaryAddress))); +} +override void opcode0C() +{ +addrAbsolute(); +peek(primaryAddress); +writeFinal(primaryAddress, testSet(readVal = read(primaryAddress))); +} + +override void opcode64() +{ +addrZeropage(); +writeFinal(primaryAddress, 0); +} +override void opcode74() +{ +addrZeropageX(); +writeFinal(primaryAddress, 0); +} +override void opcode9C() +{ +addrAbsolute(); +writeFinal(primaryAddress, 0); +} +override void opcode9E() +{ +addrAbsoluteX(true); +writeFinal(primaryAddress, 0); +} + +override void opcode02() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcode22() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcode42() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcode62() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcode82() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcodeC2() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcodeE2() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} + +override void opcode44() +{ +addrZeropage(); +readVal = readFinal(primaryAddress); +} + +override void opcode54() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcodeD4() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcodeF4() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} + +override void opcodeDC() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} +override void opcodeFC() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} + +override void opcode03() +{ +addrNone(); +} +override void opcode13() +{ +addrNone(); +} +override void opcode23() +{ +addrNone(); +} +override void opcode33() +{ +addrNone(); +} +override void opcode43() +{ +addrNone(); +} +override void opcode53() +{ +addrNone(); +} +override void opcode63() +{ +addrNone(); +} +override void opcode73() +{ +addrNone(); +} +override void opcode83() +{ +addrNone(); +} +override void opcode93() +{ +addrNone(); +} +override void opcodeA3() +{ +addrNone(); +} +override void opcodeB3() +{ +addrNone(); +} +override void opcodeC3() +{ +addrNone(); +} +override void opcodeD3() +{ +addrNone(); +} +override void opcodeE3() +{ +addrNone(); +} +override void opcodeF3() +{ +addrNone(); +} +override void opcode07() +{ +addrNone(); +} +override void opcode17() +{ +addrNone(); +} +override void opcode27() +{ +addrNone(); +} +override void opcode37() +{ +addrNone(); +} +override void opcode47() +{ +addrNone(); +} +override void opcode57() +{ +addrNone(); +} +override void opcode67() +{ +addrNone(); +} +override void opcode77() +{ +addrNone(); +} +override void opcode87() +{ +addrNone(); +} +override void opcode97() +{ +addrNone(); +} +override void opcodeA7() +{ +addrNone(); +} +override void opcodeB7() +{ +addrNone(); +} +override void opcodeC7() +{ +addrNone(); +} +override void opcodeD7() +{ +addrNone(); +} +override void opcodeE7() +{ +addrNone(); +} +override void opcodeF7() +{ +addrNone(); +} +override void opcode0B() +{ +addrNone(); +} +override void opcode1B() +{ +addrNone(); +} +override void opcode2B() +{ +addrNone(); +} +override void opcode3B() +{ +addrNone(); +} +override void opcode4B() +{ +addrNone(); +} +override void opcode5B() +{ +addrNone(); +} +override void opcode6B() +{ +addrNone(); +} +override void opcode7B() +{ +addrNone(); +} +override void opcode8B() +{ +addrNone(); +} +override void opcode9B() +{ +addrNone(); +} +override void opcodeAB() +{ +addrNone(); +} +override void opcodeBB() +{ +addrNone(); +} +override void opcodeCB() +{ +addrNone(); +} +override void opcodeDB() +{ +addrNone(); +} +override void opcodeEB() +{ +addrNone(); +} +override void opcodeFB() +{ +addrNone(); +} +override void opcode0F() +{ +addrNone(); +} +override void opcode1F() +{ +addrNone(); +} +override void opcode2F() +{ +addrNone(); +} +override void opcode3F() +{ +addrNone(); +} +override void opcode4F() +{ +addrNone(); +} +override void opcode5F() +{ +addrNone(); +} +override void opcode6F() +{ +addrNone(); +} +override void opcode7F() +{ +addrNone(); +} +override void opcode8F() +{ +addrNone(); +} +override void opcode9F() +{ +addrNone(); +} +override void opcodeAF() +{ +addrNone(); +} +override void opcodeBF() +{ +addrNone(); +} +override void opcodeCF() +{ +addrNone(); +} +override void opcodeDF() +{ +addrNone(); +} +override void opcodeEF() +{ +addrNone(); +} +override void opcodeFF() +{ +addrNone(); +} + + /* BRK */ + final override void opcode00() + { + peek(programCounter); + ++programCounter; + doInterrupt(IRQ_VECTOR, flag.toByte()); + } + + /* JSR */ + final override void opcode20() + { + ushort finalAddress = (operand1 = read(programCounter++)); + + peek(STACK_BASE + stackPointer); + pushWord(programCounter); + + finalAddress |= ((operand2 = read(programCounter)) << 8); + static if (cumulative) tick(totalCycles); + programCounter = finalAddress; + } + + /* RTI */ + final override void opcode40() + { + peek(programCounter); + flag.fromByte(pull()); + programCounter = readStack() | (readStack() << 8); + static if (cumulative) tick(totalCycles); + } + + /* JMP $$$$ */ + final override void opcode4C() + { + programCounter = readWordOperand(); + static if (cumulative) tick(totalCycles); + } + + /* RTS */ + final override void opcode60() + { + peek(programCounter); + programCounter = pullWord(); + peek(programCounter); + static if (cumulative) tick(totalCycles); + ++programCounter; + } + + /* NOP8 */ + void opcode5C() + { + readByteOperand(); + peek(programCounter++); + peek(0xFF00 | operand1); + peek(0xFFFF); + peek(0xFFFF); + peek(0xFFFF); + peek(0xFFFF); + static if (cumulative) tick(totalCycles); + } + + /* JMP ($$$$) */ + override void opcode6C() + { + ushort vector = readWordOperand(); + peek(programCounter); + programCounter = readWord(vector, cast(ushort)(vector + 1)); + static if (cumulative) tick(totalCycles); + } + + /* JMP ($$$$,X) */ + void opcode7C() + { + baseAddress = readWordOperand(); + peek(programCounter); + ushort vector = cast(ushort)(baseAddress + xIndex); + programCounter = readWord(vector, cast(ushort)(vector + 1)); + static if (cumulative) tick(totalCycles); + } + + /* BIT #$$ */ + void opcode89() + { + readVal = operand1 = readFinal(programCounter++); + flag.zero_ = accumulator & readVal; + } diff --git a/nmos.txt b/nmos.txt new file mode 100644 index 0000000..d2fa3cc --- /dev/null +++ b/nmos.txt @@ -0,0 +1,1609 @@ +override void opcode18() +{ +peek(programCounter); +flag.carry = false; +} + +override void opcode38() +{ +peek(programCounter); +flag.carry = true; +} + +override void opcode58() +{ +peek(programCounter); +flag.interrupt = false; +} + +override void opcode78() +{ +peek(programCounter); +flag.interrupt = true; +} + +override void opcodeB8() +{ +peek(programCounter); +flag.overflow = false; +} + +override void opcodeD8() +{ +peek(programCounter); +flag.decimal = false; +} + +override void opcodeF8() +{ +peek(programCounter); +flag.decimal = true; +} + +override void opcodeEA() +{ +peek(programCounter); + +} + +override void opcode08() +{ +peek(programCounter); +push(flag.toByte()); +} + +override void opcode28() +{ +peek(programCounter); +flag.fromByte(pull()); +} + +override void opcode48() +{ +peek(programCounter); +push(accumulator); +} + +override void opcode9A() +{ +peek(programCounter); +stackPointer = xIndex; +} + +override void opcode68() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = pull()); +} + +override void opcodeBA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex = stackPointer); +} + +override void opcodeAA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex = accumulator); +} + +override void opcode8A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = xIndex); +} + +override void opcodeCA() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex -= 1); +} + +override void opcodeE8() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (xIndex += 1); +} + +override void opcodeA8() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex = accumulator); +} + +override void opcode98() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = yIndex); +} + +override void opcode88() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex -= 1); +} + +override void opcodeC8() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (yIndex += 1); +} + +override void opcode10() +{ +readByteOperand(); +if (flag.negative_ < 0x80) addrRelative(cast(byte)operand1); +} + +override void opcode30() +{ +readByteOperand(); +if (flag.negative_ > 0x7F) addrRelative(cast(byte)operand1); +} + +override void opcode50() +{ +readByteOperand(); +if (!flag.overflow) addrRelative(cast(byte)operand1); +} + +override void opcode70() +{ +readByteOperand(); +if (flag.overflow) addrRelative(cast(byte)operand1); +} + +override void opcode90() +{ +readByteOperand(); +if (!flag.carry) addrRelative(cast(byte)operand1); +} + +override void opcodeB0() +{ +readByteOperand(); +if (flag.carry) addrRelative(cast(byte)operand1); +} + +override void opcodeD0() +{ +readByteOperand(); +if (flag.zero_ != 0) addrRelative(cast(byte)operand1); +} + +override void opcodeF0() +{ +readByteOperand(); +if (flag.zero_ == 0) addrRelative(cast(byte)operand1); +} + +override void opcode0A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = shiftLeft(accumulator)); +} + +override void opcode2A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = rotateLeft(accumulator)); +} + +override void opcode4A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = shiftRight(accumulator)); +} + +override void opcode6A() +{ +peek(programCounter); +flag.zero_ = flag.negative_ = (accumulator = rotateRight(accumulator)); +} + +override void opcodeA1() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeA5() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeA9() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcodeAD() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeB1() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeB5() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeB9() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} +override void opcodeBD() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator = (readVal = readFinal(primaryAddress))); +} + +override void opcode01() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode05() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode09() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcode0D() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode11() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode15() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode19() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} +override void opcode1D() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator |= (readVal = readFinal(primaryAddress))); +} + +override void opcode21() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode25() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode29() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcode2D() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode31() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode35() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode39() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} +override void opcode3D() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator &= (readVal = readFinal(primaryAddress))); +} + +override void opcode41() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode45() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode49() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcode4D() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode51() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode55() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode59() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} +override void opcode5D() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (accumulator ^= (readVal = readFinal(primaryAddress))); +} + +override void opcode61() +{ +addrIndirectX(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode65() +{ +addrZeropage(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode69() +{ +primaryAddress = programCounter++; +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +operand1 = readVal; +} +override void opcode6D() +{ +addrAbsolute(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode71() +{ +addrIndirectY(false); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode75() +{ +addrZeropageX(); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode79() +{ +addrAbsoluteY(false); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcode7D() +{ +addrAbsoluteX(false); +if (flag.decimal) dec_addWithCarry(readVal = readFinal(primaryAddress)); +else hex_addWithCarry(readVal = readFinal(primaryAddress)); +} + +override void opcodeE1() +{ +addrIndirectX(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeE5() +{ +addrZeropage(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeE9() +{ +primaryAddress = programCounter++; +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +operand1 = readVal; +} +override void opcodeED() +{ +addrAbsolute(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeF1() +{ +addrIndirectY(false); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeF5() +{ +addrZeropageX(); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeF9() +{ +addrAbsoluteY(false); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} +override void opcodeFD() +{ +addrAbsoluteX(false); +if (flag.decimal) dec_subWithCarry(readVal = readFinal(primaryAddress)); +else hex_subWithCarry(readVal = readFinal(primaryAddress)); +} + +override void opcodeC1() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeC5() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeC9() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +operand1 = readVal; +} +override void opcodeCD() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeD1() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeD5() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeD9() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} +override void opcodeDD() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (compare(accumulator, (readVal = readFinal(primaryAddress)))); +} + +override void opcode81() +{ +addrIndirectX(); +writeFinal(primaryAddress, accumulator); +} +override void opcode85() +{ +addrZeropage(); +writeFinal(primaryAddress, accumulator); +} +override void opcode8D() +{ +addrAbsolute(); +writeFinal(primaryAddress, accumulator); +} +override void opcode91() +{ +addrIndirectY(true); +writeFinal(primaryAddress, accumulator); +} +override void opcode95() +{ +addrZeropageX(); +writeFinal(primaryAddress, accumulator); +} +override void opcode99() +{ +addrAbsoluteY(true); +writeFinal(primaryAddress, accumulator); +} +override void opcode9D() +{ +addrAbsoluteX(true); +writeFinal(primaryAddress, accumulator); +} + +override void opcodeA2() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcodeA6() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeAE() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeB6() +{ +addrZeropageY(); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeBE() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (xIndex = (readVal = readFinal(primaryAddress))); +} + +override void opcodeA0() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +operand1 = readVal; +} +override void opcodeA4() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeAC() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeB4() +{ +addrZeropageX(); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeBC() +{ +addrAbsoluteX(false); +flag.zero_ = flag.negative_ = (yIndex = (readVal = readFinal(primaryAddress))); +} + +override void opcodeE0() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (compare(xIndex, (readVal = readFinal(primaryAddress)))); +operand1 = readVal; +} +override void opcodeE4() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (compare(xIndex, (readVal = readFinal(primaryAddress)))); +} +override void opcodeEC() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (compare(xIndex, (readVal = readFinal(primaryAddress)))); +} + +override void opcodeC0() +{ +primaryAddress = programCounter++; +flag.zero_ = flag.negative_ = (compare(yIndex, (readVal = readFinal(primaryAddress)))); +operand1 = readVal; +} +override void opcodeC4() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (compare(yIndex, (readVal = readFinal(primaryAddress)))); +} +override void opcodeCC() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (compare(yIndex, (readVal = readFinal(primaryAddress)))); +} + +override void opcode86() +{ +addrZeropage(); +writeFinal(primaryAddress, xIndex); +} +override void opcode8E() +{ +addrAbsolute(); +writeFinal(primaryAddress, xIndex); +} +override void opcode96() +{ +addrZeropageY(); +writeFinal(primaryAddress, xIndex); +} + +override void opcode84() +{ +addrZeropage(); +writeFinal(primaryAddress, yIndex); +} +override void opcode8C() +{ +addrAbsolute(); +writeFinal(primaryAddress, yIndex); +} +override void opcode94() +{ +addrZeropageX(); +writeFinal(primaryAddress, yIndex); +} + +override void opcode24() +{ +addrZeropage(); +bitTest(readVal = readFinal(primaryAddress)); +} +override void opcode2C() +{ +addrAbsolute(); +bitTest(readVal = readFinal(primaryAddress)); +} + +override void opcode06() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftLeft(readVal)); +} +override void opcode0E() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftLeft(readVal)); +} +override void opcode16() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftLeft(readVal)); +} +override void opcode1E() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftLeft(readVal)); +} + +override void opcode46() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftRight(readVal)); +} +override void opcode4E() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftRight(readVal)); +} +override void opcode56() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftRight(readVal)); +} +override void opcode5E() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = shiftRight(readVal)); +} + +override void opcode26() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateLeft(readVal)); +} +override void opcode2E() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateLeft(readVal)); +} +override void opcode36() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateLeft(readVal)); +} +override void opcode3E() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateLeft(readVal)); +} + +override void opcode66() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateRight(readVal)); +} +override void opcode6E() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateRight(readVal)); +} +override void opcode76() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateRight(readVal)); +} +override void opcode7E() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = rotateRight(readVal)); +} + +override void opcodeE6() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = increment(readVal)); +} +override void opcodeEE() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = increment(readVal)); +} +override void opcodeF6() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = increment(readVal)); +} +override void opcodeFE() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = increment(readVal)); +} + +override void opcodeC6() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = decrement(readVal)); +} +override void opcodeCE() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = decrement(readVal)); +} +override void opcodeD6() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = decrement(readVal)); +} +override void opcodeDE() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = decrement(readVal)); +} + +override void opcode02() +{ +addrHalt(); + +} +override void opcode12() +{ +addrHalt(); + +} +override void opcode22() +{ +addrHalt(); + +} +override void opcode32() +{ +addrHalt(); + +} +override void opcode42() +{ +addrHalt(); + +} +override void opcode52() +{ +addrHalt(); + +} +override void opcode62() +{ +addrHalt(); + +} +override void opcode72() +{ +addrHalt(); + +} +override void opcode92() +{ +addrHalt(); + +} +override void opcodeB2() +{ +addrHalt(); + +} +override void opcodeD2() +{ +addrHalt(); + +} +override void opcodeF2() +{ +addrHalt(); + +} + +override void opcode1A() +{ +addrImplied(); +} +override void opcode3A() +{ +addrImplied(); +} +override void opcode5A() +{ +addrImplied(); +} +override void opcode7A() +{ +addrImplied(); +} +override void opcodeDA() +{ +addrImplied(); +} +override void opcodeFA() +{ +addrImplied(); +} + +override void opcode0C() +{ +addrAbsolute(); +readVal = readFinal(primaryAddress); +} + +override void opcode1C() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} +override void opcode3C() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} +override void opcode5C() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} +override void opcode7C() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} +override void opcodeDC() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} +override void opcodeFC() +{ +addrAbsoluteX(false); +readVal = readFinal(primaryAddress); +} + +override void opcode80() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcode82() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcode89() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcodeC2() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} +override void opcodeE2() +{ +primaryAddress = programCounter++; +readVal = readFinal(primaryAddress); +operand1 = readVal; +} + +override void opcode04() +{ +addrZeropage(); +readVal = readFinal(primaryAddress); +} +override void opcode44() +{ +addrZeropage(); +readVal = readFinal(primaryAddress); +} +override void opcode64() +{ +addrZeropage(); +readVal = readFinal(primaryAddress); +} + +override void opcode14() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcode34() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcode54() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcode74() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcodeD4() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} +override void opcodeF4() +{ +addrZeropageX(); +readVal = readFinal(primaryAddress); +} + +override void opcodeA3() +{ +addrIndirectX(); +flag.zero_ = flag.negative_ = (accumulator = xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeA7() +{ +addrZeropage(); +flag.zero_ = flag.negative_ = (accumulator = xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeAF() +{ +addrAbsolute(); +flag.zero_ = flag.negative_ = (accumulator = xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeB3() +{ +addrIndirectY(false); +flag.zero_ = flag.negative_ = (accumulator = xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeB7() +{ +addrZeropageY(); +flag.zero_ = flag.negative_ = (accumulator = xIndex = (readVal = readFinal(primaryAddress))); +} +override void opcodeBF() +{ +addrAbsoluteY(false); +flag.zero_ = flag.negative_ = (accumulator = xIndex = (readVal = readFinal(primaryAddress))); +} + +override void opcode83() +{ +addrIndirectX(); +writeFinal(primaryAddress, accumulator & xIndex); +} +override void opcode87() +{ +addrZeropage(); +writeFinal(primaryAddress, accumulator & xIndex); +} +override void opcode97() +{ +addrZeropageY(); +writeFinal(primaryAddress, accumulator & xIndex); +} +override void opcode8F() +{ +addrAbsolute(); +writeFinal(primaryAddress, accumulator & xIndex); +} + +override void opcode03() +{ +addrIndirectX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} +override void opcode07() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} +override void opcode0F() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} +override void opcode13() +{ +addrIndirectY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} +override void opcode17() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} +override void opcode1B() +{ +addrAbsoluteY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} +override void opcode1F() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftLeft(readVal))); +accumulator |= writeVal; +} + +override void opcode23() +{ +addrIndirectX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} +override void opcode27() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} +override void opcode2F() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} +override void opcode33() +{ +addrIndirectY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} +override void opcode37() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} +override void opcode3B() +{ +addrAbsoluteY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} +override void opcode3F() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateLeft(readVal))); +accumulator &= writeVal; +} + +override void opcode43() +{ +addrIndirectX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} +override void opcode47() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} +override void opcode4F() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} +override void opcode53() +{ +addrIndirectY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} +override void opcode57() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} +override void opcode5B() +{ +addrAbsoluteY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} +override void opcode5F() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = shiftRight(readVal))); +accumulator ^= writeVal; +} + +override void opcodeC3() +{ +addrIndirectX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} +override void opcodeC7() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} +override void opcodeCF() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} +override void opcodeD3() +{ +addrIndirectY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} +override void opcodeD7() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} +override void opcodeDB() +{ +addrAbsoluteY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} +override void opcodeDF() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, (writeVal = decrement(readVal))); +flag.zero_ = flag.negative_ = compare(accumulator, writeVal); +} + +override void opcode63() +{ +addrIndirectX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} +override void opcode67() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} +override void opcode6F() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} +override void opcode73() +{ +addrIndirectY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} +override void opcode77() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} +override void opcode7B() +{ +addrAbsoluteY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} +override void opcode7F() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = rotateRight(readVal))); +if (flag.decimal) dec_addWithCarry(writeVal); +else hex_addWithCarry(writeVal); +} + +override void opcodeE3() +{ +addrIndirectX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} +override void opcodeE7() +{ +addrZeropage(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} +override void opcodeEF() +{ +addrAbsolute(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} +override void opcodeF3() +{ +addrIndirectY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} +override void opcodeF7() +{ +addrZeropageX(); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} +override void opcodeFB() +{ +addrAbsoluteY(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} +override void opcodeFF() +{ +addrAbsoluteX(true); +poke(primaryAddress, (readVal = read(primaryAddress))); +writeFinal(primaryAddress, flag.zero_ = flag.negative_ = (writeVal = increment(readVal))); +if (flag.decimal) dec_subWithCarry(writeVal); +else hex_subWithCarry(writeVal); +} + + /* BRK */ + final override void opcode00() + { + peek(programCounter); + ++programCounter; + doInterrupt(IRQ_VECTOR, flag.toByte()); + } + + /* JSR */ + final override void opcode20() + { + ushort finalAddress = (operand1 = read(programCounter++)); + + peek(STACK_BASE + stackPointer); + pushWord(programCounter); + + finalAddress |= ((operand2 = read(programCounter)) << 8); + static if (cumulative) tick(totalCycles); + programCounter = finalAddress; + } + + /* RTI */ + final override void opcode40() + { + peek(programCounter); + flag.fromByte(pull()); + programCounter = readStack() | (readStack() << 8); + static if (cumulative) tick(totalCycles); + } + + /* JMP $$$$ */ + final override void opcode4C() + { + programCounter = readWordOperand(); + static if (cumulative) tick(totalCycles); + } + + /* RTS */ + final override void opcode60() + { + peek(programCounter); + programCounter = pullWord(); + peek(programCounter); + static if (cumulative) tick(totalCycles); + ++programCounter; + } + + /* JMP ($$$$) */ + override void opcode6C() + { + ushort vector = readWordOperand(); + programCounter = readWord(vector, + (vector & 0xFF00) | cast(ubyte)(vector + 1)); + static if (cumulative) tick(totalCycles); + } + /* ANC #$$ */ + override void opcode0B() + { + readVal = operand1 = readFinal(programCounter); + flag.zero_ = flag.negative_ = (accumulator = readVal); + flag.carry = (flag.negative_ > 0x7F); + } + + /* ANC #$$ */ + override void opcode2B() + { + readVal = operand1 = readFinal(programCounter); + flag.zero_ = flag.negative_ = (accumulator = readVal); + flag.carry = (flag.negative_ > 0x7F); + } + + /* ALR #$$ */ + override void opcode4B() + { + readVal = operand1 = readFinal(programCounter); + flag.zero_ = flag.negative_ = + (accumulator = shiftRight(accumulator & readVal)); + } + + /* ARR #$$ */ + override void opcode6B() + { + readVal = operand1 = readFinal(programCounter); + ubyte val = readVal & accumulator; + if (flag.decimal) { + ubyte temp = cast(ubyte)((val >> 1) + (flag.carry ? 0x80 : 0)); + flag.zero_ = flag.negative_ = temp; + flag.overflow = (((temp ^ val) & 0x40) != 0); + if ((readVal & 0x0F) + (val & 0x01) > 5) + temp = (temp & 0xF0) + ((temp + 0x6) & 0x0F); + if (val + (val & 0x10) >= 0x60) + { + temp += 0x60; + flag.carry = true; + } + else + flag.carry = false; + accumulator = temp; + } + else { + accumulator = cast(ubyte)((val >> 1) + (flag.carry ? 0x80 : 0)); + flag.zero_ = flag.negative_ = accumulator; + val >>= 7; + flag.carry = (val != 0); + flag.overflow = ((val ^ ((accumulator >> 5) & 1)) != 0); + } + } + + /* ANE #$$ */ + override void opcode8B() + { + // unstable + readVal = operand1 = readFinal(programCounter++); + + version(Atari8Bit) + { + flag.zero_ = flag.negative_ = + (accumulator & xIndex & readVal); + accumulator &= xIndex & (operand1 | 0xEF); + } + else + { + flag.zero_ = flag.negative_ = + (accumulator &= (xIndex & readVal)); + } + } + + /* SHA ($$),Y */ + void opcode93() + { + addrIndirectY(true); + strange(accumulator & xIndex); + } + + /* SHA $$$$,Y */ + void opcode9F() + { + addrAbsoluteY(true); + strange(accumulator & xIndex); + } + + /* SHS $$$$,Y */ + void opcode9B() + { + addrAbsoluteY(true); + strange(stackPointer = (accumulator & xIndex)); + } + + /* SHY $$$$,X */ + void opcode9C() + { + addrAbsoluteX(true); + strange(yIndex); + } + + /* SHX $$$$,Y */ + void opcode9E() + { + addrAbsoluteY(true); + strange(xIndex); + } + + /* LAX #$$ */ + override void opcodeAB() + { + readVal = operand1 = readFinal(programCounter); + + version(Commodore128) + { + // not unstable? + flag.zero_ = flag.negative_ = + (accumulator = readVal); + } + else + { + // unstable + version(Commodore64) + { + accumulator |= 0xEE; + } + flag.zero_ = flag.negative_ = + (accumulator &= readVal); + } + xIndex = accumulator; + } + + /* LAS $$$$,Y */ + override void opcodeBB() + { + addrAbsoluteY(false); + readVal = readFinal(primaryAddress); + + flag.zero_ = flag.negative_ = + (xIndex = accumulator = (stackPointer & readVal)); + } + + /* SBX #$$ */ + override void opcodeCB() + { + readVal = operand1 = readFinal(programCounter++); + xIndex &= accumulator; + flag.zero_ = flag.negative_ = compare(xIndex, readVal); + } + + /* SBC #$$ */ + override void opcodeEB() + { + readVal = operand1 = readFinal(programCounter++); + if (flag.decimal) dec_subWithCarry(readVal); + else hex_subWithCarry(readVal); + }