コード例 #1
0
        public void Process(SoftwareProgram memory)
        {
            long firstValue  = _firstRetrieve.GetValue(ref memory);
            long secondValue = _secondRetrieve.GetValue(ref memory);

            _thirdStore.StoreValue(ref memory, firstValue + secondValue);
        }
コード例 #2
0
        public void Process(SoftwareProgram memory)
        {
            long firstValue  = _first.GetValue(ref memory);
            long secondValue = _second.GetValue(ref memory);

            _third.StoreValue(ref memory, firstValue * secondValue);
        }
コード例 #3
0
 public void Process(SoftwareProgram memory)
 {
     if (_first.GetValue(ref memory) == 0)
     {
         _instructionPointer = Convert.ToInt32(_second.GetValue(ref memory));
     }
     else
     {
         _instructionPointer += 3;
     }
 }
コード例 #4
0
        public void Process(SoftwareProgram memory)
        {
            long firstValue  = _first.GetValue(ref memory);
            long secondValue = _second.GetValue(ref memory);

            if (firstValue < secondValue)
            {
                _third.StoreValue(ref memory, 1);
            }
            else
            {
                _third.StoreValue(ref memory, 0);
            }
        }
コード例 #5
0
        public long GetValue(ref SoftwareProgram memory)
        {
            if (_mode == ParameterMode.Immediate)
            {
                return(memory[_position]);
            }

            if (_mode == ParameterMode.Position)
            {
                return(memory[Convert.ToInt32(memory[_position])]);
            }

            var index = Convert.ToInt32(memory[_position]);

            return(memory[_relativeBase + index]);
        }
コード例 #6
0
        public void StoreValue(ref SoftwareProgram memory, long?value)
        {
            if (value == null)
            {
                return;
            }

            if (_mode == ParameterMode.Immediate)
            {
                memory[Position] = (int)value;
            }

            if (_mode == ParameterMode.Position)
            {
                memory[Convert.ToInt32(memory[Position])] = (long)value;
            }

            if (_mode == ParameterMode.Relative)
            {
                var index = Convert.ToInt32(memory[Position]);
                memory[_relativeBase + index] = (long)value;
            }
        }
コード例 #7
0
 public long GetOutput(ref SoftwareProgram memory)
 {
     return(_first.GetValue(ref memory));
 }
コード例 #8
0
 public void Process(SoftwareProgram memory)
 {
     // no action required
 }
        public int GetRelativeBase(ref SoftwareProgram memory)
        {
            var value = _first.GetValue(ref memory);

            return(_relativeBase + Convert.ToInt32(value));
        }
コード例 #10
0
 public void Process(SoftwareProgram memory)
 {
     _first.StoreValue(ref memory, _input);
 }