protected int Tas(int opcode) { lock (lockObject) { int mode = (opcode >> 3) & 0x07; int reg = (opcode & 0x07); IOperand op = cpu.ResolveSrcEA(mode, reg, Size.Byte); int v = op.GetByte(); if (v == 0) { cpu.SetFlags(cpu.ZFlag); } else { cpu.ClrFlags(cpu.ZFlag); } if ((v & 0x080) != 0) { cpu.SetFlags(cpu.NFlag); } else { cpu.ClrFlags(cpu.NFlag); } cpu.ClrFlags(cpu.CFlag | cpu.VFlag); if (!EmulateBrokenTAS) { op.SetByte(v | 0x80); } return(op.IsRegisterMode() ? 4 : 14 + op.GetTiming()); } }
protected int TstByte(int opcode) { int mode = (opcode >> 3) & 0x07; int reg = (opcode & 0x07); IOperand op = cpu.ResolveSrcEA(mode, reg, Size.Byte); int v = op.GetByte(); if (v == 0) { cpu.SetFlags(cpu.ZFlag); } else { cpu.ClrFlags(cpu.ZFlag); } if ((v & 0x080) != 0) { cpu.SetFlags(cpu.NFlag); } else { cpu.ClrFlags(cpu.NFlag); } cpu.ClrFlags(cpu.CFlag | cpu.VFlag); return(4 + op.GetTiming()); }
protected int NotByte(int opcode) { IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte); int s = op.GetByte(); int r = (~s) & 0xFF; op.SetByte(r); cpu.CalcFlags(InstructionType.NOT, s, 0, r, Size.Byte); return(op.IsRegisterMode() ? 4 : 8 + op.GetTiming()); }
protected int NegxByte(int opcode) { IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte); int s = op.GetByte(); int r = (0 - (s + (cpu.IsFlagSet(cpu.XFlag) ? 1 : 0))); op.SetByte(r); cpu.CalcFlags(InstructionType.NEGX, s, 0, r, Size.Byte); return(op.IsRegisterMode() ? 4 : 8 + op.GetTiming()); }
protected int CmpByte(int opcode) { IOperand op = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte); int s = op.GetByte(); int d = cpu.GetDataRegisterByte((opcode >> 9) & 0x07); int r = d - s; cpu.CalcFlags(InstructionType.CMP, s, d, r, Size.Byte); return(4 + op.GetTiming()); }
protected int MoveByte(int opcode) { IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Byte); IOperand dst = cpu.ResolveDstEA((opcode >> 6) & 0x07, (opcode >> 9) & 0x07, Size.Byte); int s = src.GetByte(); dst.SetByte(s); cpu.CalcFlags(InstructionType.MOVE, s, s, s, Size.Byte); return(ShortExecutionTime[src.Index()][dst.Index()]); }
protected int EorByte(int opcode) { int s = cpu.GetDataRegisterByte((opcode >> 9) & 0x07); IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Byte); int d = dst.GetByte(); int r = s ^ d; dst.SetByte(r); cpu.CalcFlags(InstructionType.EOR, s, d, r, Size.Byte); return(dst.IsRegisterMode() ? 4 : 8 + dst.GetTiming()); }
protected int ClrByte(int opcode) { IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte); op.GetByte(); op.SetByte(0); int flags = cpu.GetCCRegister(); flags &= ~(cpu.NFlag | cpu.CFlag | cpu.VFlag); flags |= cpu.ZFlag; cpu.SetCCRegister(flags); return(op.IsRegisterMode() ? 4 : 8 + op.GetTiming()); }
protected int Nbcd(int opcode) { int mode = (opcode >> 3) & 0x07; int reg = (opcode & 0x07); IOperand op = cpu.ResolveDstEA(mode, reg, Size.Byte); int s = op.GetByte(); int x = (cpu.IsFlagSet(cpu.XFlag) ? 1 : 0); int c; int lo = 10 - (s & 0x0f) - x; if (lo < 10) { c = 1; } else { lo = 0; c = 0; } int hi = 10 - ((s >> 4) & 0x0f) - c; if (hi < 10) { c = 1; } else { c = 0; hi = 0; } int result = (hi << 4) + lo; if (c != 0) { cpu.SetFlags(cpu.XFlag | cpu.CFlag); } else { cpu.ClrFlags(cpu.XFlag | cpu.CFlag); } if (result != 0) { cpu.ClrFlags(cpu.ZFlag); } op.SetByte(result); return(op.IsRegisterMode() ? 6 : 8); }
protected int EoriByte(int opcode) { int s = cpu.FetchPCWord() & 0x00ff; IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Byte); int d = dst.GetByte(); int r = s ^ d; dst.SetByte(r); if (!dst.IsSR()) { cpu.CalcFlags(InstructionType.EOR, s, d, r, Size.Byte); } return(dst.IsRegisterMode() ? 8 : 12 + dst.GetTiming()); }
protected int BtstDynByte(int opcode) { var bit = cpu.GetDataRegisterLong((opcode >> 9) & 0x07) & 7; bit = 1 << bit; IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte); int val = op.GetByte(); if ((val & bit) != 0) { cpu.ClrFlags(cpu.ZFlag); } else { cpu.SetFlags(cpu.ZFlag); } return(4 + op.GetTiming()); }
protected int BtstStaticByte(int opcode) { var bit = cpu.FetchPCWord() & 0x07; bit = 1 << bit; IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte); int val = op.GetByte(); if ((val & bit) != 0) { cpu.ClrFlags(cpu.ZFlag); } else { cpu.SetFlags(cpu.ZFlag); } return(8 + op.GetTiming()); }