示例#1
0
        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());
            }
        }
示例#2
0
        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());
        }
示例#3
0
        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());
        }
示例#4
0
        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()]);
        }
示例#5
0
        protected int Sxx(int opcode)
        {
            IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte);
            int      cc = (opcode >> 8) & 0x0f;
            int      time;

            if (cpu.TestCC(cc))
            {
                op.SetByte(0xff);
                time = (op.IsRegisterMode() ? 6 : 8 + op.GetTiming());
            }
            else
            {
                op.SetByte(0);
                time = (op.IsRegisterMode() ? 4 : 8 + op.GetTiming());
            }

            return(time);
        }
示例#6
0
        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());
        }
示例#7
0
        protected int SubiByte(int opcode)
        {
            int      s   = CpuUtils.SignExtendByte(cpu.FetchPCWord());
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Byte);
            int      d   = dst.GetByteSigned();
            int      r   = d - s;

            dst.SetByte(r);
            cpu.CalcFlags(InstructionType.SUB, s, d, r, Size.Byte);
            return(dst.IsRegisterMode() ? 8 : 12 + dst.GetTiming());
        }
示例#8
0
        protected int SubByteEaDest(int opcode)
        {
            int      s   = cpu.GetDataRegisterByteSigned((opcode >> 9) & 0x07);
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Byte);
            int      d   = dst.GetByteSigned();
            int      r   = d - s;

            dst.SetByte(r);
            int time = 8 + dst.GetTiming();

            cpu.CalcFlags(InstructionType.SUB, s, d, r, Size.Byte);
            return(time);
        }
示例#9
0
        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());
        }
示例#10
0
        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);
        }
示例#11
0
        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());
        }
示例#12
0
        protected int SubqByte(int opcode)
        {
            int s = (opcode >> 9 & 0x07);

            if (s == 0)
            {
                s = 8;
            }
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte);
            int      d   = dst.GetByteSigned();
            int      r   = d - s;

            dst.SetByte(r);
            cpu.CalcFlags(InstructionType.SUB, s, d, r, Size.Byte);
            return(dst.IsRegisterMode() ? 4 : 8 + dst.GetTiming());
        }
示例#13
0
        protected int BsetDynByte(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);
            }

            val |= (bit);
            op.SetByte(val);
            return(8 + op.GetTiming());
        }
示例#14
0
        protected int BsetStaticByte(int opcode)
        {
            var bit = cpu.FetchPCWord() & 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);
            }

            val |= (bit);
            op.SetByte(val);
            return(12 + op.GetTiming());
        }