Exemplo n.º 1
0
		void AND0_Disasm(DisassemblyInfo info)
		{
			int dstReg = (op >> 9) & 0x07;
			int size = (op >> 6) & 0x03;
			int srcMode = (op >> 3) & 0x07;
			int srcReg = op & 0x07;

			int pc = info.PC + 2;

			switch (size)
			{
				case 0: // Byte
					info.Mnemonic = "and.b";
					info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 1, ref pc), dstReg);
					break;
				case 1: // Word
					info.Mnemonic = "and.w";
					info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 2, ref pc), dstReg);
					break;
				case 2: // Long
					info.Mnemonic = "and.l";
					info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 4, ref pc), dstReg);
					break;
			}

			info.Length = pc - info.PC;
		}
Exemplo n.º 2
0
		void ANDI_SR_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			info.Mnemonic = "andi";
			info.Args = DisassembleImmediate(2, ref pc) + ", SR";
			info.Length = pc - info.PC;
		}
Exemplo n.º 3
0
		void MOVE_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int size = ((op >> 12) & 0x03);
			int dstMode = ((op >> 6) & 0x07);
			int dstReg = ((op >> 9) & 0x07);
			int srcMode = ((op >> 3) & 0x07);
			int srcReg = (op & 0x07);

			switch (size)
			{
				case 1:
					info.Mnemonic = "move.b";
					info.Args = DisassembleValue(srcMode, srcReg, 1, ref pc) + ", ";
					info.Args += DisassembleValue(dstMode, dstReg, 1, ref pc);
					break;
				case 3:
					info.Mnemonic = "move.w";
					info.Args = DisassembleValue(srcMode, srcReg, 2, ref pc) + ", ";
					info.Args += DisassembleValue(dstMode, dstReg, 2, ref pc);
					break;
				case 2:
					info.Mnemonic = "move.l";
					info.Args = DisassembleValue(srcMode, srcReg, 4, ref pc) + ", ";
					info.Args += DisassembleValue(dstMode, dstReg, 4, ref pc);
					break;
			}

			info.Length = pc - info.PC;
		}
Exemplo n.º 4
0
		void MOVEfSR_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;
			info.Mnemonic = "move";
			info.Args = "SR, " + DisassembleValue(mode, reg, 2, ref pc);
			info.Length = pc - info.PC;
		}
Exemplo n.º 5
0
		void MOVEUSP_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int dir = (op >> 3) & 1;
			int reg = op & 7;
			info.Mnemonic = "move";
			info.Args = (dir == 0) ? ("A" + reg + ", USP") : ("USP, A" + reg);
			info.Length = pc - info.PC;
		}
Exemplo n.º 6
0
        void MOVEUSP_Disasm(DisassemblyInfo info)
        {
            int pc  = info.PC + 2;
            int dir = (op >> 3) & 1;
            int reg = op & 7;

            info.Mnemonic = "move";
            info.Args     = (dir == 0) ? ("A" + reg + ", USP") : ("USP, A" + reg);
            info.Length   = pc - info.PC;
        }
Exemplo n.º 7
0
        void MOVEfSR_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            info.Mnemonic = "move";
            info.Args     = "SR, " + DisassembleValue(mode, reg, 2, ref pc);
            info.Length   = pc - info.PC;
        }
Exemplo n.º 8
0
        void PEA_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            info.Mnemonic = "pea";
            info.Args     = DisassembleAddress(mode, reg, ref pc);
            info.Length   = pc - info.PC;
        }
Exemplo n.º 9
0
        void JMP_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            info.Mnemonic = "jmp";
            info.Args     = DisassembleValue(mode, reg, 1, ref pc);
            info.Length   = pc - info.PC;
        }
        private void MOVEtSR_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            info.Mnemonic = "move";
            info.Args     = DisassembleValue(mode, reg, 2, ref pc) + ", SR";
            info.Length   = pc - info.PC;
        }
Exemplo n.º 11
0
        private void Scc_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int cond = (op >> 8) & 0x0F;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            info.Mnemonic = "s" + DisassembleCondition(cond);
            info.Args     = DisassembleValue(mode, reg, 1, ref pc);
            info.Length   = pc - info.PC;
        }
