本文整理汇总了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();
}