Esempio n. 1
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src = new DisassembledOperand("sr");
            DisassembledOperand dst = cpu.DisassembleDstEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, "move", src, dst));
        }
Esempio n. 2
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            if ((opcode & 0x00c0) == 0x00c0)
            {
                src = cpu.DisassembleDstEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);
                return(new DisassembledInstruction(address, opcode, "asl" + sz.Ext, src));
            }
            else if ((opcode & 0x0020) == 0x0020)
            {
                src = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
                dst = new DisassembledOperand("d" + (opcode & 0x07));
            }
            else
            {
                int count = (opcode >> 9) & 0x07;
                if (count == 0)
                {
                    count = 8;
                }
                src = new DisassembledOperand("#" + count);
                dst = new DisassembledOperand("d" + (opcode & 0x07));
            }

            return(new DisassembledInstruction(address, opcode, "asl" + sz.Ext, src, dst));
        }
Esempio n. 3
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src = cpu.DisassembleSrcEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);
            DisassembledOperand dst = cpu.DisassembleDstEA(address + 2 + src.Bytes, (opcode >> 6) & 0x07, (opcode >> 9) & 0x07, sz);

            return(new DisassembledInstruction(address, opcode, "move" + sz.Ext, src, dst));
        }
Esempio n. 4
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand src = new DisassembledOperand($"#${(opcode & 0xff).ToString("x2", CultureInfo.InvariantCulture)}");
            DisassembledOperand dst = new DisassembledOperand($"d{(opcode >> 9) & 0x07}");

            return(new DisassembledInstruction(address, opcode, "moveq", src, dst));
        }
Esempio n. 5
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src;
            int bytes = 2;

            if ((opcode & 0x0100) != 0)
            {
                src = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
            }
            else
            {
                int ext = cpu.ReadMemoryWord(address + 2);
                int val;
                if (((opcode >> 3) & 0x07) == 0)
                {
                    val = ext & 0x1f;
                }
                else
                {
                    val = ext & 0x07;
                }

                src    = new DisassembledOperand($"#${val.ToString("x", CultureInfo.InvariantCulture)}", 2, ext);
                bytes += 2;
            }

            DisassembledOperand dst = cpu.DisassembleDstEA(address + bytes, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, "bset", src, dst));
        }
Esempio n. 6
0
            public DisassembledInstruction Disassemble(int address, int opcode)
            {
                int data = parent.cpu.ReadMemoryWord(address + 2);
                DisassembledOperand op = new DisassembledOperand($"#${data.ToString("x4", CultureInfo.InvariantCulture)}", 2, data);

                return(new DisassembledInstruction(address, opcode, "stop", op));
            }
Esempio n. 7
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src = cpu.DisassembleSrcEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);
            DisassembledOperand dst = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));

            return(new DisassembledInstruction(address, opcode, "divs", src, dst));
        }
Esempio n. 8
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src = new DisassembledOperand($"(a{(opcode & 0x07)})+");
            DisassembledOperand dst = new DisassembledOperand($"(a{((opcode >> 9) & 0x07)})+");

            return(new DisassembledInstruction(address, opcode, "cmpm" + sz.Ext, src, dst));
        }
Esempio n. 9
0
        public DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand src = new DisassembledOperand("a" + (opcode & 0x07));
            int dis = cpu.ReadMemoryWordSigned(address + 2);
            DisassembledOperand dst = new DisassembledOperand($"#${dis.ToString("x4", CultureInfo.InvariantCulture)}", 2, dis);

            return(new DisassembledInstruction(address, opcode, "link", src, dst));
        }
Esempio n. 10
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            int cc  = (opcode >> 8) & 0x0f;
            int dis = cpu.ReadMemoryWordSigned(address + 2);
            DisassembledOperand reg = new DisassembledOperand($"d{opcode & 0x07}");

            DisassembledOperand where = new DisassembledOperand($"${(dis + address + 2).ToString("x8", CultureInfo.InvariantCulture)}", 2, dis);
            return(new DisassembledInstruction(address, opcode, names[cc], reg, where));
        }
Esempio n. 11
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            int s = (opcode >> 9 & 0x07);

            if (s == 0)
            {
                s = 8;
            }
            DisassembledOperand src = new DisassembledOperand("#" + s);
            DisassembledOperand dst = cpu.DisassembleDstEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, "addq" + sz.Ext, src, dst));
        }
Esempio n. 12
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            int    imm_bytes;
            int    imm;
            string instructionSet;

            imm            = cpu.ReadMemoryWord(address + 2);
            instructionSet = imm.ToString("#$%04x", CultureInfo.InvariantCulture);
            imm_bytes      = 2;
            DisassembledOperand src = new DisassembledOperand(instructionSet, imm_bytes, imm);
            DisassembledOperand dst = cpu.DisassembleDstEA(address + 2 + imm_bytes, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, "ori" + sz.Ext, src, dst));
        }
