示例#1
0
        protected int RoxlWordMem(int opcode)
        {
            IOperand op       = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      v        = op.GetWord();
            int      last_out = v & 0x8000;

            v <<= 1;
            if (cpu.IsFlagSet(cpu.XFlag))
            {
                v |= 0x01;
            }
            op.SetWord(v);
            int maskFlags;

            if (last_out != 0)
            {
                maskFlags = cpu.XFlag + cpu.CFlag;
            }
            else
            {
                maskFlags = 0;
            }
            if ((v & 0xffff) == 0)
            {
                maskFlags += cpu.ZFlag;
            }
            if ((v & 0x8000) != 0)
            {
                maskFlags += cpu.NFlag;
            }
            cpu.SetCCRegister(maskFlags);
            return(8 + op.GetTiming());
        }
示例#2
0
        protected int TstWord(int opcode)
        {
            int      mode = (opcode >> 3) & 0x07;
            int      reg  = (opcode & 0x07);
            IOperand op   = cpu.ResolveSrcEA(mode, reg, Size.Word);
            int      v    = op.GetWord();

            if (v == 0)
            {
                cpu.SetFlags(cpu.ZFlag);
            }
            else
            {
                cpu.ClrFlags(cpu.ZFlag);
            }

            if ((v & 0x8000) != 0)
            {
                cpu.SetFlags(cpu.NFlag);
            }
            else
            {
                cpu.ClrFlags(cpu.NFlag);
            }

            cpu.ClrFlags(cpu.CFlag | cpu.VFlag);
            return(4 + op.GetTiming());
        }
示例#3
0
        protected int EoriWord(int opcode)
        {
            int      s   = cpu.FetchPCWord();
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      d   = dst.GetWord();
            int      r   = s ^ d;

            if (dst.IsSR())
            {
                if (cpu.IsSupervisorMode())
                {
                    cpu.SetSR(r);
                }
                else
                {
                    cpu.RaiseSRException();
                    return(34);
                }
            }
            else
            {
                dst.SetWord(r);
                cpu.CalcFlags(InstructionType.EOR, s, d, r, Size.Word);
            }

            return(dst.IsRegisterMode() ? 8 : 12 + dst.GetTiming());
        }
示例#4
0
        protected int Chk(int opcode)
        {
            int      reg            = (opcode >> 9) & 0x07;
            int      dval           = cpu.GetDataRegisterWordSigned(reg);
            IOperand op             = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      sval           = op.GetWord();
            bool     raiseException = false;

            if (dval < 0)
            {
                cpu.SetFlags(cpu.NFlag);
                raiseException = true;
            }
            else if (dval > sval)
            {
                cpu.ClrFlags(cpu.NFlag);
                raiseException = true;
            }

            if (raiseException)
            {
                cpu.RaiseException(6);
                return(40 + op.GetTiming());
            }

            return(10 + op.GetTiming());
        }
示例#5
0
        protected int DoMoveToCcr(int opcode)
        {
            IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      s   = src.GetWord() & 31;

            cpu.SetCCRegister(s);
            return(12 + src.GetTiming());
        }
示例#6
0
        protected int DoMoveFromSr(int opcode)
        {
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);

            dst.GetWord();
            dst.SetWord(cpu.GetSR());
            return(dst.IsRegisterMode() ? 6 : 8 + dst.GetTiming());
        }
示例#7
0
        protected int MoveWord(int opcode)
        {
            IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            IOperand dst = cpu.ResolveDstEA((opcode >> 6) & 0x07, (opcode >> 9) & 0x07, Size.Word);
            int      s   = src.GetWord();

            dst.SetWord(s);
            cpu.CalcFlags(InstructionType.MOVE, s, s, s, Size.Word);
            return(ShortExecutionTime[src.Index()][dst.Index()]);
        }
示例#8
0
        protected int NotWord(int opcode)
        {
            IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s  = op.GetWord();
            int      r  = (~s) & 0xffff;

            op.SetWord(r);
            cpu.CalcFlags(InstructionType.NOT, s, 0, r, Size.Word);
            return(op.IsRegisterMode() ? 4 : 8 + op.GetTiming());
        }
示例#9
0
        protected int CmpWord(int opcode)
        {
            IOperand op = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s  = op.GetWord();
            int      d  = cpu.GetDataRegisterWord((opcode >> 9) & 0x07);
            int      r  = d - s;

            cpu.CalcFlags(InstructionType.CMP, s, d, r, Size.Word);
            return(4 + op.GetTiming());
        }
示例#10
0
        protected int NegxWord(int opcode)
        {
            IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s  = op.GetWord();
            int      r  = (0 - (s + (cpu.IsFlagSet(cpu.XFlag) ? 1 : 0)));

            op.SetWord(r);
            cpu.CalcFlags(InstructionType.NEGX, s, 0, r, Size.Word);
            return(op.IsRegisterMode() ? 4 : 8 + op.GetTiming());
        }
