public Opcode(string Mnemonic, int ByteValue, int NumOperands, AddressingType Addressing) { this.Mnemonic = Mnemonic; this.ByteValue = ByteValue; this.NumOperands = NumOperands; this.Addressing = Addressing; }
public override int Execute(C6502 cpu, byte operand) { var state = cpu.State as ExecutionState; int result = operand << 1; result |= (cpu.State.ProcessorStatus & (byte)StatusFlags.Carry); SetCarry(cpu, () => (result & 0x100) != 0); result &= 0xFF; SetNegative(cpu, () => Helper.IsSigned((byte)result)); SetZero(cpu, () => result == 0); // Hacky but it will do the trick. Accumulator Addressing is an outcast. if (AddressingType is AccumulatorAddressing) { cpu.State.RegA = (byte)result; } else { cpu.Memory[AddressingType.GetAddress(cpu, state.Parameter)] = (byte)result; } return(2); }
public override int Execute(C6502 cpu, byte operand) { var state = cpu.State as ExecutionState; cpu.State.ProgramCounter = AddressingType.GetAddress(cpu, state.Parameter); return(3); }
public override int Execute(C6502 cpu, byte operand) { var state = cpu.State as ExecutionState; int v = operand; if (cpu.State.IsFlagSet((byte)StatusFlags.Carry)) { v |= 0x100; } SetCarry(cpu, () => (v & 0x01) != 0); v >>= 1; v &= 0xFF; SetNegative(cpu, () => Helper.IsSigned((byte)v)); SetZero(cpu, () => v == 0); // Hacky but it will do the trick. Accumulator Addressing is an outcast. if (AddressingType is AccumulatorAddressing) { cpu.State.RegA = (byte)v; } else { cpu.Memory[AddressingType.GetAddress(cpu, state.Parameter)] = (byte)v; } return(2); }
public Opcode(string Mnemonic, int ByteValue, int NumOperands, AddressingType Addressing, int NumCycles, int PageBoundaryCycles) { this.Mnemonic = Mnemonic; this.ByteValue = ByteValue; this.NumOperands = NumOperands; this.Addressing = Addressing; this.NumCycles = NumCycles; this.PageBoundaryCycles = PageBoundaryCycles; NumPenaltyCycles = PageBoundaryCycles; }
public override int Execute(C6502 cpu, byte operand) { var state = cpu.State as ExecutionState; byte value = (byte)(operand + 1); cpu.Memory[AddressingType.GetAddress(cpu, state.Parameter)] = value; SetNegative(cpu, () => Helper.IsSigned(value)); SetZero(cpu, () => value == 0); return(2); }
public Opcode(string Mnemonic, int ByteValue, int NumOperands, AddressingType Addressing, int NumCycles, int PageBoundaryCycles, int BranchSamePagePenalty, int BranchOtherPagePenalty) { this.Mnemonic = Mnemonic; this.ByteValue = ByteValue; this.NumOperands = NumOperands; this.Addressing = Addressing; this.NumCycles = NumCycles; this.PageBoundaryCycles = PageBoundaryCycles; this.BranchOtherPagePenalty = BranchOtherPagePenalty; this.BranchSamePagePenalty = BranchSamePagePenalty; NumPenaltyCycles = PageBoundaryCycles + BranchOtherPagePenalty + BranchSamePagePenalty; }
public override int Execute(C6502 cpu, byte operand) { var state = cpu.State as ExecutionState; ushort toPush = (ushort)(cpu.State.ProgramCounter - 1); // TODO: check if this is the correct order. I guess so (DS) cpu.Push((byte)((toPush >> 8) & 0xFF)); cpu.Push((byte)(toPush & 0xFF)); cpu.State.ProgramCounter = AddressingType.GetAddress(cpu, state.Parameter); return(6); }
public override int Execute(C6502 cpu, byte operand) { ExecutionState state = cpu.State as ExecutionState; if (state == null) { throw new Exception("Something BAAAADD happened"); } cpu.Memory[AddressingType.GetAddress(cpu, state.Parameter)] = state.RegX; // I don't know what the f**k this is but it is 2 everywhere (DS). return(2); }
public override int Execute(C6502 cpu, byte operand) { var state = cpu.State as ExecutionState; SetCarry(cpu, () => (operand & 0x01) != 0); int result = operand >> 1; result &= 0xFF; // Negative is always set in this opcode SetNegative(cpu, () => true); SetZero(cpu, () => result == 0); // Hacky but it will do the trick. Accumulator Addressing is an outcast. if (AddressingType is AccumulatorAddressing) { cpu.State.RegA = (byte)result; } else { cpu.Memory[AddressingType.GetAddress(cpu, state.Parameter)] = (byte)result; } return(2); }