Exemplo n.º 12
0
        private void BSETr_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int dReg = (op >> 9) & 7;
            int mode = (op >> 3) & 7;
            int reg  = op & 7;

            info.Mnemonic = "bset";
            info.Args     = $"D{dReg}, {DisassembleValue(mode, reg, 1, ref pc)}";
            info.Length   = pc - info.PC;
        }
Exemplo n.º 13
0
        private void BSETi_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int bit  = ReadWord(pc); pc += 2;
            int mode = (op >> 3) & 7;
            int reg  = op & 7;

            info.Mnemonic = "bset";
            info.Args     = $"#${bit:X}, {DisassembleValue(mode, reg, 1, ref pc)}";
            info.Length   = pc - info.PC;
        }
Exemplo n.º 14
0
        void BSETr_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int dReg = (op >> 9) & 7;
            int mode = (op >> 3) & 7;
            int reg  = op & 7;

            info.Mnemonic = "bset";
            info.Args     = String.Format("D{0}, {1}", dReg, DisassembleValue(mode, reg, 1, ref pc));
            info.Length   = pc - info.PC;
        }
Exemplo n.º 15
0
        void BSETi_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int bit  = ReadWord(pc); pc += 2;
            int mode = (op >> 3) & 7;
            int reg  = op & 7;

            info.Mnemonic = "bset";
            info.Args     = String.Format("#${0:X}, {1}", bit, DisassembleValue(mode, reg, 1, ref pc));
            info.Length   = pc - info.PC;
        }
Exemplo n.º 16
0
		void EXT_Disasm(DisassemblyInfo info)
		{
			int size = (op >> 6) & 1;
			int reg = op & 7;

			switch (size)
			{
				case 0: info.Mnemonic = "ext.w"; info.Args = "D" + reg; break;
				case 1: info.Mnemonic = "ext.l"; info.Args = "D" + reg; break;
			}
		}
Exemplo n.º 17
0
        void DIVS_Disasm(DisassemblyInfo info)
        {
            int dreg = (op >> 9) & 7;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            int pc = info.PC + 2;

            info.Mnemonic = "divs";
            info.Args     = String.Format("{0}, D{1}", DisassembleValue(mode, reg, 2, ref pc), dreg);
            info.Length   = pc - info.PC;
        }
Exemplo n.º 18
0
        private void DIVS_Disasm(DisassemblyInfo info)
        {
            int dreg = (op >> 9) & 7;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            int pc = info.PC + 2;

            info.Mnemonic = "divs";
            info.Args     = $"{DisassembleValue(mode, reg, 2, ref pc)}, D{dreg}";
            info.Length   = pc - info.PC;
        }
Exemplo n.º 19
0
		void LEA_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int mode = (op >> 3) & 7;
			int sReg = (op >> 0) & 7;
			int dReg = (op >> 9) & 7;

			info.Mnemonic = "lea";
			info.Args = DisassembleAddress(mode, sReg, ref pc);
			info.Args += ", A" + dReg;

			info.Length = pc - info.PC;
		}
Exemplo n.º 20
0
        private void ADDA_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int aReg = (op >> 9) & 7;
            int size = (op >> 8) & 1;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            info.Mnemonic = (size == 0) ? "adda.w" : "adda.l";
            info.Args     = DisassembleValue(mode, reg, (size == 0) ? 2 : 4, ref pc) + ", A" + aReg;

            info.Length = pc - info.PC;
        }
Exemplo n.º 21
0
		void MOVEM1_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int size = (op >> 6) & 1;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			ushort registers = (ushort)ReadWord(pc); pc += 2;
			string address = DisassembleAddress(mode, reg, ref pc);

			info.Mnemonic = size == 0 ? "movem.w" : "movem.l";
			info.Args = address + ", " + DisassembleRegisterList1((uint)registers << 16);
			info.Length = pc - info.PC;
		}
