当前位置: 首页>>代码示例>>C#>>正文


C# IMemory.Read方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:20,代码来源:LeaOperator.cs

示例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;
        }
开发者ID:shilrobot,项目名称:emu6502,代码行数:85,代码来源:Disasm.cs

示例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();
 }
开发者ID:shilrobot,项目名称:emu6502,代码行数:21,代码来源:Disasm.cs


注:本文中的IMemory.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。