public ImageWriter CreateImageWriter(IProcessorArchitecture arch, Address addr) { if (!SegmentMap.TryFindSegment(addr, out var segment)) { throw new ArgumentException(string.Format("The address {0} is invalid.", addr)); } return(arch.CreateImageWriter(segment.MemoryArea, addr)); }
public void Sift_16Bit() { var writer = arch.CreateImageWriter(mem, mem.BaseAddress); int iLastByte = 0; int lastLen = 0; while (iLastByte >= 0 && DecrementCount()) { var instr = Dasm(); processInstr(mem.Bytes, instr); if (rdr.Offset != lastLen) { iLastByte = (int)rdr.Offset - 1; lastLen = (int)rdr.Offset; } if (iLastByte >= maxInstrLength) { iLastByte = maxInstrLength - 1; } rdr.Offset = iLastByte & ~1; var val = rdr.ReadUInt16() + 1u; while (val >= 0x10000) { writer.Position = iLastByte & ~1; writer.WriteUInt16(0); iLastByte -= 2; if (iLastByte < 0) { return; } rdr.Offset = iLastByte & ~1; val = rdr.ReadUInt16() + 1u; } writer.Position = iLastByte & ~1; writer.WriteUInt16((ushort)val); } }