Exemplo n.º 1
0
        public Instruction(IWordStream stream, ulong address)
        {
            var bits = new BitStream(stream.ReadWord(address++));

            this.Length     = 1;
            this.Code       = bits.ReadU8(8);
            this.Definition = InstructionDefinition.Find(this.Code);

            if (this.Definition.ParameterCount > 0)
            {
                this.Parameter1 = this.DecodeParameter(stream, ref address, bits);
            }
            if (this.Definition.ParameterCount > 1)
            {
                this.Parameter2 = this.DecodeParameter(stream, ref address, bits);
            }
            if (this.Definition.ParameterCount > 2)
            {
                this.Parameter3 = this.DecodeParameter(stream, ref address, bits);
            }

            bits.Advance((3 - this.Definition.ParameterCount) * 8);

            if (bits.ReadU1())
            {
                this.ConditionalZero      = bits.ReadU1();
                this.ConditionalParameter = this.DecodeParameter(stream, ref address, bits);
            }
        }
Exemplo n.º 2
0
        public Instruction(byte code, IList <Parameter> parameters, Parameter conditionalParameter, bool conditionalZero)
        {
            this.Code   = code;
            this.Length = (byte)(1 + (conditionalParameter?.Length ?? 0));
            this.ConditionalParameter = conditionalParameter;
            this.ConditionalZero      = conditionalZero;
            this.Definition           = InstructionDefinition.Find(this.Code);

            if (this.Definition.ParameterCount >= 1)
            {
                this.Parameter1 = parameters[0];
                this.Length    += this.Parameter1.Length;
            }

            if (this.Definition.ParameterCount >= 2)
            {
                this.Parameter2 = parameters[1];
                this.Length    += this.Parameter2.Length;
            }

            if (this.Definition.ParameterCount >= 3)
            {
                this.Parameter3 = parameters[2];
                this.Length    += this.Parameter3.Length;
            }
        }