Beispiel #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());
        }
Beispiel #2
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);
            }
        }
Beispiel #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());
        }
Beispiel #4
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());
        }
Beispiel #5
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());
        }
Beispiel #6
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());
        }
Beispiel #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()]);
        }
Beispiel #8
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());
        }
Beispiel #9
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());
        }
Beispiel #10
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());
        }
Beispiel #11
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);
        }
Beispiel #12
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());
        }
Beispiel #13
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());
        }
Beispiel #14
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());
        }