Esempio n. 13
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, bool moveToUsp)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            if (moveToUsp)
            {
                src = new DisassembledOperand("a" + (opcode & 0x07));
                dst = new DisassembledOperand("usp");
            }
            else
            {
                src = new DisassembledOperand("usp");
                dst = new DisassembledOperand("a" + (opcode & 0x07));
            }

            return(new DisassembledInstruction(address, opcode, "move", src, dst));
        }
Esempio n. 14
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, bool dataRegMode)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            if (dataRegMode)
            {
                src = new DisassembledOperand($"d{(opcode & 0x07)}");
                dst = new DisassembledOperand($"d{((opcode >> 9) & 0x07)}");
            }
            else
            {
                src = new DisassembledOperand($"-(a{(opcode & 0x07)})");
                dst = new DisassembledOperand($"-(a{((opcode >> 9) & 0x07)})");
            }

            return(new DisassembledInstruction(address, opcode, "abcd", src, dst));
        }
Esempio n. 15
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            if ((opcode & 0x08) == 0)
            {
                src = new DisassembledOperand($"d{(opcode & 0x07)}");
                dst = new DisassembledOperand($"d{((opcode >> 9) & 0x07)}");
            }
            else
            {
                src = new DisassembledOperand($"-(a{(opcode & 0x07)})");
                dst = new DisassembledOperand($"-(a{((opcode >> 9) & 0x07)})");
            }

            return(new DisassembledInstruction(address, opcode, $"addx{sz.Ext}", src, dst));
        }
Esempio n. 16
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            if ((opcode & 0x08) == 0)
            {
                src = new DisassembledOperand("d" + (opcode & 0x07));
                dst = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
            }
            else
            {
                src = new DisassembledOperand($"-(a{opcode & 0x07})");
                dst = new DisassembledOperand($"-(a{(opcode >> 9) & 0x07})");
            }

            return(new DisassembledInstruction(address, opcode, "subx" + sz.Ext, src, dst));
        }
Esempio n. 17
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            if ((opcode & 0x0100) == 0)
            {
                src = cpu.DisassembleSrcEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);
                dst = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
            }
            else
            {
                src = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
                dst = cpu.DisassembleDstEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);
            }

            return(new DisassembledInstruction(address, opcode, "sub" + sz.Ext, src, dst));
        }
Esempio n. 18
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            int    val;
            int    bytes_read;
            string op;

            switch (sz.Ext)
            {
            case Size.BYTESIZE:
            {
                val        = cpu.ReadMemoryWord(address + 2);
                bytes_read = 2;
                op         = $"#${(val & 0xff).ToString("x2", CultureInfo.InvariantCulture)}";
                break;
            }

            case Size.WORDSIZE:
            {
                val        = cpu.ReadMemoryWord(address + 2);
                bytes_read = 2;
                op         = $"#${(val & 0x0000ffff).ToString("x4", CultureInfo.InvariantCulture)}";
                break;
            }

            case Size.LONGSIZE:
            {
                val        = cpu.ReadMemoryLong(address + 2);
                bytes_read = 4;
                op         = $"#${val.ToString("x8", CultureInfo.InvariantCulture)}";
                break;
            }

            default:
            {
                throw new ArgumentException("Invalid size for CMPI");
            }
            }

            DisassembledOperand src = new DisassembledOperand(op, bytes_read, val);
            DisassembledOperand dst = cpu.DisassembleDstEA(address + 2 + bytes_read, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, $"cmpi{sz.Ext}", src, dst));
        }
Esempio n. 19
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz, bool r2m)
        {
            DisassembledOperand src;
            DisassembledOperand dst;
            int dis = cpu.ReadMemoryWordSigned(address + 2);

            if (r2m)
            {
                src = new DisassembledOperand($"d{((opcode >> 9) & 0x07)}");
                dst = new DisassembledOperand($"#${dis.ToString("x4", CultureInfo.InvariantCulture)}(a{opcode & 0x07}", 2, dis);
            }
            else
            {
                src = new DisassembledOperand($"#${dis.ToString("x4", CultureInfo.InvariantCulture)}(a{opcode & 0x07})", 2, dis);
                dst = new DisassembledOperand($"d{((opcode >> 9) & 0x07)}");
            }

            return(new DisassembledInstruction(address, opcode, $"movep{sz.Ext}", src, dst));
        }
