示例#1
0
        protected int SubqWord(int opcode)
        {
            int s = (opcode >> 9 & 0x07);

            if (s == 0)
            {
                s = 8;
            }
            int mode = (opcode >> 3) & 0x07;

            if (mode != 1)
            {
                IOperand dst = cpu.ResolveDstEA(mode, (opcode & 0x07), Size.Word);
                int      d   = dst.GetWordSigned();
                int      r   = d - s;
                dst.SetWord(r);
                cpu.CalcFlags(InstructionType.SUB, s, d, r, Size.Word);
                return(dst.IsRegisterMode() ? 4 : 8 + dst.GetTiming());
            }
            else
            {
                int reg = opcode & 0x07;
                cpu.SetAddrRegisterLong(reg, cpu.GetAddrRegisterLong(reg) - s);
                return(4);
            }
        }
示例#2
0
        protected int MoveaWord(int opcode)
        {
            IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);

            cpu.SetAddrRegisterLong((opcode >> 9) & 0x07, src.GetWordSigned());
            return(MOVE.ShortExecutionTime[src.Index()][1]);
        }
示例#3
0
        protected int OriWord(int opcode)
        {
            int      s   = cpu.FetchPCWordSigned();
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      d   = dst.GetWordSigned();
            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.OR, s, d, r, Size.Word);
            }

            return(dst.IsRegisterMode() ? 8 : 12 + dst.GetTiming());
        }
示例#4
0
        protected int AddaWord(int opcode)
        {
            IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s   = src.GetWordSigned();
            int      reg = (opcode >> 9) & 0x07;

            cpu.SetAddrRegisterLong(reg, cpu.GetAddrRegisterLong(reg) + s);
            return(8 + src.GetTiming());
        }
示例#5
0
        protected int CmpiWord(int opcode)
        {
            int      s  = cpu.FetchPCWordSigned();
            IOperand op = cpu.ResolveDstEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      d  = op.GetWordSigned();
            int      r  = d - s;

            cpu.CalcFlags(InstructionType.CMP, s, d, r, Size.Word);
            return(op.IsRegisterMode() ? 8 : 8 + op.GetTiming());
        }
示例#6
0
        protected int CmpaWord(int opcode)
        {
            IOperand op = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      d  = cpu.GetAddrRegisterLong((opcode >> 9) & 0x07);
            int      s  = op.GetWordSigned();
            int      r  = d - s;

            cpu.CalcFlags(InstructionType.CMP, s, d, r, Size.SizeLong);
            return(6 + op.GetTiming());
        }
示例#7
0
        protected int SubiWord(int opcode)
        {
            int      s   = cpu.FetchPCWordSigned();
            IOperand dst = cpu.ResolveDstEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      d   = dst.GetWordSigned();
            int      r   = d - s;

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

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

            cpu.CalcFlags(InstructionType.SUB, s, d, r, Size.Word);
            return(time);
        }
示例#9
0
        protected int Divs(int opcode)
        {
            IOperand op  = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s   = op.GetWordSigned();
            int      reg = (opcode >> 9) & 0x07;
            int      d   = cpu.GetDataRegisterLong(reg);
            int      time;

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

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

                time = 158 + op.GetTiming();
            }

            return(time);
        }
示例#10
0
        protected int Muls(int opcode)
        {
            IOperand op  = cpu.ResolveSrcEA((opcode >> 3) & 0x07, (opcode & 0x07), Size.Word);
            int      s   = op.GetWordSigned();
            int      reg = (opcode >> 9) & 0x07;
            int      d   = cpu.GetDataRegisterWord(reg);

            if ((d & 0x8000) == 0x8000)
            {
                d |= -65536;
            }

            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 last_bit = 0;
            int val;
            int count = 0;

            for (int x = 0; x < 16; x++)
            {
                val = s & 1;
                if (val != last_bit)
                {
                    count++;
                }
                last_bit = val;
                s      >>= 1;
            }

            return(38 + (count << 1));
        }
示例#11
0
        protected int SubWordDnDest(int opcode)
        {
            IOperand src = cpu.ResolveSrcEA((opcode >> 3) & 0x07, opcode & 0x07, Size.Word);
            int      s   = src.GetWordSigned();
            int      reg = (opcode >> 9) & 0x07;
            int      d   = cpu.GetDataRegisterWordSigned(reg);
            int      r   = d - s;

            cpu.SetDataRegisterWord(reg, r);
            int time = 4 + src.GetTiming();

            cpu.CalcFlags(InstructionType.SUB, s, d, r, Size.Word);
            return(time);
        }