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


C++ Memory::Read方法代码示例

本文整理汇总了C++中Memory::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ Memory::Read方法的具体用法?C++ Memory::Read怎么用?C++ Memory::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memory的用法示例。


在下文中一共展示了Memory::Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnCommand


//.........这里部分代码省略.........
    instructionLimit = parameters[0]->number;
    while (instructionCount != instructionLimit)
    {
      cpu.Tick();
    }
  }
  else if (!command.compare(runCmd))
  {
    instructionCount = 0;
    instructionLimit = 0;
    breakCount = 0;
    breakLimit = 1;
    while (breakCount < breakLimit)
    {
      cpu.Tick();
    }
  }
  else if (!command.compare(goCmd))
  {
    instructionCount = 0;
    instructionLimit = 0;
    breakCount = 0;
    breakLimit = parameters[0]->number;
    while (breakCount != breakLimit)
    {
      cpu.Tick();
    }
  }
  else if (!command.compare(loadCmd))
  {
    std::string hex = "hex";
    std::string sym = "rst";
    std::string &fileName = parameters[0]->string;

    if (fileName.rfind(hex) + hex.length() == fileName.length())
    {
      int bytes = cpu.alu.flash.ParseHex(parameters[0]->string);
      printw("Read %d bytes from %s\n", bytes, fileName.c_str());
    }
    else if (fileName.rfind(sym) + sym.length() == fileName.length())
    {
      int symbols = SymbolTable::GetInstance().ParseFile(fileName);
      printw("Found %d symbols in %s\n", symbols, fileName.c_str());
    }
    else
    {
      printw("Unknown file:%s\n", fileName.c_str());
    }
  }
  else if (!command.compare(disassembleCmd))
  {
    std::uint16_t address = parameters[0]->number;
    std::uint16_t length = parameters[1]->number;
    std::uint16_t limit = address + length;
    while (address <= limit)
    {
      printw("%x %s\n", address, cpu.alu.Disassemble(address).c_str());
      address += 1 + cpu.alu.GetOperands(address);
    }
  }
  else if (!command.compare(flashCmd) || !command.compare(iramCmd))
  {
    std::uint16_t address = parameters[0]->number;
    std::uint16_t length = parameters[1]->number;
    bool newline = false;
    Memory *mem;
    if (!command.compare(flashCmd))
    {
      mem = &cpu.alu.flash;
    }
    else
    {
      mem = &cpu.alu.iram;
    }
    for (int i = 0; i < length; i++)
    {
      const int itemsPerLine = 16;
      if (i % itemsPerLine == 0)
      {
        printw("%4.4x ", address + i);
      }
      printw("%2.2x", mem->Read(address + i));
      if (i % itemsPerLine == itemsPerLine - 1)
      {
        printw("\n");
        newline = true;
      }
      else
      {
        printw(" ");
        newline = false;
      }
    }
    if (!newline)
    {
      printw("\n");
    }
  }
  refresh();
}
开发者ID:andersdellien,项目名称:8051-sim,代码行数:101,代码来源:command.cpp


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