Esempio n. 20
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            int    imm_bytes;
            int    imm;
            string instructionSet;

            switch (sz.Ext)
            {
            case Size.BYTESIZE:
            {
                imm            = cpu.ReadMemoryWord(address + 2);
                instructionSet = $"#${(imm & 0x00ff).ToString("x2", CultureInfo.InvariantCulture)}";
                imm_bytes      = 2;
                break;
            }

            case Size.WORDSIZE:
            {
                imm            = cpu.ReadMemoryWord(address + 2);
                instructionSet = $"#${imm.ToString("x4", CultureInfo.InvariantCulture)}";
                imm_bytes      = 2;
                break;
            }

            case Size.LONGSIZE:
            {
                imm            = cpu.ReadMemoryLong(address + 2);
                instructionSet = $"#${imm.ToString("x8", CultureInfo.InvariantCulture)}";
                imm_bytes      = 4;
                break;
            }

            default:
            {
                throw new ArgumentException("Size unsized for ANDI");
            }
            }

            DisassembledOperand src = new DisassembledOperand(instructionSet, imm_bytes, imm);
            DisassembledOperand dst = cpu.DisassembleDstEA(address + 2 + imm_bytes, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, $"andi{sz.Ext}", src, dst));
        }
Esempio n. 21
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand op;
            int    cc  = (opcode >> 8) & 0x0f;
            int    dis = CpuUtils.SignExtendByte(opcode & 0xff);
            string name;

            if (dis != 0)
            {
                op   = new DisassembledOperand($"{(dis + address + 2).ToString("x8", CultureInfo.InvariantCulture)}");
                name = $"{names[cc]}.s";
            }
            else
            {
                dis  = cpu.ReadMemoryWordSigned(address + 2);
                op   = new DisassembledOperand($"{(dis + address + 2).ToString("x8", CultureInfo.InvariantCulture)}", 2, dis);
                name = $"{names[cc]}.w";
            }

            return(new DisassembledInstruction(address, opcode, name, op));
        }
Esempio n. 22
0
        public DisassembledInstruction DisassembleOp(int address, int opcode, Size sz, bool regToMem)
        {
            DisassembledOperand src;
            DisassembledOperand dst;
            int  mode     = (opcode >> 3) & 0x07;
            int  reg      = (opcode & 0x07);
            int  reglist  = cpu.ReadMemoryWord(address + 2);
            bool reversed = (mode == 4);

            if (regToMem)
            {
                src = new DisassembledOperand(RegListToString(reglist, reversed), 2, reglist);
                dst = cpu.DisassembleDstEA(address + 4, mode, reg, sz);
            }
            else
            {
                src = cpu.DisassembleSrcEA(address + 4, mode, reg, sz);
                dst = new DisassembledOperand(RegListToString(reglist, reversed), 2, reglist);
            }

            return(new DisassembledInstruction(address, opcode, "movem" + sz.Ext, src, dst));
        }
Esempio n. 23
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, ExgMode mode)
        {
            DisassembledOperand src;
            DisassembledOperand dst;

            switch (mode)
            {
            case ExgMode.ExgData:
            {
                src = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
                dst = new DisassembledOperand("d" + (opcode & 0x07));
                break;
            }

            case ExgMode.ExgAddr:
            {
                src = new DisassembledOperand("a" + ((opcode >> 9) & 0x07));
                dst = new DisassembledOperand("a" + (opcode & 0x07));
                break;
            }

            case ExgMode.ExgDataAddr:
            {
                src = new DisassembledOperand("d" + ((opcode >> 9) & 0x07));
                dst = new DisassembledOperand("a" + (opcode & 0x07));
                break;
            }

            default:
            {
                throw new ArgumentException("Invalid exg type specified");
            }
            }

            return(new DisassembledInstruction(address, opcode, "exg", src, dst));
        }
Esempio n. 24
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand op = new DisassembledOperand((opcode & 0x0f).ToString("d", CultureInfo.InvariantCulture));

            return(new DisassembledInstruction(address, opcode, "trap", op));
        }
Esempio n. 25
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src = new DisassembledOperand("d" + (opcode & 0x07));

            return(new DisassembledInstruction(address, opcode, "ext" + sz.Ext, src));
        }
Esempio n. 26
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand src = cpu.DisassembleDstEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, "not" + sz.Ext, src));
        }
Esempio n. 27
0
        public DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand src = new DisassembledOperand("d" + (opcode & 0x07));

            return(new DisassembledInstruction(address, opcode, "swap", src));
        }
Esempio n. 28
0
        public DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand src = new DisassembledOperand($"a{opcode & 0x07}");

            return(new DisassembledInstruction(address, opcode, "unlk", src));
        }
Esempio n. 29
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode, Size sz)
        {
            DisassembledOperand op = cpu.DisassembleSrcEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), sz);

            return(new DisassembledInstruction(address, opcode, "jmp", op));
        }
Esempio n. 30
0
        protected DisassembledInstruction DisassembleOp(int address, int opcode)
        {
            DisassembledOperand op = cpu.DisassembleDstEA(address + 2, (opcode >> 3) & 0x07, (opcode & 0x07), Size.Byte);

            return(new DisassembledInstruction(address, opcode, names[(opcode >> 8) & 0x0f], op));
        }