public void Process(SoftwareProgram memory)
        {
            long firstValue  = _firstRetrieve.GetValue(ref memory);
            long secondValue = _secondRetrieve.GetValue(ref memory);

            _thirdStore.StoreValue(ref memory, firstValue + secondValue);
        }
Exemple #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);
        }
Exemple #3
0
 public void Process(SoftwareProgram memory)
 {
     if (_first.GetValue(ref memory) == 0)
     {
         _instructionPointer = Convert.ToInt32(_second.GetValue(ref memory));
     }
     else
     {
         _instructionPointer += 3;
     }
 }
Exemple #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);
            }
        }
        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]);
        }
Exemple #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;
            }
        }
Exemple #7
0
 public long GetOutput(ref SoftwareProgram memory)
 {
     return(_first.GetValue(ref memory));
 }
Exemple #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));
        }
Exemple #10
0
 public void Process(SoftwareProgram memory)
 {
     _first.StoreValue(ref memory, _input);
 }