예제 #1
0
        private void Initialize(string arg, Chip chip)
        {
            if (!int.TryParse(arg, out var inc))
            {
                if (!Enum.TryParse(arg.ToUpper(), out Register port))
                {
                    throw new InstructionValidationException("Provided value is not an integer or a valid port.");
                }

                if (!chip.HasPort(port))
                {
                    throw new InstructionValidationException("The specified port is not valid.");
                }

                Register = port;
                IsInt    = false;
                return;
            }

            if (inc > Constants.INT_MAX || inc < Constants.INT_MIN)
            {
                throw new InstructionValidationException("Provided integer is out of bounds.");
            }

            Int   = inc;
            IsInt = true;
        }
예제 #2
0
        public RArg(string arg, Chip chip)
        {
            if (!Enum.TryParse(arg.ToUpper(), out Register port))
            {
                throw new InstructionValidationException("Provided value is not a valid port.");
            }

            if (!chip.HasPort(port))
            {
                throw new InstructionValidationException("The specified port is not valid.");
            }

            Register = port;
        }