// address in byte, not word public void Write(uint address, Word32b newValue) { _logger.LogChange(address, this.Read(address), newValue); int offset = (int)address % 4; int index = (int)address / 4; int currentOffset = offset; int currentIndex = index; int i; for (i = 0; i < 4; i++) { byte[] word = BitConverter.GetBytes(this.Memory[currentIndex]); word[currentOffset] = newValue.ToBytes()[i]; this.Memory[currentIndex] = BitConverter.ToUInt32(word); currentOffset++; if (currentOffset >= 4) { currentOffset = 0; currentIndex++; } } }
// address in byte, not word public void Write(uint address, Word32b newValue) { _logger.LogChange(address, this.Read(address), newValue); uint i; for (i = 0; i < 4; i++) { this.Memory[address + i] = newValue.ToBytes()[i]; } }
public void Write(RegisterType address, Word32b newValue) { _logger.LogChange(address, this.Read(address), newValue); this.Registers[address] = newValue; }