public static MemoryModel GetInstance() { if (instance == null) { instance = new MemoryModel(addressBusLength); } return(instance); }
public static byte[] GetMemoryWord(this MemoryModel memory, uint physicalAddress) { if (physicalAddress >= memory.GetMemoryLength - 1) { throw new ArgumentException($"Address is out of range memory block."); } return(new[] { memory.GetMemoryCell(physicalAddress), memory.GetMemoryCell(physicalAddress + 1) }); //Little endian }
public string GetView(UInt16 segmentAddress, UInt16 offset, UInt16 lines = 8) { StringBuilder viewBuilder = new StringBuilder(); byte cell; Memory memory = MemoryModel.GetInstance(); uint addressIterator = (uint)((segmentAddress << 4) + offset); currentViewAddress = addressIterator; for (UInt16 it = 0; it < lines; it++, offset += 16) { viewBuilder.Append(segmentAddress.ToString("X").PadLeft(4, '0') + ":" + offset.ToString("X").PadLeft(4, '0') + " "); for (uint singleByte = 0; singleByte < 16; singleByte++, addressIterator++) { cell = memory.GetMemoryCell(addressIterator); viewBuilder.Append(" "); viewBuilder.Append(cell.ToString("X").PadLeft(2, '0')); viewBuilder.Append(" "); } viewBuilder.Append("\n"); } return(viewBuilder.ToString()); }
public static void SetMemoryWord(this MemoryModel memory, uint physicalAddress, UInt16 value) { byte[] word = BitConverter.GetBytes(value); memory.SetMemoryWord(physicalAddress, word); }