示例#11
0
        protected int EorWord(int opcode)
        {
            int      s   = cpu.GetDataRegisterWord((opcode >> 9) & 0x07);
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      d   = dst.GetWord();
            int      r   = s ^ d;

            dst.SetWord(r);
            cpu.CalcFlags(InstructionType.EOR, s, d, r, Size.Word);
            return(dst.IsRegisterMode() ? 4 : 8 + dst.GetTiming());
        }
示例#12
0
        protected int LslWordMem(int opcode)
        {
            IOperand op       = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      v        = op.GetWord();
            int      last_out = v & 0x8000;

            v <<= 1;
            op.SetWord(v);
            cpu.CalcFlags(InstructionType.LSL, 1, last_out, v, Size.Word);
            return(8 + op.GetTiming());
        }
示例#13
0
        protected int Divu(int opcode)
        {
            IOperand op  = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s   = op.GetWord();
            int      reg = (opcode >> 9) & 0x07;
            int      d   = cpu.GetDataRegisterLong(reg);
            int      time;

            if (s == 0)
            {
                cpu.RaiseException(5);
                time = 38 + op.GetTiming();
            }
            else
            {
                long dl   = d & 4294967295L;
                long quot = dl / (long)s;
                if (quot > 65535L)
                {
                    cpu.SetFlags(cpu.VFlag);
                    cpu.SetFlags(cpu.NFlag);
                }
                else
                {
                    int remain = (int)((dl % s) & 0xffff);
                    int result = (int)(quot & 0x0000ffff) | (remain << 16);
                    cpu.SetDataRegisterLong(reg, result);
                    if ((quot & 0x8000) != 0)
                    {
                        cpu.SetFlags(cpu.NFlag);
                    }
                    else
                    {
                        cpu.ClrFlags(cpu.NFlag);
                    }

                    if (quot == 0)
                    {
                        cpu.SetFlags(cpu.ZFlag);
                    }
                    else
                    {
                        cpu.ClrFlags(cpu.ZFlag);
                    }

                    cpu.ClrFlags((cpu.VFlag | cpu.CFlag));
                }

                time = 140 + op.GetTiming();
            }

            return(time);
        }
示例#14
0
        protected int AsrWordMem(int opcode)
        {
            IOperand op       = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      v        = op.GetWord();
            int      last_out = v & 0x01;
            int      msb      = v & 0x8000;

            v  = (int)((uint)v >> 1);
            v |= msb;
            op.SetWord(v);
            cpu.CalcFlags(InstructionType.ASR, 1, last_out, v, Size.Word);
            return(8 + op.GetTiming());
        }
示例#15
0
        protected int ClrWord(int opcode)
        {
            IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);

            op.GetWord();
            op.SetWord(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());
        }
示例#16
0
        protected int DoMoveToSr(int opcode)
        {
            IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      s   = src.GetWord() & 0xf71f;

            if (!cpu.IsSupervisorMode())
            {
                cpu.RaiseSRException();
                return(34);
            }

            cpu.SetSR(s);
            return(12 + src.GetTiming());
        }
示例#17
0
        protected int AslWordMem(int opcode)
        {
            IOperand op          = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      v           = op.GetWord();
            int      last_out    = v & 0x8000;
            int      msb_changed = 0;

            v <<= 1;
            if ((v & 0x8000) != last_out)
            {
                msb_changed = 1;
            }

            op.SetWord(v);
            cpu.CalcFlagsParam(InstructionType.ASL, 1, last_out, v, msb_changed, Size.Word);
            return(8 + op.GetTiming());
        }
示例#18
0
        protected int Mulu(int opcode)
        {
            IOperand op  = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s   = op.GetWord();
            int      reg = (opcode >> 9) & 0x07;
            int      d   = cpu.GetDataRegisterWord(reg);
            int      r   = s * d;

            if (r < 0)
            {
                cpu.SetFlags(cpu.NFlag);
            }
            else
            {
                cpu.ClrFlags(cpu.NFlag);
            }

            if (r == 0)
            {
                cpu.SetFlags(cpu.ZFlag);
            }
            else
            {
                cpu.ClrFlags(cpu.ZFlag);
            }

            cpu.ClrFlags((cpu.VFlag | cpu.CFlag));
            cpu.SetDataRegisterLong(reg, r);
            int x = s;

            x = (x & 0x5555) + ((x >> 1) & 0x5555);
            x = (x & 0x3333) + ((x >> 2) & 0x3333);
            x = (x & 0x0f0f) + ((x >> 4) & 0x0f0f);
            x = (x & 0x00ff) + ((x >> 8) & 0x00ff);
            return(38 + (x << 1));
        }