/// <summary> /// Saves the current work segment into the memory image. /// </summary> public void FlushSegment() { if (MemoryBlocks.Count > 0) { // unify the record data blocks into a single segment var memseg = new byte[SegmentEndAddress + 1 - SegmentStartAddress]; uint reladdr = 0; for (int i = 0; i < MemoryBlocks.Count; i++) { MemoryBlocks[i].CopyTo(memseg, reladdr); reladdr += (uint)MemoryBlocks[i].Length; } // add it to the image, and empty the context Memory.TryAddSegment(new Segment(SegmentStartAddress, memseg)); MemoryBlocks.Clear(); } }