本文整理汇总了C#中IMemory.Read方法的典型用法代码示例。如果您正苦于以下问题:C# IMemory.Read方法的具体用法?C# IMemory.Read怎么用?C# IMemory.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMemory
的用法示例。
在下文中一共展示了IMemory.Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override IntPtr Execute(IMemory memory)
{
switch (Type)
{
case LeaType.Byte:
return (IntPtr)memory.Read<byte>(Target);
case LeaType.Word:
return (IntPtr)memory.Read<ushort>(Target);
case LeaType.Dword:
return (IntPtr)memory.Read<uint>(Target);
case LeaType.Pointer:
return memory.Read<IntPtr>(Target);
default:
throw new PatternException("Unknown LeaType");
}
}
示例2: DisassembleOne
public static bool DisassembleOne(IMemory mem, int addr, int count, StringBuilder sb, out int bytesConsumed)
{
bytesConsumed = 0;
if (mem == null)
throw new ArgumentNullException("data");
if (sb == null)
throw new ArgumentNullException("sb");
if (addr < 0 ||
addr > 0xFFFF)
throw new ArgumentOutOfRangeException("addr");
byte opcode = mem.Read(addr);
if (opNames[opcode] == null)
return false;
AddressMode mode = addrModes[opcode];
int byteCount = byteCounts[(int)mode];
if (count < byteCount)
return false;
byte lo = 0, hi = 0;
if (byteCount >= 2)
lo = mem.Read(addr + 1);
if (byteCount == 3)
hi = mem.Read(addr + 2);
if(byteCount == 3)
sb.AppendFormat("{0:X4} {1:X2} {2:X2} {3:X2} {4}", addr, opcode, lo, hi, opNames[opcode]);
else if (byteCount == 2)
sb.AppendFormat("{0:X4} {1:X2} {2:X2} {3}", addr, opcode, lo, opNames[opcode]);
else if (byteCount == 1)
sb.AppendFormat("{0:X4} {1:X2} {2}", addr, opcode, opNames[opcode]);
switch (mode)
{
case AddressMode.Immediate:
sb.AppendFormat(" #${0:X2}", lo);
break;
case AddressMode.ZeroPage:
sb.AppendFormat(" ${0:X2}", lo);
break;
case AddressMode.ZeroPageIndexedX:
sb.AppendFormat(" ${0:X2},X", lo);
break;
case AddressMode.ZeroPageIndexedY:
sb.AppendFormat(" ${0:X2},Y", lo);
break;
case AddressMode.Accumulator:
//sb.AppendFormat(" A", lo);
break;
case AddressMode.Absolute:
sb.AppendFormat(" ${0:X2}{1:X2}", hi, lo);
break;
case AddressMode.AbsoluteIndexedX:
sb.AppendFormat(" ${0:X2}{1:X2},X", hi, lo);
break;
case AddressMode.AbsoluteIndexedY:
sb.AppendFormat(" ${0:X2}{1:X2},Y", hi, lo);
break;
case AddressMode.Indirect:
sb.AppendFormat(" (${0:X2}{1:X2})", hi, lo);
break;
case AddressMode.IndexedIndirectX:
sb.AppendFormat(" (${0:X2},X)", lo);
break;
case AddressMode.IndirectIndexedY:
sb.AppendFormat(" (${0:X2}),Y", lo);
break;
case AddressMode.Implied:
break;
case AddressMode.Relative:
{
int offset = (lo <= 127) ? lo : lo - 256;
int targetAddr = (addr + 2 + offset) & 0xFFFF;
sb.AppendFormat(" ${0:X4}", targetAddr);
}
break;
}
sb.Append("\r\n");
bytesConsumed = byteCount;
return true;
}
示例3: Disassemble
// TODO: Allow for different "display addreses" versus actual internal addresses to 'data'
public static string Disassemble(IMemory mem, int addr, int count)
{
StringBuilder sb = new StringBuilder();
while (count > 0)
{
int consumed;
if (DisassembleOne(mem, addr, count, sb, out consumed))
{
addr += consumed;
count -= consumed;
}
else
{
DB(sb, addr, mem.Read(addr));
++addr;
--count;
}
}
return sb.ToString();
}