public void ClearMemoryTest(int programCounter)
        {
            var instruction = new SetMemoryInstruction();

            var instructionModel = new InstructionModel
            {
                Type = instruction.Type,
                Data = 0
            };

            var context = new InstructionExecutionContext(new bool[1], programCounter, instructionModel);

            var result = instruction.Execute(context);

            Assert.True(context.Memory[0]);

            Assert.Equal(programCounter + 1, result.ProgramCounter);
        }
Beispiel #2
0
            private void ExecuteSetMemoryInstruction(SetMemoryInstruction instruction)
            {
                var memoryLocation = instruction.Address;
                var value          = instruction.Value;
                var locations      = new List <long>();

                if (_version == 1)
                {
                    value = ApplyMaskToValue(value);
                    locations.Add(memoryLocation);
                }

                if (_version == 2)
                {
                    locations.AddRange(ApplyMaskToMemoryLocation(memoryLocation));
                }

                foreach (var location in locations)
                {
                    Memory[location] = value;
                }
            }