public SubInstruction GetSubInstruction(ParsedInstruction ParsedInstruction)
            {
                switch (this.Type)
                {
                case InstructionType.Normal:
                    return(this.SubInstructions[0]);

                case InstructionType.WR:
                    return(this.SubInstructions[(ParsedInstruction.ZCRI & ParsedInstruction.WriteResultFlag) == ParsedInstruction.WriteResultFlag ? 0 : 1]);

                case InstructionType.Hub:
                    return(this.SubInstructions[ParsedInstruction.SRC & 0x7]);

                case InstructionType.Jump:
                    int num = ParsedInstruction.ZCRI & 0x3;
                    if (num <= 1)
                    {
                        num = 0;
                        if (ParsedInstruction.SRC == 0)
                        {
                            num = 1;
                        }
                    }
                    return(this.SubInstructions[num]);
                }
                throw new Exception("Unknown Instruction Type: " + this.Type.ToString());
            }
        public void Address()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_FF_AA_AA);

            Assert.AreEqual((ushort)0xAA_AA, instruction.Address);
        }
        public void Register2()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_F4_00_00);

            Assert.AreEqual((byte)0x05, instruction.Register2);
        }
        public void Width()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFE_00_00_00);

            Assert.AreEqual((byte)0x02, instruction.Width);
        }
        public void OpCode()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xA8_00_00_00);

            Assert.AreEqual((byte)0x2A, instruction.Opcode);
        }
        public void Offset()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_FF_00_AA);

            Assert.AreEqual((short)-86, instruction.Offset);
        }
        public void Immediate()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_FF_FF_AA);

            Assert.AreEqual((byte)0xAA, instruction.Immediate);
        }
        public void Register1_Dirty()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_A0_00_00);
            _ = instruction.Register1;
            instruction.LoadRawInstruction(0xFF_40_00_00);

            Assert.AreEqual((byte)0x02, instruction.Register1);
        }
        public void Width_Dirty()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFE_00_00_00);
            _ = instruction.Width;
            instruction.LoadRawInstruction(0xFD_00_00_00);

            Assert.AreEqual((byte)0x01, instruction.Width);
        }
        public void Offset_Dirty()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_FF_00_AA);
            _ = instruction.Offset;
            instruction.LoadRawInstruction(0xFF_FF_00_55);

            Assert.AreEqual((short)85, instruction.Offset);
        }
        public void Immediate_Dirty()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_FF_FF_AA);
            _ = instruction.Immediate;
            instruction.LoadRawInstruction(0xFF_FF_FF_55);

            Assert.AreEqual((byte)0x55, instruction.Immediate);
        }
        public void Address_Dirty()
        {
            var instruction = new ParsedInstruction();

            instruction.LoadRawInstruction(0xFF_FF_AA_AA);
            _ = instruction.Address;
            instruction.LoadRawInstruction(0xFF_FF_55_55);

            Assert.AreEqual((ushort)0x55_55, instruction.Address);
        }
Example #13
0
        public static Propeller.Assembly.SubInstruction GetSubInstruction(Propeller.Assembly.Instruction SourceInstruction, ParsedInstruction ParsedInstruction)
        {
            switch (SourceInstruction.Type)
            {
            case Propeller.Assembly.InstructionType.Normal:
                return(SourceInstruction.SubInstructions[0]);

            case Propeller.Assembly.InstructionType.WR:
                return(SourceInstruction.SubInstructions[(ParsedInstruction.ZCRI & ParsedInstruction.WriteResultFlag) == ParsedInstruction.WriteResultFlag ? 0 : 1]);

            case Propeller.Assembly.InstructionType.Hub:
                return(SourceInstruction.SubInstructions[ParsedInstruction.SRC & 0x7]);

            case Propeller.Assembly.InstructionType.Jump:
                int num = ParsedInstruction.ZCRI & 0x3;
                if (num <= 1)
                {
                    num = 0;
                    if (ParsedInstruction.SRC == 0)
                    {
                        num = 1;
                    }
                }
                return(SourceInstruction.SubInstructions[num]);
            }
            throw new Exception("Uknown Instruction Type: " + SourceInstruction.Type.ToString());
        }
Example #14
0
 public void Execute(Chip8State state, ParsedInstruction instruction) =>
 CallTable[instruction.Instruction](state, instruction);