Exemplo n.º 22
0
		void CLR_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int size = (op >> 6) & 3;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			switch (size)
			{
				case 0: info.Mnemonic = "clr.b"; info.Args = DisassembleValue(mode, reg, 1, ref pc); break;
				case 1: info.Mnemonic = "clr.w"; info.Args = DisassembleValue(mode, reg, 2, ref pc); break;
				case 2: info.Mnemonic = "clr.l"; info.Args = DisassembleValue(mode, reg, 4, ref pc); break;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 23
0
        void CLR_Disasm(DisassemblyInfo info)
        {
            int pc = info.PC + 2;
            int size = (op >> 6) & 3;
            int mode = (op >> 3) & 7;
            int reg = (op >> 0) & 7;

            switch (size)
            {
                case 0: info.Mnemonic = "clr.b"; info.Args = DisassembleValue(mode, reg, 1, ref pc); break;
                case 1: info.Mnemonic = "clr.w"; info.Args = DisassembleValue(mode, reg, 2, ref pc); break;
                case 2: info.Mnemonic = "clr.l"; info.Args = DisassembleValue(mode, reg, 4, ref pc); break;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 24
0
        private void Bcc_Disasm(DisassemblyInfo info)
        {
            int   pc            = info.PC + 2;
            sbyte displacement8 = (sbyte)op;
            int   cond          = (op >> 8) & 0x0F;

            info.Mnemonic = "b" + DisassembleCondition(cond);
            if (displacement8 != 0)
            {
                info.Args = $"${pc + displacement8:X}";
            }
            else
            {
                info.Args = $"${pc + ReadWord(pc):X}";
                pc       += 2;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 25
0
        private void DBcc_Disasm(DisassemblyInfo info)
        {
            int cond = (op >> 8) & 0x0F;

            if (cond == 1)
            {
                info.Mnemonic = "dbra";
            }
            else
            {
                info.Mnemonic = "db" + DisassembleCondition(cond);
            }

            int pc = info.PC + 2;

            info.Args   = $"D{op & 7}, ${pc + ReadWord(pc):X}";
            info.Length = 4;
        }
Exemplo n.º 26
0
        private void CMPM_Disasm(DisassemblyInfo info)
        {
            int pc    = info.PC + 2;
            int axReg = (op >> 9) & 7;
            int size  = (op >> 6) & 3;
            int ayReg = (op >> 0) & 7;

            switch (size)
            {
            case 0: info.Mnemonic = "cmpm.b"; break;

            case 1: info.Mnemonic = "cmpm.w"; break;

            case 2: info.Mnemonic = "cmpm.l"; break;
            }
            info.Args   = $"(A{ayReg})+, (A{axReg})+";
            info.Length = pc - info.PC;
        }
Exemplo n.º 27
0
        void Bcc_Disasm(DisassemblyInfo info)
        {
            int   pc            = info.PC + 2;
            sbyte displacement8 = (sbyte)op;
            int   cond          = (op >> 8) & 0x0F;

            info.Mnemonic = "b" + DisassembleCondition(cond);
            if (displacement8 != 0)
            {
                info.Args = string.Format("${0:X}", pc + displacement8);
            }
            else
            {
                info.Args = string.Format("${0:X}", pc + ReadWord(pc));
                pc       += 2;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 28
0
        void DBcc_Disasm(DisassemblyInfo info)
        {
            int cond = (op >> 8) & 0x0F;

            if (cond == 1)
            {
                info.Mnemonic = "dbra";
            }
            else
            {
                info.Mnemonic = "db" + DisassembleCondition(cond);
            }

            int pc = info.PC + 2;

            info.Args   = String.Format("D{0}, ${1:X}", op & 7, pc + ReadWord(pc));
            info.Length = 4;
        }
Exemplo n.º 29
0
        void CMPM_Disasm(DisassemblyInfo info)
        {
            int pc    = info.PC + 2;
            int axReg = (op >> 9) & 7;
            int size  = (op >> 6) & 3;
            int ayReg = (op >> 0) & 7;

            switch (size)
            {
            case 0: info.Mnemonic = "cmpm.b"; break;

            case 1: info.Mnemonic = "cmpm.w"; break;

            case 2: info.Mnemonic = "cmpm.l"; break;
            }
            info.Args   = string.Format("(A{0})+, (A{1})+", ayReg, axReg);
            info.Length = pc - info.PC;
        }
Exemplo n.º 30
0
        void BSR_Disasm(DisassemblyInfo info)
        {
            int pc = info.PC + 2;

            info.Mnemonic = "bsr";

            sbyte displacement8 = (sbyte)op;

            if (displacement8 != 0)
            {
                info.Args = String.Format("${0:X}", pc + displacement8);
            }
            else
            {
                info.Args = String.Format("${0:X}", pc + ReadWord(pc));
                pc       += 2;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 31
0
        private void BSR_Disasm(DisassemblyInfo info)
        {
            int pc = info.PC + 2;

            info.Mnemonic = "bsr";

            sbyte displacement8 = (sbyte)op;

            if (displacement8 != 0)
            {
                info.Args = $"${pc + displacement8:X}";
            }
            else
            {
                info.Args = $"${pc + ReadWord(pc):X}";
                pc       += 2;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 32
0
		void MOVEA_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int size = ((op >> 12) & 0x03);
			int dstReg = ((op >> 9) & 0x07);
			int srcMode = ((op >> 3) & 0x07);
			int srcReg = (op & 0x07);

			if (size == 3)
			{
				info.Mnemonic = "movea.w";
				info.Args = DisassembleValue(srcMode, srcReg, 2, ref pc) + ", A" + dstReg;
			}
			else
			{
				info.Mnemonic = "movea.l";
				info.Args = DisassembleValue(srcMode, srcReg, 4, ref pc) + ", A" + dstReg;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 33
0
        private void SUBQ_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int data = (op >> 9) & 7;
            int size = (op >> 6) & 3;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            data = data == 0 ? 8 : data;             // range is 1-8; 0 represents 8

            switch (size)
            {
            case 0: info.Mnemonic = "subq.b"; info.Args = "#" + data + ", " + DisassembleValue(mode, reg, 1, ref pc); break;

            case 1: info.Mnemonic = "subq.w"; info.Args = "#" + data + ", " + DisassembleValue(mode, reg, 2, ref pc); break;

            case 2: info.Mnemonic = "subq.l"; info.Args = "#" + data + ", " + DisassembleValue(mode, reg, 4, ref pc); break;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 34
0
        void ANDI_Disasm(DisassemblyInfo info)
        {
            int size    = ((op >> 6) & 0x03);
            int dstMode = ((op >> 3) & 0x07);
            int dstReg  = (op & 0x07);

            int pc = info.PC + 2;

            switch (size)
            {
            case 0:                     // Byte
            {
                info.Mnemonic = "andi.b";
                sbyte imm = (sbyte)ReadWord(pc); pc += 2;
                info.Args  = string.Format("#${0:X}, ", imm);
                info.Args += DisassembleValue(dstMode, dstReg, 1, ref pc);
                break;
            }

            case 1:                     // Word
            {
                info.Mnemonic = "andi.w";
                short imm = ReadWord(pc); pc += 2;
                info.Args  = string.Format("#${0:X}, ", imm);
                info.Args += DisassembleValue(dstMode, dstReg, 2, ref pc);
                break;
            }

            case 2:                     // Long
            {
                info.Mnemonic = "andi.l";
                int imm = ReadLong(pc); pc += 4;
                info.Args  = string.Format("#${0:X}, ", imm);
                info.Args += DisassembleValue(dstMode, dstReg, 4, ref pc);
                break;
            }
            }

            info.Length = pc - info.PC;
        }
Exemplo n.º 35
0
        private void SUB_Disasm(DisassemblyInfo info)
        {
            int pc   = info.PC + 2;
            int dReg = (op >> 9) & 7;
            int dir  = (op >> 8) & 1;
            int size = (op >> 6) & 3;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            string op1 = "D" + dReg;
            string op2;

            switch (size)
            {
            case 0: info.Mnemonic = "sub.b"; op2 = DisassembleValue(mode, reg, 1, ref pc); break;

            case 1: info.Mnemonic = "sub.w"; op2 = DisassembleValue(mode, reg, 2, ref pc); break;

            default: info.Mnemonic = "sub.l"; op2 = DisassembleValue(mode, reg, 4, ref pc); break;
            }
            info.Args   = dir == 0 ? (op2 + ", " + op1) : (op1 + ", " + op2);
            info.Length = pc - info.PC;
        }
Exemplo n.º 36
0
        private void CMPA_Disasm(DisassemblyInfo info)
        {
            int pc = info.PC + 2;

            int aReg = (op >> 9) & 7;
            int size = (op >> 8) & 1;
            int mode = (op >> 3) & 7;
            int reg  = (op >> 0) & 7;

            switch (size)
            {
            case 0:
                info.Mnemonic = "cmpa.w";
                info.Args     = DisassembleValue(mode, reg, 2, ref pc) + ", A" + aReg;
                break;

            case 1:
                info.Mnemonic = "cmpa.l";
                info.Args     = DisassembleValue(mode, reg, 4, ref pc) + ", A" + aReg;
                break;
            }
            info.Length = pc - info.PC;
        }
Exemplo n.º 37
0
		void ASRd_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int rot = (op >> 9) & 7;
			int size = (op >> 6) & 3;
			int m = (op >> 5) & 1;
			int reg = op & 7;

			if (m == 0 && rot == 0) rot = 8;

			switch (size)
			{
				case 0: info.Mnemonic = "asr.b"; break;
				case 1: info.Mnemonic = "asr.w"; break;
				case 2: info.Mnemonic = "asr.l"; break;
			}
			if (m == 0) info.Args = rot + ", D" + reg;
			else info.Args = "D" + rot + ", D" + reg;

			info.Length = pc - info.PC;
		}
Exemplo n.º 38
0
		void NOT_Disasm(DisassemblyInfo info)
		{
			int size = (op >> 6) & 0x03;
			int mode = (op >> 3) & 0x07;
			int reg = op & 0x07;

			int pc = info.PC + 2;

			switch (size)
			{
				case 0: // Byte
					info.Mnemonic = "not.b";
					info.Args = DisassembleValue(mode, reg, 1, ref pc);
					break;
				case 1: // Word
					info.Mnemonic = "not.w";
					info.Args = DisassembleValue(mode, reg, 2, ref pc);
					break;
				case 2: // Long
					info.Mnemonic = "not.l";
					info.Args = DisassembleValue(mode, reg, 4, ref pc);
					break;
			}

			info.Length = pc - info.PC;
		}
Exemplo n.º 39
0
		void BSETr_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int dReg = (op >> 9) & 7;
			int mode = (op >> 3) & 7;
			int reg = op & 7;

			info.Mnemonic = "bset";
			info.Args = String.Format("D{0}, {1}", dReg, DisassembleValue(mode, reg, 1, ref pc));
			info.Length = pc - info.PC;
		}
Exemplo n.º 40
0
		void SUBQ_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int data = (op >> 9) & 7;
			int size = (op >> 6) & 3;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			data = data == 0 ? 8 : data; // range is 1-8; 0 represents 8

			switch (size)
			{
				case 0: info.Mnemonic = "subq.b"; info.Args = data + ", " + DisassembleValue(mode, reg, 1, ref pc); break;
				case 1: info.Mnemonic = "subq.w"; info.Args = data + ", " + DisassembleValue(mode, reg, 2, ref pc); break;
				case 2: info.Mnemonic = "subq.l"; info.Args = data + ", " + DisassembleValue(mode, reg, 4, ref pc); break;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 41
0
		void CMPA_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;

			int aReg = (op >> 9) & 7;
			int size = (op >> 8) & 1;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			switch (size)
			{
				case 0:
					info.Mnemonic = "cmpa.w";
					info.Args = DisassembleValue(mode, reg, 2, ref pc) + ", A" + aReg;
					break;
				case 1:
					info.Mnemonic = "cmpa.l";
					info.Args = DisassembleValue(mode, reg, 4, ref pc) + ", A" + aReg;
					break;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 42
0
		void BSR_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			info.Mnemonic = "bsr";

			sbyte displacement8 = (sbyte)op;
			if (displacement8 != 0)
				info.Args = String.Format("${0:X}", pc + displacement8);
			else
			{
				info.Args = String.Format("${0:X}", pc + ReadWord(pc));
				pc += 2;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 43
0
		void Bcc_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			sbyte displacement8 = (sbyte)op;
			int cond = (op >> 8) & 0x0F;

			info.Mnemonic = "b" + DisassembleCondition(cond);
			if (displacement8 != 0)
			{
				info.Args = string.Format("${0:X}", pc + displacement8);
			}
			else
			{
				info.Args = string.Format("${0:X}", pc + ReadWord(pc));
				pc += 2;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 44
0
		void Scc_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int cond = (op >> 8) & 0x0F;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			info.Mnemonic = "s" + DisassembleCondition(cond);
			info.Args = DisassembleValue(mode, reg, 1, ref pc);
			info.Length = pc - info.PC;
		}
Exemplo n.º 45
0
		void NOP_Disasm(DisassemblyInfo info)
		{
			info.Mnemonic = "nop";
		}
Exemplo n.º 46
0
		void UNLK_Disasm(DisassemblyInfo info)
		{
			int reg = op & 7;
			info.Mnemonic = "unlk";
			info.Args = "A" + reg;
			info.Length = 2;
		}
Exemplo n.º 47
0
		void LINK_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int reg = op & 7;
			info.Mnemonic = "link";
			info.Args = "A" + reg + ", " + DisassembleImmediate(2, ref pc); // TODO need a DisassembleSigned or something
			info.Length = pc - info.PC;
		}
Exemplo n.º 48
0
		void JSR_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;
			info.Mnemonic = "jsr";
			info.Args = DisassembleAddress(mode, reg, ref pc);
			info.Length = pc - info.PC;
		}
Exemplo n.º 49
0
		void JMP_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;
			info.Mnemonic = "jmp";
			info.Args = DisassembleValue(mode, reg, 1, ref pc);
			info.Length = pc - info.PC;
		}
Exemplo n.º 50
0
		void TRAP_Disasm(DisassemblyInfo info)
		{
			info.Mnemonic = "trap";
			info.Args = string.Format("#${0:X}", op & 0xF);
		}
Exemplo n.º 51
0
		void DBcc_Disasm(DisassemblyInfo info)
		{
			int cond = (op >> 8) & 0x0F;
			if (cond == 1)
				info.Mnemonic = "dbra";
			else
				info.Mnemonic = "db" + DisassembleCondition(cond);

			int pc = info.PC + 2;
			info.Args = String.Format("D{0}, ${1:X}", op & 7, pc + ReadWord(pc));
			info.Length = 4;
		}
Exemplo n.º 52
0
		public DisassemblyInfo Disassemble(int pc)
		{
			var info = new DisassemblyInfo { Mnemonic = "UNKNOWN", PC = pc, Length = 2 };
			op = (ushort)ReadWord(pc);

			if (Opcodes[op] == MOVE) MOVE_Disasm(info);
			else if (Opcodes[op] == MOVEA) MOVEA_Disasm(info);
			else if (Opcodes[op] == MOVEQ) MOVEQ_Disasm(info);
			else if (Opcodes[op] == MOVEM0) MOVEM0_Disasm(info);
			else if (Opcodes[op] == MOVEM1) MOVEM1_Disasm(info);
			else if (Opcodes[op] == LEA) LEA_Disasm(info);
			else if (Opcodes[op] == CLR) CLR_Disasm(info);
			else if (Opcodes[op] == EXT) EXT_Disasm(info);
			else if (Opcodes[op] == PEA) PEA_Disasm(info);

			else if (Opcodes[op] == ANDI) ANDI_Disasm(info);
			else if (Opcodes[op] == EORI) EORI_Disasm(info);
			else if (Opcodes[op] == ORI) ORI_Disasm(info);
			else if (Opcodes[op] == ASLd) ASLd_Disasm(info);
			else if (Opcodes[op] == ASRd) ASRd_Disasm(info);
			else if (Opcodes[op] == LSLd) LSLd_Disasm(info);
			else if (Opcodes[op] == LSRd) LSRd_Disasm(info);
			else if (Opcodes[op] == ROXLd) ROXLd_Disasm(info);
			else if (Opcodes[op] == ROXRd) ROXRd_Disasm(info);
			else if (Opcodes[op] == ROLd) ROLd_Disasm(info);
			else if (Opcodes[op] == RORd) RORd_Disasm(info);
			else if (Opcodes[op] == SWAP) SWAP_Disasm(info);
			else if (Opcodes[op] == AND0) AND0_Disasm(info);
			else if (Opcodes[op] == AND1) AND1_Disasm(info);
			else if (Opcodes[op] == EOR) EOR_Disasm(info);
			else if (Opcodes[op] == OR0) OR0_Disasm(info);
			else if (Opcodes[op] == OR1) OR1_Disasm(info);
			else if (Opcodes[op] == NOT) NOT_Disasm(info);
			else if (Opcodes[op] == NEG) NEG_Disasm(info);

			else if (Opcodes[op] == JMP) JMP_Disasm(info);
			else if (Opcodes[op] == JSR) JSR_Disasm(info);
			else if (Opcodes[op] == Bcc) Bcc_Disasm(info);
			else if (Opcodes[op] == BRA) BRA_Disasm(info);
			else if (Opcodes[op] == BSR) BSR_Disasm(info);
			else if (Opcodes[op] == DBcc) DBcc_Disasm(info);
			else if (Opcodes[op] == Scc) Scc_Disasm(info);
			else if (Opcodes[op] == RTE) RTE_Disasm(info);
			else if (Opcodes[op] == RTS) RTS_Disasm(info);
			else if (Opcodes[op] == RTR) RTR_Disasm(info);
			else if (Opcodes[op] == TST) TST_Disasm(info);
			else if (Opcodes[op] == BTSTi) BTSTi_Disasm(info);
			else if (Opcodes[op] == BTSTr) BTSTr_Disasm(info);
			else if (Opcodes[op] == BCHGi) BCHGi_Disasm(info);
			else if (Opcodes[op] == BCHGr) BCHGr_Disasm(info);
			else if (Opcodes[op] == BCLRi) BCLRi_Disasm(info);
			else if (Opcodes[op] == BCLRr) BCLRr_Disasm(info);
			else if (Opcodes[op] == BSETi) BSETi_Disasm(info);
			else if (Opcodes[op] == BSETr) BSETr_Disasm(info);
			else if (Opcodes[op] == LINK) LINK_Disasm(info);
			else if (Opcodes[op] == UNLK) UNLK_Disasm(info);
			else if (Opcodes[op] == NOP) NOP_Disasm(info);

			else if (Opcodes[op] == ADD0) ADD_Disasm(info);
			else if (Opcodes[op] == ADD1) ADD_Disasm(info);
			else if (Opcodes[op] == ADDA) ADDA_Disasm(info);
			else if (Opcodes[op] == ADDI) ADDI_Disasm(info);
			else if (Opcodes[op] == ADDQ) ADDQ_Disasm(info);
			else if (Opcodes[op] == SUB0) SUB_Disasm(info);
			else if (Opcodes[op] == SUB1) SUB_Disasm(info);
			else if (Opcodes[op] == SUBA) SUBA_Disasm(info);
			else if (Opcodes[op] == SUBI) SUBI_Disasm(info);
			else if (Opcodes[op] == SUBQ) SUBQ_Disasm(info);
			else if (Opcodes[op] == CMP) CMP_Disasm(info);
			else if (Opcodes[op] == CMPM) CMPM_Disasm(info);
			else if (Opcodes[op] == CMPA) CMPA_Disasm(info);

			else if (Opcodes[op] == CMPI) CMPI_Disasm(info);
			else if (Opcodes[op] == MULU) MULU_Disasm(info);
			else if (Opcodes[op] == MULS) MULS_Disasm(info);
			else if (Opcodes[op] == DIVU) DIVU_Disasm(info);
			else if (Opcodes[op] == DIVS) DIVS_Disasm(info);

			else if (Opcodes[op] == MOVEtSR) MOVEtSR_Disasm(info);
			else if (Opcodes[op] == MOVEfSR) MOVEfSR_Disasm(info);
			else if (Opcodes[op] == MOVEUSP) MOVEUSP_Disasm(info);
			else if (Opcodes[op] == ANDI_SR) ANDI_SR_Disasm(info);
			else if (Opcodes[op] == EORI_SR) EORI_SR_Disasm(info);
			else if (Opcodes[op] == ORI_SR) ORI_SR_Disasm(info);
			else if (Opcodes[op] == MOVECCR) MOVECCR_Disasm(info);
			else if (Opcodes[op] == TRAP) TRAP_Disasm(info);

			var sb = new StringBuilder();
			for (int p = info.PC; p < info.PC + info.Length; p++)
				sb.AppendFormat("{0:X2}", ReadByte(p));
			info.RawBytes = sb.ToString();

			return info;
		}
Exemplo n.º 53
0
		void CMPM_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int axReg = (op >> 9) & 7;
			int size = (op >> 6) & 3;
			int ayReg = (op >> 0) & 7;

			switch (size)
			{
				case 0: info.Mnemonic = "cmpm.b"; break;
				case 1: info.Mnemonic = "cmpm.w"; break;
				case 2: info.Mnemonic = "cmpm.l"; break;
			}
			info.Args = string.Format("(A{0})+, (A{1})+", ayReg, axReg);
			info.Length = pc - info.PC;
		}
Exemplo n.º 54
0
		void SWAP_Disasm(DisassemblyInfo info)
		{
			int reg = op & 7;
			info.Mnemonic = "swap";
			info.Args = "D" + reg;
		}
Exemplo n.º 55
0
		void SUBA_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;

			int aReg = (op >> 9) & 7;
			int size = (op >> 8) & 1;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			info.Mnemonic = (size == 0) ? "suba.w" : "suba.l";
			info.Args = DisassembleValue(mode, reg, (size == 0) ? 2 : 4, ref pc) + ", A" + aReg;

			info.Length = pc - info.PC;
		}
Exemplo n.º 56
0
		void ANDI_Disasm(DisassemblyInfo info)
		{
			int size = ((op >> 6) & 0x03);
			int dstMode = ((op >> 3) & 0x07);
			int dstReg = (op & 0x07);

			int pc = info.PC + 2;

			switch (size)
			{
				case 0: // Byte
					{
						info.Mnemonic = "andi.b";
						sbyte imm = (sbyte)ReadWord(pc); pc += 2;
						info.Args = string.Format("${0:X}, ", imm);
						info.Args += DisassembleValue(dstMode, dstReg, 1, ref pc);
						break;
					}
				case 1: // Word
					{
						info.Mnemonic = "andi.w";
						short imm = ReadWord(pc); pc += 2;
						info.Args = string.Format("${0:X}, ", imm);
						info.Args += DisassembleValue(dstMode, dstReg, 2, ref pc);
						break;
					}
				case 2: // Long
					{
						info.Mnemonic = "andi.l";
						int imm = ReadLong(pc); pc += 4;
						info.Args = string.Format("${0:X}, ", imm);
						info.Args += DisassembleValue(dstMode, dstReg, 4, ref pc);
						break;
					}
			}

			info.Length = pc - info.PC;
		}
Exemplo n.º 57
0
		void RTE_Disasm(DisassemblyInfo info)
		{
			info.Mnemonic = "rte";
			info.Args = "";
		}
Exemplo n.º 58
0
		void ORI_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int size = (op >> 6) & 3;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;

			switch (size)
			{
				case 0: // byte
					{
						info.Mnemonic = "ori.b";
						sbyte immed = (sbyte)ReadWord(pc); pc += 2;
						info.Args = String.Format("${0:X}, {1}", immed, DisassembleValue(mode, reg, 1, ref pc));
						break;
					}
				case 1: // word
					{
						info.Mnemonic = "ori.w";
						short immed = ReadWord(pc); pc += 2;
						info.Args = String.Format("${0:X}, {1}", immed, DisassembleValue(mode, reg, 2, ref pc));
						break;
					}
				case 2: // long
					{
						info.Mnemonic = "ori.l";
						int immed = ReadLong(pc); pc += 4;
						info.Args = String.Format("${0:X}, {1}", immed, DisassembleValue(mode, reg, 4, ref pc));
						break;
					}
			}

			info.Length = pc - info.PC;
		}
Exemplo n.º 59
0
		void CMPI_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int size = (op >> 6) & 3;
			int mode = (op >> 3) & 7;
			int reg = (op >> 0) & 7;
			int immediate;

			switch (size)
			{
				case 0:
					immediate = (byte)ReadWord(pc); pc += 2;
					info.Mnemonic = "cmpi.b";
					info.Args = String.Format("${0:X}, {1}", immediate, DisassembleValue(mode, reg, 1, ref pc));
					break;
				case 1:
					immediate = ReadWord(pc); pc += 2;
					info.Mnemonic = "cmpi.w";
					info.Args = String.Format("${0:X}, {1}", immediate, DisassembleValue(mode, reg, 2, ref pc));
					break;
				case 2:
					immediate = ReadLong(pc); pc += 4;
					info.Mnemonic = "cmpi.l";
					info.Args = String.Format("${0:X}, {1}", immediate, DisassembleValue(mode, reg, 4, ref pc));
					break;
			}
			info.Length = pc - info.PC;
		}
Exemplo n.º 60
0
		void BSETi_Disasm(DisassemblyInfo info)
		{
			int pc = info.PC + 2;
			int bit = ReadWord(pc); pc += 2;
			int mode = (op >> 3) & 7;
			int reg = op & 7;

			info.Mnemonic = "bset";
			info.Args = String.Format("#${0:X}, {1}", bit, DisassembleValue(mode, reg, 1, ref pc));
			info.Length = pc - info.PC;
		}