Started preliminary work on new debugger
This commit is contained in:
parent
c81d2dcfea
commit
0fecd6f3d1
35 changed files with 607 additions and 1608 deletions
|
|
@ -50,7 +50,6 @@ list(APPEND DEBUGGER_SOURCE_FILES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/debugger/debugger_main.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/debugger/debugger_main.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/debugger/DisassemblyLoader.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/debugger/DisassemblyLoader.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/debugger/Debugger.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/debugger/Debugger.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/debugger/DebuggerNew.cpp
|
|
||||||
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/hardware/VirtualCPU.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/hardware/VirtualCPU.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/hardware/VirtualRAM.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/hardware/VirtualRAM.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
## --
|
## --
|
||||||
## -- This file is automatically generated by the DragonAssembler (version 0.4.1649)
|
## -- This file is automatically generated by the DragonAssembler (version 0.4.1650)
|
||||||
## -- Please do not modify this file in any way.
|
## -- Please do not modify this file in any way.
|
||||||
## --
|
## --
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
namespace code
|
namespace code
|
||||||
{
|
{
|
||||||
ostd::ByteStream Assembler::assembleFromFile(ostd::String fileName)
|
ostd::ByteStream Assembler::assembleFromFile(String fileName)
|
||||||
{
|
{
|
||||||
m_rawSource = "";
|
m_rawSource = "";
|
||||||
m_code.clear();
|
m_code.clear();
|
||||||
|
|
@ -66,7 +66,7 @@ namespace dragon
|
||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::ByteStream Assembler::assembleToFile(ostd::String sourceFileName, ostd::String binaryFileName)
|
ostd::ByteStream Assembler::assembleToFile(String sourceFileName, String binaryFileName)
|
||||||
{
|
{
|
||||||
assembleFromFile(sourceFileName);
|
assembleFromFile(sourceFileName);
|
||||||
if (m_code.size() == 0) return { };
|
if (m_code.size() == 0) return { };
|
||||||
|
|
@ -74,7 +74,7 @@ namespace dragon
|
||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::ByteStream Assembler::assembleToVirtualDisk(ostd::String fileName, hw::VirtualHardDrive& vhdd, uint32_t address)
|
ostd::ByteStream Assembler::assembleToVirtualDisk(String fileName, hw::VirtualHardDrive& vhdd, uint32_t address)
|
||||||
{
|
{
|
||||||
assembleFromFile(fileName);
|
assembleFromFile(fileName);
|
||||||
if (m_code.size() == 0) return { };
|
if (m_code.size() == 0) return { };
|
||||||
|
|
@ -83,10 +83,10 @@ namespace dragon
|
||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Assembler::saveDisassemblyToFile(ostd::String fileName)
|
bool Assembler::saveDisassemblyToFile(String fileName)
|
||||||
{
|
{
|
||||||
if (m_code.size() == 0 || m_disassembly.size() == 0) return false;
|
if (m_code.size() == 0 || m_disassembly.size() == 0) return false;
|
||||||
ostd::String header_string = "{ DRAGON_DEBUG_DISASSEMBLY }";
|
String header_string = "{ DRAGON_DEBUG_DISASSEMBLY }";
|
||||||
uint64_t da_size = 0;
|
uint64_t da_size = 0;
|
||||||
da_size += (header_string.len() + 1) * ostd::tTypeSize::BYTE;
|
da_size += (header_string.len() + 1) * ostd::tTypeSize::BYTE;
|
||||||
da_size += m_disassembly.size() * ostd::tTypeSize::DWORD; //Addresses
|
da_size += m_disassembly.size() * ostd::tTypeSize::DWORD; //Addresses
|
||||||
|
|
@ -122,11 +122,11 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Yellow).p("Symbols:").nl();
|
out.fg(ostd::ConsoleColors::Yellow).p("Symbols:").nl();
|
||||||
for (auto& symbol : m_symbolTable)
|
for (auto& symbol : m_symbolTable)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Red).p(ostd::String::getHexStr(symbol.second.address, true, 2));
|
out.fg(ostd::ConsoleColors::Red).p(String::getHexStr(symbol.second.address, true, 2));
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" ").p(symbol.first);
|
out.fg(ostd::ConsoleColors::Magenta).p(" ").p(symbol.first);
|
||||||
out.fg(ostd::ConsoleColors::Blue).nl().p(" ");
|
out.fg(ostd::ConsoleColors::Blue).nl().p(" ");
|
||||||
for (auto& b : symbol.second.bytes)
|
for (auto& b : symbol.second.bytes)
|
||||||
out.p(ostd::String::getHexStr(b, false, 1)).p(".");
|
out.p(String::getHexStr(b, false, 1)).p(".");
|
||||||
out.nl();
|
out.nl();
|
||||||
}
|
}
|
||||||
if (m_symbolTable.size() > 0)
|
if (m_symbolTable.size() > 0)
|
||||||
|
|
@ -137,7 +137,7 @@ namespace dragon
|
||||||
for (auto& label : m_labelTable)
|
for (auto& label : m_labelTable)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(label.first.new_fixedLength(symbol_len));
|
out.fg(ostd::ConsoleColors::Magenta).p(label.first.new_fixedLength(symbol_len));
|
||||||
out.fg(ostd::ConsoleColors::Red).p(ostd::String::getHexStr(label.second.address, true, 2)).nl();
|
out.fg(ostd::ConsoleColors::Red).p(String::getHexStr(label.second.address, true, 2)).nl();
|
||||||
}
|
}
|
||||||
if (m_labelTable.size() > 0)
|
if (m_labelTable.size() > 0)
|
||||||
out.nl();
|
out.nl();
|
||||||
|
|
@ -156,12 +156,12 @@ namespace dragon
|
||||||
if (verbose_level == 0 || verbose_level == 1)
|
if (verbose_level == 0 || verbose_level == 1)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Yellow).p("Program data:").nl();
|
out.fg(ostd::ConsoleColors::Yellow).p("Program data:").nl();
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(ostd::String("Fixed Size: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p((int)m_fixedSize).p(" bytes").nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(String("Fixed Size: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p((int)m_fixedSize).p(" bytes").nl();
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(ostd::String("Program Size:").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p((int)m_programSize).p(" bytes").nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(String("Program Size:").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p((int)m_programSize).p(" bytes").nl();
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(ostd::String("Data Size: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p((int)m_dataSize).p(" bytes").nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(String("Data Size: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p((int)m_dataSize).p(" bytes").nl();
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(ostd::String("Fixed Fill: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(m_fixedFillValue, true, 1)).nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(String("Fixed Fill: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(String::getHexStr(m_fixedFillValue, true, 1)).nl();
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(ostd::String("Load Address:").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(m_loadAddress, true, 2)).nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(String("Load Address:").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(String::getHexStr(m_loadAddress, true, 2)).nl();
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(ostd::String("Entry Point: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(m_dataSize + m_loadAddress + 3, true, 2)).nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(String("Entry Point: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(String::getHexStr(m_dataSize + m_loadAddress + 3, true, 2)).nl();
|
||||||
}
|
}
|
||||||
|
|
||||||
out.nl();
|
out.nl();
|
||||||
|
|
@ -197,8 +197,8 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::removeComments(void)
|
void Assembler::removeComments(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
lineEdit = line;
|
lineEdit = line;
|
||||||
|
|
@ -214,7 +214,7 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::replaceDefines(void)
|
void Assembler::replaceDefines(void)
|
||||||
{
|
{
|
||||||
auto listContainsDefine = [](const std::vector<tDefine>& list, const ostd::String& name) -> bool {
|
auto listContainsDefine = [](const std::vector<tDefine>& list, const String& name) -> bool {
|
||||||
for (auto& def : list)
|
for (auto& def : list)
|
||||||
{
|
{
|
||||||
if (def.name == name)
|
if (def.name == name)
|
||||||
|
|
@ -222,19 +222,19 @@ namespace dragon
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
// auto exportExists = [](const std::unordered_map<ostd::String, tExportSpec>& exports, const ostd::String& name) -> bool {
|
// auto exportExists = [](const std::unordered_map<String, tExportSpec>& exports, const String& name) -> bool {
|
||||||
// return exports.count(name) > 0;
|
// return exports.count(name) > 0;
|
||||||
// };
|
// };
|
||||||
std::vector<tDefine> defines;
|
std::vector<tDefine> defines;
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
ostd::String tmpLineEdit;
|
String tmpLineEdit;
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
lineEdit = line;
|
lineEdit = line;
|
||||||
lineEdit.trim();
|
lineEdit.trim();
|
||||||
tmpLineEdit = lineEdit;
|
tmpLineEdit = lineEdit;
|
||||||
// ostd::String export_name = "";
|
// String export_name = "";
|
||||||
// if (tmpLineEdit.toLower().startsWith("@export_comment "))
|
// if (tmpLineEdit.toLower().startsWith("@export_comment "))
|
||||||
// {
|
// {
|
||||||
// lineEdit.substr(16).trim();
|
// lineEdit.substr(16).trim();
|
||||||
|
|
@ -277,8 +277,8 @@ namespace dragon
|
||||||
std::cout << "Invalid @define directive: " << line << "\n";
|
std::cout << "Invalid @define directive: " << line << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ostd::String define_name = lineEdit.new_substr(0, lineEdit.indexOf(" ")).trim();
|
String define_name = lineEdit.new_substr(0, lineEdit.indexOf(" ")).trim();
|
||||||
ostd::String define_value = lineEdit.new_substr(lineEdit.indexOf(" ") + 1).trim();
|
String define_value = lineEdit.new_substr(lineEdit.indexOf(" ") + 1).trim();
|
||||||
if (listContainsDefine(defines, define_name))
|
if (listContainsDefine(defines, define_name))
|
||||||
{
|
{
|
||||||
std::cout << "Redefinition of @define value: " << line << "\n";
|
std::cout << "Redefinition of @define value: " << line << "\n";
|
||||||
|
|
@ -300,7 +300,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
for (auto& line : newLines)
|
for (auto& line : newLines)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
for (int32_t i = defines.size() - 1; i >= 0; i--)
|
for (int32_t i = defines.size() - 1; i >= 0; i--)
|
||||||
lineEdit.replaceAll(defines[i].name, defines[i].value.new_trim());
|
lineEdit.replaceAll(defines[i].name, defines[i].value.new_trim());
|
||||||
line = lineEdit;
|
line = lineEdit;
|
||||||
|
|
@ -319,11 +319,11 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::replaceGroupDefines(void)
|
void Assembler::replaceGroupDefines(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
bool in_group = false;
|
bool in_group = false;
|
||||||
ostd::String group_name = "";
|
String group_name = "";
|
||||||
ostd::String export_name = "";
|
String export_name = "";
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
lineEdit = line;
|
lineEdit = line;
|
||||||
|
|
@ -376,7 +376,7 @@ namespace dragon
|
||||||
std::cout << "Invalid definition inside group: " << line << "\n";
|
std::cout << "Invalid definition inside group: " << line << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ostd::String newLine = "@define " + export_name + " ";
|
String newLine = "@define " + export_name + " ";
|
||||||
newLine.add(group_name).add(".").add(lineEdit);
|
newLine.add(group_name).add(".").add(lineEdit);
|
||||||
newLines.push_back(newLine);
|
newLines.push_back(newLine);
|
||||||
}
|
}
|
||||||
|
|
@ -386,10 +386,10 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::parseStructures(void)
|
void Assembler::parseStructures(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
bool in_struct = false;
|
bool in_struct = false;
|
||||||
ostd::String struct_name = "";
|
String struct_name = "";
|
||||||
tStructDefinition struct_def;
|
tStructDefinition struct_def;
|
||||||
int32_t member_index = 0;
|
int32_t member_index = 0;
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
|
|
@ -428,9 +428,9 @@ namespace dragon
|
||||||
struct_def.size += data.data.size();
|
struct_def.size += data.data.size();
|
||||||
std::sort(struct_def.members.begin(), struct_def.members.end());
|
std::sort(struct_def.members.begin(), struct_def.members.end());
|
||||||
m_structDefs.push_back(struct_def);
|
m_structDefs.push_back(struct_def);
|
||||||
ostd::String size_def = "@define ";
|
String size_def = "@define ";
|
||||||
size_def.add(struct_def.name).add(".").add("SIZE").add(" ");
|
size_def.add(struct_def.name).add(".").add("SIZE").add(" ");
|
||||||
size_def.add(ostd::String::getHexStr(struct_def.size, true, 2));
|
size_def.add(String::getHexStr(struct_def.size, true, 2));
|
||||||
newLines.push_back(size_def);
|
newLines.push_back(size_def);
|
||||||
in_struct = false;
|
in_struct = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -445,8 +445,8 @@ namespace dragon
|
||||||
std::cout << "Invalid definition inside struct. Size specification missing: " << line << "\n";
|
std::cout << "Invalid definition inside struct. Size specification missing: " << line << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ostd::String member_name = lineEdit.new_substr(0, lineEdit.indexOf(":")).trim();
|
String member_name = lineEdit.new_substr(0, lineEdit.indexOf(":")).trim();
|
||||||
ostd::String member_data = "";
|
String member_data = "";
|
||||||
lineEdit.substr(lineEdit.indexOf(":") + 1).trim();
|
lineEdit.substr(lineEdit.indexOf(":") + 1).trim();
|
||||||
if (member_name.contains(" "))
|
if (member_name.contains(" "))
|
||||||
{
|
{
|
||||||
|
|
@ -482,7 +482,7 @@ namespace dragon
|
||||||
auto tokens = member_data.tokenize(",");
|
auto tokens = member_data.tokenize(",");
|
||||||
if (tokens.count() == 1)
|
if (tokens.count() == 1)
|
||||||
{
|
{
|
||||||
ostd::String tok = tokens.next();
|
String tok = tokens.next();
|
||||||
if (tok.isNumeric())
|
if (tok.isNumeric())
|
||||||
{
|
{
|
||||||
uint8_t data = (uint8_t)tok.toInt();
|
uint8_t data = (uint8_t)tok.toInt();
|
||||||
|
|
@ -504,7 +504,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
while (tokens.hasNext())
|
while (tokens.hasNext())
|
||||||
{
|
{
|
||||||
ostd::String tok = tokens.next();
|
String tok = tokens.next();
|
||||||
if (tok.isNumeric())
|
if (tok.isNumeric())
|
||||||
{
|
{
|
||||||
uint8_t data = (uint8_t)tok.toInt();
|
uint8_t data = (uint8_t)tok.toInt();
|
||||||
|
|
@ -530,7 +530,7 @@ namespace dragon
|
||||||
// {
|
// {
|
||||||
// std::cout << " " << d.first << " ";
|
// std::cout << " " << d.first << " ";
|
||||||
// for (auto& b : d.second)
|
// for (auto& b : d.second)
|
||||||
// std::cout << ostd::String::getHexStr(b) << " ";
|
// std::cout << String::getHexStr(b) << " ";
|
||||||
// }
|
// }
|
||||||
// std::cout << "\n";
|
// std::cout << "\n";
|
||||||
// }
|
// }
|
||||||
|
|
@ -539,8 +539,8 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::parseStructInstances(void)
|
void Assembler::parseStructInstances(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
for (auto& line : m_rawDataSection)
|
for (auto& line : m_rawDataSection)
|
||||||
{
|
{
|
||||||
lineEdit = line;
|
lineEdit = line;
|
||||||
|
|
@ -549,11 +549,11 @@ namespace dragon
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ostd::String symbolName = lineEdit.new_substr(0, lineEdit.indexOf(" "));
|
String symbolName = lineEdit.new_substr(0, lineEdit.indexOf(" "));
|
||||||
symbolName.trim();
|
symbolName.trim();
|
||||||
lineEdit.substr(lineEdit.indexOf(" ") + 1);
|
lineEdit.substr(lineEdit.indexOf(" ") + 1);
|
||||||
lineEdit.trim();
|
lineEdit.trim();
|
||||||
ostd::String initialization_data = "";
|
String initialization_data = "";
|
||||||
bool has_init_data = false;
|
bool has_init_data = false;
|
||||||
if (lineEdit.startsWith("<") && lineEdit.contains("="))
|
if (lineEdit.startsWith("<") && lineEdit.contains("="))
|
||||||
{
|
{
|
||||||
|
|
@ -579,7 +579,7 @@ namespace dragon
|
||||||
auto tokens = initialization_data.tokenize(",");
|
auto tokens = initialization_data.tokenize(",");
|
||||||
while (tokens.hasNext())
|
while (tokens.hasNext())
|
||||||
{
|
{
|
||||||
ostd::String tok = tokens.next();
|
String tok = tokens.next();
|
||||||
if (!tok.isNumeric())
|
if (!tok.isNumeric())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid initialization data: " << lineEdit << "\n";
|
std::cout << "Invalid initialization data: " << lineEdit << "\n";
|
||||||
|
|
@ -613,14 +613,14 @@ namespace dragon
|
||||||
newLines.push_back("!" + symbolName);
|
newLines.push_back("!" + symbolName);
|
||||||
for (auto& member : struct_def.members)
|
for (auto& member : struct_def.members)
|
||||||
{
|
{
|
||||||
ostd::String newLine = symbolName;
|
String newLine = symbolName;
|
||||||
newLine.add(".").add(member.name).add(" ");
|
newLine.add(".").add(member.name).add(" ");
|
||||||
for (int32_t i = 0; i < member.data.size(); i++, data_index++)
|
for (int32_t i = 0; i < member.data.size(); i++, data_index++)
|
||||||
{
|
{
|
||||||
if (has_init_data)
|
if (has_init_data)
|
||||||
newLine.add(ostd::String::getHexStr(init_data[data_index], true, 2));
|
newLine.add(String::getHexStr(init_data[data_index], true, 2));
|
||||||
else
|
else
|
||||||
newLine.add(ostd::String::getHexStr(member.data[i], true, 2));
|
newLine.add(String::getHexStr(member.data[i], true, 2));
|
||||||
newLine.add(",");
|
newLine.add(",");
|
||||||
}
|
}
|
||||||
newLine.substr(0, newLine.len() - 1);
|
newLine.substr(0, newLine.len() - 1);
|
||||||
|
|
@ -638,8 +638,8 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::parseExportSpecifications(void)
|
void Assembler::parseExportSpecifications(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
lineEdit = line;
|
lineEdit = line;
|
||||||
|
|
@ -654,8 +654,8 @@ namespace dragon
|
||||||
std::cout << "Invalid @export directive: " << line << "\n";
|
std::cout << "Invalid @export directive: " << line << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ostd::String exportName = lineEdit.new_substr(0, lineEdit.indexOf(" ")).trim();
|
String exportName = lineEdit.new_substr(0, lineEdit.indexOf(" ")).trim();
|
||||||
ostd::String exportPath = lineEdit.new_substr(lineEdit.indexOf(" ") + 1).trim();
|
String exportPath = lineEdit.new_substr(lineEdit.indexOf(" ") + 1).trim();
|
||||||
m_exports[exportName] = { exportPath, { } };
|
m_exports[exportName] = { exportPath, { } };
|
||||||
}
|
}
|
||||||
m_lines.clear();
|
m_lines.clear();
|
||||||
|
|
@ -664,13 +664,13 @@ namespace dragon
|
||||||
|
|
||||||
void Assembler::createExports(void)
|
void Assembler::createExports(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
ostd::String lineEdit;
|
String lineEdit;
|
||||||
auto exportExists = [](const std::unordered_map<ostd::String, tExportSpec>& exportList, const ostd::String& exportName) -> bool {
|
auto exportExists = [](const std::unordered_map<String, tExportSpec>& exportList, const String& exportName) -> bool {
|
||||||
return exportList.count(exportName) > 0;
|
return exportList.count(exportName) > 0;
|
||||||
};
|
};
|
||||||
bool export_start = false;
|
bool export_start = false;
|
||||||
ostd::String open_export = "";
|
String open_export = "";
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
lineEdit = line;
|
lineEdit = line;
|
||||||
|
|
@ -688,8 +688,8 @@ namespace dragon
|
||||||
std::cout << "Invalid @export_comment directive: " << line << "\n";
|
std::cout << "Invalid @export_comment directive: " << line << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ostd::String exportName = lineEdit.new_substr(0, lineEdit.indexOf(" ")).trim();
|
String exportName = lineEdit.new_substr(0, lineEdit.indexOf(" ")).trim();
|
||||||
ostd::String exportComment = lineEdit.new_substr(lineEdit.indexOf(" ") + 1).trim();
|
String exportComment = lineEdit.new_substr(lineEdit.indexOf(" ") + 1).trim();
|
||||||
if (!exportExists(m_exports, exportName))
|
if (!exportExists(m_exports, exportName))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid export name in @export_comment directive: " << line << "\n";
|
std::cout << "Invalid export name in @export_comment directive: " << line << "\n";
|
||||||
|
|
@ -701,7 +701,7 @@ namespace dragon
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exportComment.substr(1, exportComment.len() - 1).replaceAll("\\n", "\n");
|
exportComment.substr(1, exportComment.len() - 1).replaceAll("\\n", "\n");
|
||||||
m_exports[exportName].lines.push_back(ostd::String("##").add(exportComment));
|
m_exports[exportName].lines.push_back(String("##").add(exportComment));
|
||||||
}
|
}
|
||||||
else if (lineEdit.startsWith("@raw_export_start "))
|
else if (lineEdit.startsWith("@raw_export_start "))
|
||||||
{
|
{
|
||||||
|
|
@ -748,8 +748,8 @@ namespace dragon
|
||||||
void Assembler::replaceExportBuiltinVars(void)
|
void Assembler::replaceExportBuiltinVars(void)
|
||||||
{
|
{
|
||||||
if (!saveExports) return;
|
if (!saveExports) return;
|
||||||
auto getVersionStr = []() -> ostd::String {
|
auto getVersionStr = []() -> String {
|
||||||
return ostd::String("").add(MAJ_V).add(".").add(MIN_V).add(".").add(BUILD_NR);
|
return String("").add(MAJ_V).add(".").add(MIN_V).add(".").add(BUILD_NR);
|
||||||
};
|
};
|
||||||
for (auto&[name, exportSpec] : m_exports)
|
for (auto&[name, exportSpec] : m_exports)
|
||||||
{
|
{
|
||||||
|
|
@ -790,7 +790,7 @@ namespace dragon
|
||||||
|
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
lineEdit.trim();
|
lineEdit.trim();
|
||||||
if (lineEdit.startsWith(".data"))
|
if (lineEdit.startsWith(".data"))
|
||||||
currentSection = DATA_SECTION;
|
currentSection = DATA_SECTION;
|
||||||
|
|
@ -812,7 +812,7 @@ namespace dragon
|
||||||
std::cout << "Invalid .fixed value: " << lineEdit << "\n";
|
std::cout << "Invalid .fixed value: " << lineEdit << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ostd::String fixedSizeEdit = lineEdit.new_substr(0, lineEdit.indexOf(","));
|
String fixedSizeEdit = lineEdit.new_substr(0, lineEdit.indexOf(","));
|
||||||
fixedSizeEdit.trim();
|
fixedSizeEdit.trim();
|
||||||
lineEdit = lineEdit.substr(lineEdit.indexOf(",") + 1);
|
lineEdit = lineEdit.substr(lineEdit.indexOf(",") + 1);
|
||||||
lineEdit.trim();
|
lineEdit.trim();
|
||||||
|
|
@ -904,9 +904,9 @@ namespace dragon
|
||||||
// std::cout << line << "\n";
|
// std::cout << line << "\n";
|
||||||
for (auto& line : m_rawDataSection)
|
for (auto& line : m_rawDataSection)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
tSymbol symbol;
|
tSymbol symbol;
|
||||||
ostd::String symbolName = "";
|
String symbolName = "";
|
||||||
bool array = false;
|
bool array = false;
|
||||||
if (lineEdit.startsWith("!"))
|
if (lineEdit.startsWith("!"))
|
||||||
{
|
{
|
||||||
|
|
@ -1036,7 +1036,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
for (auto& line : m_rawCodeSection)
|
for (auto& line : m_rawCodeSection)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
uint32_t commaCount = lineEdit.count(",");
|
uint32_t commaCount = lineEdit.count(",");
|
||||||
uint32_t spaceCount = lineEdit.count(" ");
|
uint32_t spaceCount = lineEdit.count(" ");
|
||||||
if (lineEdit.endsWith(":") && commaCount == 0 && spaceCount == 0) //Labels
|
if (lineEdit.endsWith(":") && commaCount == 0 && spaceCount == 0) //Labels
|
||||||
|
|
@ -1051,7 +1051,7 @@ namespace dragon
|
||||||
tDisassemblyLine _disassembly_line;
|
tDisassemblyLine _disassembly_line;
|
||||||
for (auto& line : m_rawCodeSection)
|
for (auto& line : m_rawCodeSection)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
uint32_t commaCount = lineEdit.count(",");
|
uint32_t commaCount = lineEdit.count(",");
|
||||||
uint32_t spaceCount = lineEdit.count(" ");
|
uint32_t spaceCount = lineEdit.count(" ");
|
||||||
if (lineEdit.endsWith(":") && commaCount == 0 && spaceCount == 0) //Labels
|
if (lineEdit.endsWith(":") && commaCount == 0 && spaceCount == 0) //Labels
|
||||||
|
|
@ -1086,7 +1086,7 @@ namespace dragon
|
||||||
else if (commaCount == 0 && spaceCount <= 0) //0 Operands
|
else if (commaCount == 0 && spaceCount <= 0) //0 Operands
|
||||||
{
|
{
|
||||||
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
||||||
ostd::String _tmp_edit(lineEdit);
|
String _tmp_edit(lineEdit);
|
||||||
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
||||||
parseDebugOperands(lineEdit);
|
parseDebugOperands(lineEdit);
|
||||||
else
|
else
|
||||||
|
|
@ -1099,7 +1099,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
||||||
lineEdit = replaceSymbols(lineEdit);
|
lineEdit = replaceSymbols(lineEdit);
|
||||||
ostd::String _tmp_edit(lineEdit);
|
String _tmp_edit(lineEdit);
|
||||||
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
||||||
parseDebugOperands(lineEdit);
|
parseDebugOperands(lineEdit);
|
||||||
else
|
else
|
||||||
|
|
@ -1112,7 +1112,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
||||||
lineEdit = replaceSymbols(lineEdit);
|
lineEdit = replaceSymbols(lineEdit);
|
||||||
ostd::String _tmp_edit(lineEdit);
|
String _tmp_edit(lineEdit);
|
||||||
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
||||||
parseDebugOperands(lineEdit);
|
parseDebugOperands(lineEdit);
|
||||||
else
|
else
|
||||||
|
|
@ -1125,7 +1125,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
|
||||||
lineEdit = replaceSymbols(lineEdit);
|
lineEdit = replaceSymbols(lineEdit);
|
||||||
ostd::String _tmp_edit(lineEdit);
|
String _tmp_edit(lineEdit);
|
||||||
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
if (_tmp_edit.toLower().trim().startsWith("debug_"))
|
||||||
parseDebugOperands(lineEdit);
|
parseDebugOperands(lineEdit);
|
||||||
else
|
else
|
||||||
|
|
@ -1144,31 +1144,31 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Assembler::parseDebugOperands(ostd::String line)
|
void Assembler::parseDebugOperands(String line)
|
||||||
{
|
{
|
||||||
if (!debugMode)
|
if (!debugMode)
|
||||||
return;
|
return;
|
||||||
if (ostd::String(line).toLower().startsWith("debug_break"))
|
if (String(line).toLower().startsWith("debug_break"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::DEBUG_Break);
|
m_code.push_back(data::OpCodes::DEBUG_Break);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ostd::String(line).toLower().startsWith("debug_ram_dump"))
|
else if (String(line).toLower().startsWith("debug_ram_dump"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::DEBUG_DumpRAM);
|
m_code.push_back(data::OpCodes::DEBUG_DumpRAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ostd::String(line).toLower().startsWith("debug_profile_stop"))
|
else if (String(line).toLower().startsWith("debug_profile_stop"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::DEBUG_StopProfile);
|
m_code.push_back(data::OpCodes::DEBUG_StopProfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ostd::String(line).toLower().startsWith("debug_profile_start"))
|
else if (String(line).toLower().startsWith("debug_profile_start"))
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
ostd::String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
||||||
instEdit.trim().toLower();
|
instEdit.trim().toLower();
|
||||||
ostd::String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
||||||
opEdit.trim();
|
opEdit.trim();
|
||||||
int16_t word1 = 0x0000;
|
int16_t word1 = 0x0000;
|
||||||
int16_t word2 = 0x0000;
|
int16_t word2 = 0x0000;
|
||||||
|
|
@ -1200,36 +1200,36 @@ namespace dragon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assembler::parse0Operand(ostd::String line)
|
void Assembler::parse0Operand(String line)
|
||||||
{
|
{
|
||||||
if (ostd::String(line).toLower().startsWith("nop"))
|
if (String(line).toLower().startsWith("nop"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::NoOp);
|
m_code.push_back(data::OpCodes::NoOp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ostd::String(line).toLower().startsWith("ret"))
|
else if (String(line).toLower().startsWith("ret"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::Ret);
|
m_code.push_back(data::OpCodes::Ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ostd::String(line).toLower().startsWith("rti"))
|
else if (String(line).toLower().startsWith("rti"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::RetInt);
|
m_code.push_back(data::OpCodes::RetInt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ostd::String(line).toLower().startsWith("hlt"))
|
else if (String(line).toLower().startsWith("hlt"))
|
||||||
{
|
{
|
||||||
m_code.push_back(data::OpCodes::Halt);
|
m_code.push_back(data::OpCodes::Halt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assembler::parse1Operand(ostd::String line)
|
void Assembler::parse1Operand(String line)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
ostd::String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
||||||
instEdit.trim().toLower();
|
instEdit.trim().toLower();
|
||||||
ostd::String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
||||||
opEdit.trim();
|
opEdit.trim();
|
||||||
int16_t word = 0x0000;
|
int16_t word = 0x0000;
|
||||||
if (STDVEC_CONTAINS(cpuExtensions, "extalu"))
|
if (STDVEC_CONTAINS(cpuExtensions, "extalu"))
|
||||||
|
|
@ -1302,7 +1302,7 @@ namespace dragon
|
||||||
if (opType == eOperandType::Immediate || opType == eOperandType::Label)
|
if (opType == eOperandType::Immediate || opType == eOperandType::Label)
|
||||||
{
|
{
|
||||||
// if (opType == eOperandType::Label)
|
// if (opType == eOperandType::Label)
|
||||||
// std::cout << ostd::String::getHexStr(word, true, 2) << "\n";
|
// std::cout << String::getHexStr(word, true, 2) << "\n";
|
||||||
m_code[m_code.size() - 1] = data::OpCodes::PushImm;
|
m_code[m_code.size() - 1] = data::OpCodes::PushImm;
|
||||||
// m_code.push_back(data::OpCodes::PushImm);
|
// m_code.push_back(data::OpCodes::PushImm);
|
||||||
m_code.push_back((uint8_t)((word & 0xFF00) >> 8));
|
m_code.push_back((uint8_t)((word & 0xFF00) >> 8));
|
||||||
|
|
@ -1468,12 +1468,12 @@ namespace dragon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assembler::parse2Operand(ostd::String line)
|
void Assembler::parse2Operand(String line)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
ostd::String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
||||||
instEdit.trim().toLower();
|
instEdit.trim().toLower();
|
||||||
ostd::String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
||||||
opEdit.trim();
|
opEdit.trim();
|
||||||
int16_t word = 0x0000;
|
int16_t word = 0x0000;
|
||||||
auto st = opEdit.tokenize(",");
|
auto st = opEdit.tokenize(",");
|
||||||
|
|
@ -1859,12 +1859,12 @@ namespace dragon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assembler::parse3Operand(ostd::String line)
|
void Assembler::parse3Operand(String line)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
ostd::String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
|
||||||
instEdit.trim().toLower();
|
instEdit.trim().toLower();
|
||||||
ostd::String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
|
||||||
opEdit.trim();
|
opEdit.trim();
|
||||||
if (STDVEC_CONTAINS(cpuExtensions, "extmov"))
|
if (STDVEC_CONTAINS(cpuExtensions, "extmov"))
|
||||||
{
|
{
|
||||||
|
|
@ -1889,7 +1889,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)word1);
|
m_code.push_back((uint8_t)word1);
|
||||||
code_offset++;
|
code_offset++;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -1973,7 +1973,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)(word1 & 0x00FF));
|
m_code.push_back((uint8_t)(word1 & 0x00FF));
|
||||||
code_offset += 2;
|
code_offset += 2;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2046,7 +2046,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)word1);
|
m_code.push_back((uint8_t)word1);
|
||||||
code_offset++;
|
code_offset++;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2129,7 +2129,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)(word1 & 0x00FF));
|
m_code.push_back((uint8_t)(word1 & 0x00FF));
|
||||||
code_offset += 2;
|
code_offset += 2;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2201,7 +2201,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)word1);
|
m_code.push_back((uint8_t)word1);
|
||||||
code_offset++;
|
code_offset++;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2283,7 +2283,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)word1);
|
m_code.push_back((uint8_t)word1);
|
||||||
code_offset++;
|
code_offset++;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2354,7 +2354,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)word1);
|
m_code.push_back((uint8_t)word1);
|
||||||
code_offset++;
|
code_offset++;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2436,7 +2436,7 @@ namespace dragon
|
||||||
m_code.push_back((uint8_t)word1);
|
m_code.push_back((uint8_t)word1);
|
||||||
code_offset++;
|
code_offset++;
|
||||||
eOperandType opType2 = parseOperand(st.next(), word2);
|
eOperandType opType2 = parseOperand(st.next(), word2);
|
||||||
ostd::String op3 = st.next();
|
String op3 = st.next();
|
||||||
bool word_offset = false;
|
bool word_offset = false;
|
||||||
if (op3.startsWith("word"))
|
if (op3.startsWith("word"))
|
||||||
{
|
{
|
||||||
|
|
@ -2522,7 +2522,7 @@ namespace dragon
|
||||||
newCode.push_back((uint8_t)(entryAddr & 0x00FF));
|
newCode.push_back((uint8_t)(entryAddr & 0x00FF));
|
||||||
if (m_dataSize > 0)
|
if (m_dataSize > 0)
|
||||||
m_disassembly.insert(m_disassembly.begin(), { (uint16_t)(m_loadAddress + 3), "[----------DATA_SECTION----------]" });
|
m_disassembly.insert(m_disassembly.begin(), { (uint16_t)(m_loadAddress + 3), "[----------DATA_SECTION----------]" });
|
||||||
m_disassembly.insert(m_disassembly.begin(), { m_loadAddress, ostd::String("jmp ").add(ostd::String::getHexStr(entryAddr, true, 2)) });
|
m_disassembly.insert(m_disassembly.begin(), { m_loadAddress, String("jmp ").add(String::getHexStr(entryAddr, true, 2)) });
|
||||||
for (auto& d : m_symbolTable)
|
for (auto& d : m_symbolTable)
|
||||||
{
|
{
|
||||||
symbols.push_back(d.second);
|
symbols.push_back(d.second);
|
||||||
|
|
@ -2552,17 +2552,17 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ostd::String Assembler::replaceSymbols(ostd::String line)
|
String Assembler::replaceSymbols(String line)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit(line);
|
String lineEdit(line);
|
||||||
for (auto& symbol : m_symbolTable)
|
for (auto& symbol : m_symbolTable)
|
||||||
{
|
{
|
||||||
ostd::String regex = "\\" + symbol.first.new_regexReplace("\\.", "\\.") + "(?!\\.)(?!\\w)";
|
String regex = "\\" + symbol.first.new_regexReplace("\\.", "\\.") + "(?!\\.)(?!\\w)";
|
||||||
|
|
||||||
// std::cout << "SYMBOL: " << symbol.first << "\n";
|
// std::cout << "SYMBOL: " << symbol.first << "\n";
|
||||||
// std::cout << "LINE: " << lineEdit << "\n";
|
// std::cout << "LINE: " << lineEdit << "\n";
|
||||||
// std::cout << "REGEX: " << regex << "\n";
|
// std::cout << "REGEX: " << regex << "\n";
|
||||||
lineEdit.regexReplace(regex, ostd::String::getHexStr(symbol.second.address, true, 2), false);
|
lineEdit.regexReplace(regex, String::getHexStr(symbol.second.address, true, 2), false);
|
||||||
// std::cout << "NEW_LINE: " << lineEdit << "\n\n";
|
// std::cout << "NEW_LINE: " << lineEdit << "\n\n";
|
||||||
}
|
}
|
||||||
return lineEdit;
|
return lineEdit;
|
||||||
|
|
@ -2580,9 +2580,9 @@ namespace dragon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assembler::eOperandType Assembler::parseOperand(ostd::String op, int16_t& outOp)
|
Assembler::eOperandType Assembler::parseOperand(String op, int16_t& outOp)
|
||||||
{
|
{
|
||||||
ostd::String opEdit(op);
|
String opEdit(op);
|
||||||
bool derefReg = false;
|
bool derefReg = false;
|
||||||
if (opEdit.startsWith("*"))
|
if (opEdit.startsWith("*"))
|
||||||
{
|
{
|
||||||
|
|
@ -2640,8 +2640,8 @@ namespace dragon
|
||||||
m_labelTable[opEdit].references.push_back(m_code.size());
|
m_labelTable[opEdit].references.push_back(m_code.size());
|
||||||
outOp = (int16_t)labelAddr;
|
outOp = (int16_t)labelAddr;
|
||||||
// std::cout << "LABEL: " << opEdit << "\n";
|
// std::cout << "LABEL: " << opEdit << "\n";
|
||||||
// std::cout << " : " << ostd::String::getHexStr(labelAddr, true, 2) << "\n";
|
// std::cout << " : " << String::getHexStr(labelAddr, true, 2) << "\n";
|
||||||
// std::cout << " : " << ostd::String::getHexStr(outOp, true, 2) << "\n";
|
// std::cout << " : " << String::getHexStr(outOp, true, 2) << "\n";
|
||||||
return eOperandType::Label;
|
return eOperandType::Label;
|
||||||
}
|
}
|
||||||
if (opEdit.startsWith("{") && opEdit.endsWith("}"))
|
if (opEdit.startsWith("{") && opEdit.endsWith("}"))
|
||||||
|
|
@ -2673,9 +2673,9 @@ namespace dragon
|
||||||
return eOperandType::Error;
|
return eOperandType::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Assembler::parseRegister(ostd::String op)
|
uint8_t Assembler::parseRegister(String op)
|
||||||
{
|
{
|
||||||
ostd::String opEdit(op);
|
String opEdit(op);
|
||||||
opEdit.trim().toLower();
|
opEdit.trim().toLower();
|
||||||
if (opEdit == "r1") return data::Registers::R1;
|
if (opEdit == "r1") return data::Registers::R1;
|
||||||
if (opEdit == "r2") return data::Registers::R2;
|
if (opEdit == "r2") return data::Registers::R2;
|
||||||
|
|
|
||||||
|
|
@ -15,30 +15,30 @@ namespace dragon
|
||||||
class IncludePreprocessor
|
class IncludePreprocessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::vector<ostd::String> loadEntryFile(const ostd::String& filePath);
|
static std::vector<String> loadEntryFile(const String& filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool __can_file_be_included(std::vector<ostd::String>& lines);
|
static bool __can_file_be_included(std::vector<String>& lines);
|
||||||
static bool __include_loop(void);
|
static bool __include_loop(void);
|
||||||
static std::vector<ostd::String> __load_file(const ostd::String& filePath);
|
static std::vector<String> __load_file(const String& filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static std::vector<ostd::String> m_lines;
|
inline static std::vector<String> m_lines;
|
||||||
inline static std::vector<ostd::String> m_guards;
|
inline static std::vector<String> m_guards;
|
||||||
inline static ostd::String m_directory { "" };
|
inline static String m_directory { "" };
|
||||||
};
|
};
|
||||||
|
|
||||||
class Assembler
|
class Assembler
|
||||||
{
|
{
|
||||||
public: struct tDefine
|
public: struct tDefine
|
||||||
{
|
{
|
||||||
ostd::String name;
|
String name;
|
||||||
ostd::String value;
|
String value;
|
||||||
};
|
};
|
||||||
public: struct tDisassemblyLine
|
public: struct tDisassemblyLine
|
||||||
{
|
{
|
||||||
uint32_t addr = 0;
|
uint32_t addr = 0;
|
||||||
ostd::String code = "";
|
String code = "";
|
||||||
uint16_t size = 1;
|
uint16_t size = 1;
|
||||||
inline bool operator<(const tDisassemblyLine& second) const { return addr < second.addr; }
|
inline bool operator<(const tDisassemblyLine& second) const { return addr < second.addr; }
|
||||||
inline bool operator>(const tDisassemblyLine& second) const { return addr > second.addr; }
|
inline bool operator>(const tDisassemblyLine& second) const { return addr > second.addr; }
|
||||||
|
|
@ -55,7 +55,7 @@ namespace dragon
|
||||||
};
|
};
|
||||||
public: struct tStructMember
|
public: struct tStructMember
|
||||||
{
|
{
|
||||||
ostd::String name;
|
String name;
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
int32_t position;
|
int32_t position;
|
||||||
inline bool operator<(const tStructMember& second) const { return position < second.position; }
|
inline bool operator<(const tStructMember& second) const { return position < second.position; }
|
||||||
|
|
@ -63,14 +63,14 @@ namespace dragon
|
||||||
};
|
};
|
||||||
public: struct tStructDefinition
|
public: struct tStructDefinition
|
||||||
{
|
{
|
||||||
ostd::String name;
|
String name;
|
||||||
std::vector<tStructMember> members;
|
std::vector<tStructMember> members;
|
||||||
int32_t size;
|
int32_t size;
|
||||||
};
|
};
|
||||||
public: struct tExportSpec
|
public: struct tExportSpec
|
||||||
{
|
{
|
||||||
ostd::String fileName { "" };
|
String fileName { "" };
|
||||||
std::vector<ostd::String> lines;
|
std::vector<String> lines;
|
||||||
};
|
};
|
||||||
public: enum class eOperandType
|
public: enum class eOperandType
|
||||||
{
|
{
|
||||||
|
|
@ -88,16 +88,16 @@ namespace dragon
|
||||||
public: struct tCommandLineArgs
|
public: struct tCommandLineArgs
|
||||||
{
|
{
|
||||||
inline tCommandLineArgs(void) { }
|
inline tCommandLineArgs(void) { }
|
||||||
ostd::String source_file_path { "" };
|
String source_file_path { "" };
|
||||||
ostd::String dest_file_path { "" };
|
String dest_file_path { "" };
|
||||||
bool save_disassembly { false };
|
bool save_disassembly { false };
|
||||||
int32_t verbose_level { 0xFF };
|
int32_t verbose_level { 0xFF };
|
||||||
bool debug_mode { false };
|
bool debug_mode { false };
|
||||||
bool save_exports { true };
|
bool save_exports { true };
|
||||||
ostd::String disassembly_file_path { "" };
|
String disassembly_file_path { "" };
|
||||||
ostd::String final_stage_path { "" };
|
String final_stage_path { "" };
|
||||||
std::vector<ostd::String> cpu_extensions;
|
std::vector<String> cpu_extensions;
|
||||||
std::vector<ostd::String> include_directories;
|
std::vector<String> include_directories;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -114,10 +114,10 @@ namespace dragon
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ostd::ByteStream assembleFromFile(ostd::String fileName);
|
static ostd::ByteStream assembleFromFile(String fileName);
|
||||||
static ostd::ByteStream assembleToFile(ostd::String sourceFileName, ostd::String binaryFileName);
|
static ostd::ByteStream assembleToFile(String sourceFileName, String binaryFileName);
|
||||||
static ostd::ByteStream assembleToVirtualDisk(ostd::String fileName, hw::VirtualHardDrive& vhdd, uint32_t address);
|
static ostd::ByteStream assembleToVirtualDisk(String fileName, hw::VirtualHardDrive& vhdd, uint32_t address);
|
||||||
static bool saveDisassemblyToFile(ostd::String fileName);
|
static bool saveDisassemblyToFile(String fileName);
|
||||||
static void printProgramInfo(int32_t verbose_level = 1);
|
static void printProgramInfo(int32_t verbose_level = 1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -139,28 +139,28 @@ namespace dragon
|
||||||
static void parseDataSection(void);
|
static void parseDataSection(void);
|
||||||
static void parseCodeSection(void);
|
static void parseCodeSection(void);
|
||||||
|
|
||||||
static void parseDebugOperands(ostd::String line);
|
static void parseDebugOperands(String line);
|
||||||
static void parse0Operand(ostd::String line);
|
static void parse0Operand(String line);
|
||||||
static void parse1Operand(ostd::String line);
|
static void parse1Operand(String line);
|
||||||
static void parse2Operand(ostd::String line);
|
static void parse2Operand(String line);
|
||||||
static void parse3Operand(ostd::String line);
|
static void parse3Operand(String line);
|
||||||
static void combineDataAndCode(void);
|
static void combineDataAndCode(void);
|
||||||
|
|
||||||
static ostd::String replaceSymbols(ostd::String line);
|
static String replaceSymbols(String line);
|
||||||
static void replaceLabelRefs(void);
|
static void replaceLabelRefs(void);
|
||||||
static eOperandType parseOperand(ostd::String op, int16_t& outOp);
|
static eOperandType parseOperand(String op, int16_t& outOp);
|
||||||
static uint8_t parseRegister(ostd::String op);
|
static uint8_t parseRegister(String op);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static ostd::String m_rawSource { "" };
|
inline static String m_rawSource { "" };
|
||||||
inline static ostd::ByteStream m_code;
|
inline static ostd::ByteStream m_code;
|
||||||
|
|
||||||
inline static std::vector<ostd::String> m_lines;
|
inline static std::vector<String> m_lines;
|
||||||
inline static std::vector<ostd::String> m_rawDataSection;
|
inline static std::vector<String> m_rawDataSection;
|
||||||
inline static std::vector<ostd::String> m_rawCodeSection;
|
inline static std::vector<String> m_rawCodeSection;
|
||||||
|
|
||||||
inline static std::unordered_map<ostd::String, tSymbol> m_symbolTable;
|
inline static std::unordered_map<String, tSymbol> m_symbolTable;
|
||||||
inline static std::unordered_map<ostd::String, tLabel> m_labelTable;
|
inline static std::unordered_map<String, tLabel> m_labelTable;
|
||||||
|
|
||||||
inline static uint16_t m_fixedSize { 0 };
|
inline static uint16_t m_fixedSize { 0 };
|
||||||
inline static uint8_t m_fixedFillValue { 0x00 };
|
inline static uint8_t m_fixedFillValue { 0x00 };
|
||||||
|
|
@ -168,20 +168,20 @@ namespace dragon
|
||||||
inline static uint16_t m_currentDataAddr { 0x0000 };
|
inline static uint16_t m_currentDataAddr { 0x0000 };
|
||||||
inline static uint16_t m_dataSize { 0x0000 };
|
inline static uint16_t m_dataSize { 0x0000 };
|
||||||
inline static uint16_t m_programSize { 0x0000 };
|
inline static uint16_t m_programSize { 0x0000 };
|
||||||
inline static ostd::String m_entry_lbl { "" };
|
inline static String m_entry_lbl { "" };
|
||||||
inline static ostd::String m_headerStr { "" };
|
inline static String m_headerStr { "" };
|
||||||
|
|
||||||
inline static std::vector<tStructDefinition> m_structDefs;
|
inline static std::vector<tStructDefinition> m_structDefs;
|
||||||
inline static std::vector<tDisassemblyLine> m_disassembly;
|
inline static std::vector<tDisassemblyLine> m_disassembly;
|
||||||
|
|
||||||
inline static std::unordered_map<ostd::String, tExportSpec> m_exports;
|
inline static std::unordered_map<String, tExportSpec> m_exports;
|
||||||
|
|
||||||
inline static ostd::ConsoleOutputHandler out;
|
inline static ostd::ConsoleOutputHandler out;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline static bool saveExports { false };
|
inline static bool saveExports { false };
|
||||||
inline static bool debugMode { false };
|
inline static bool debugMode { false };
|
||||||
inline static std::vector<ostd::String> cpuExtensions;
|
inline static std::vector<String> cpuExtensions;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace dragon
|
||||||
args.verbose_level = -1;
|
args.verbose_level = -1;
|
||||||
for (int32_t i = 2; i < argc; i++)
|
for (int32_t i = 2; i < argc; i++)
|
||||||
{
|
{
|
||||||
ostd::String edit(argv[i]);
|
String edit(argv[i]);
|
||||||
if (edit == "-o")
|
if (edit == "-o")
|
||||||
{
|
{
|
||||||
if (i == argc - 1)
|
if (i == argc - 1)
|
||||||
|
|
@ -42,7 +42,7 @@ namespace dragon
|
||||||
if (i == argc - 1)
|
if (i == argc - 1)
|
||||||
return RETURN_VAL_MISSING_PARAM;
|
return RETURN_VAL_MISSING_PARAM;
|
||||||
i++;
|
i++;
|
||||||
ostd::String _include = argv[i];
|
String _include = argv[i];
|
||||||
_include.trim();
|
_include.trim();
|
||||||
if (!_include.endsWith("/"))
|
if (!_include.endsWith("/"))
|
||||||
_include.add("/");
|
_include.add("/");
|
||||||
|
|
@ -63,7 +63,7 @@ namespace dragon
|
||||||
if (i == argc - 1)
|
if (i == argc - 1)
|
||||||
return RETURN_VAL_MISSING_PARAM;
|
return RETURN_VAL_MISSING_PARAM;
|
||||||
i++;
|
i++;
|
||||||
ostd::String final_path = argv[i];
|
String final_path = argv[i];
|
||||||
if (!ostd::FileSystem::ensureFile(final_path))
|
if (!ostd::FileSystem::ensureFile(final_path))
|
||||||
return RETURN_VAL_INVALID_PARAM;
|
return RETURN_VAL_INVALID_PARAM;
|
||||||
args.final_stage_path = final_path;
|
args.final_stage_path = final_path;
|
||||||
|
|
@ -109,7 +109,7 @@ namespace dragon
|
||||||
int32_t commandLength = 46;
|
int32_t commandLength = 46;
|
||||||
|
|
||||||
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
|
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
|
||||||
ostd::String tmpCommand = "--save-disassembly <destination-directory>";
|
String tmpCommand = "--save-disassembly <destination-directory>";
|
||||||
tmpCommand.addRightPadding(commandLength);
|
tmpCommand.addRightPadding(commandLength);
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Saves debug information in the destination directory. (Enabled by default in debug mode.)").reset().nl();
|
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Saves debug information in the destination directory. (Enabled by default in debug mode.)").reset().nl();
|
||||||
tmpCommand = "--save-final-stage <destination-file>";
|
tmpCommand = "--save-final-stage <destination-file>";
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
namespace code
|
namespace code
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> IncludePreprocessor::loadEntryFile(const ostd::String& filePath)
|
std::vector<String> IncludePreprocessor::loadEntryFile(const String& filePath)
|
||||||
{
|
{
|
||||||
m_guards.clear();
|
m_guards.clear();
|
||||||
m_lines.clear();
|
m_lines.clear();
|
||||||
|
|
@ -20,10 +20,10 @@ namespace dragon
|
||||||
if (!__can_file_be_included(m_lines))
|
if (!__can_file_be_included(m_lines))
|
||||||
return { }; //TODO: Error
|
return { }; //TODO: Error
|
||||||
if (!__include_loop()) return { }; //TODO: Error
|
if (!__include_loop()) return { }; //TODO: Error
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<String> newLines;
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit = line.new_trim();
|
String lineEdit = line.new_trim();
|
||||||
if (lineEdit != "")
|
if (lineEdit != "")
|
||||||
newLines.push_back(line);
|
newLines.push_back(line);
|
||||||
}
|
}
|
||||||
|
|
@ -32,12 +32,12 @@ namespace dragon
|
||||||
return m_lines;
|
return m_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IncludePreprocessor::__can_file_be_included(std::vector<ostd::String>& lines)
|
bool IncludePreprocessor::__can_file_be_included(std::vector<String>& lines)
|
||||||
{
|
{
|
||||||
ostd::String guard_name = "";
|
String guard_name = "";
|
||||||
for (auto& line : lines)
|
for (auto& line : lines)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit = line.new_trim();
|
String lineEdit = line.new_trim();
|
||||||
if (lineEdit.new_toLower().startsWith("@guard "))
|
if (lineEdit.new_toLower().startsWith("@guard "))
|
||||||
{
|
{
|
||||||
guard_name = lineEdit.new_substr(7).trim();
|
guard_name = lineEdit.new_substr(7).trim();
|
||||||
|
|
@ -57,7 +57,7 @@ namespace dragon
|
||||||
|
|
||||||
bool IncludePreprocessor::__include_loop(void)
|
bool IncludePreprocessor::__include_loop(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> lines = m_lines;
|
std::vector<String> lines = m_lines;
|
||||||
bool included = false;
|
bool included = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +65,7 @@ namespace dragon
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for ( ; i < lines.size(); i++)
|
for ( ; i < lines.size(); i++)
|
||||||
{
|
{
|
||||||
ostd::String line = lines[i];
|
String line = lines[i];
|
||||||
line.trim();
|
line.trim();
|
||||||
if (line.new_toLower().startsWith("@include") && line.len() > 8)
|
if (line.new_toLower().startsWith("@include") && line.len() > 8)
|
||||||
{
|
{
|
||||||
|
|
@ -90,15 +90,15 @@ namespace dragon
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ostd::String> IncludePreprocessor::__load_file(const ostd::String& filePath)
|
std::vector<String> IncludePreprocessor::__load_file(const String& filePath)
|
||||||
{
|
{
|
||||||
const auto& include_dirs = Assembler::Application::args.include_directories;
|
const auto& include_dirs = Assembler::Application::args.include_directories;
|
||||||
|
|
||||||
if (ostd::FileSystem::fileExists(m_directory + filePath))
|
if (ostd::FileSystem::fileExists(m_directory + filePath))
|
||||||
{
|
{
|
||||||
ostd::TextFileBuffer file(m_directory + filePath);
|
ostd::TextFileBuffer file(m_directory + filePath);
|
||||||
ostd::String source = file.rawContent();
|
String source = file.rawContent();
|
||||||
return ostd::String(source.replaceAll("\t", " ")).tokenize("\n", false).getRawData();
|
return String(source.replaceAll("\t", " ")).tokenize("\n", false).getRawData();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& dir : include_dirs)
|
for (const auto& dir : include_dirs)
|
||||||
|
|
@ -106,8 +106,8 @@ namespace dragon
|
||||||
if (ostd::FileSystem::fileExists(dir + filePath))
|
if (ostd::FileSystem::fileExists(dir + filePath))
|
||||||
{
|
{
|
||||||
ostd::TextFileBuffer file(dir + filePath);
|
ostd::TextFileBuffer file(dir + filePath);
|
||||||
ostd::String source = file.rawContent();
|
String source = file.rawContent();
|
||||||
return ostd::String(source.replaceAll("\t", " ")).tokenize("\n", false).getRawData();
|
return String(source.replaceAll("\t", " ")).tokenize("\n", false).getRawData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace dragon
|
||||||
return codeRegion;
|
return codeRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::String Debugger::Utils::findSymbol(const DisassemblyList& list, uint16_t address, uint16_t* outSize)
|
String Debugger::Utils::findSymbol(const DisassemblyList& list, uint16_t address, uint16_t* outSize)
|
||||||
{
|
{
|
||||||
for (auto& line : list)
|
for (auto& line : list)
|
||||||
{
|
{
|
||||||
|
|
@ -67,7 +67,7 @@ namespace dragon
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Debugger::Utils::findSymbol(const DisassemblyList& list, const ostd::String& symbol, uint16_t* outSize)
|
uint16_t Debugger::Utils::findSymbol(const DisassemblyList& list, const String& symbol, uint16_t* outSize)
|
||||||
{
|
{
|
||||||
for (auto& line : list)
|
for (auto& line : list)
|
||||||
{
|
{
|
||||||
|
|
@ -116,7 +116,7 @@ namespace dragon
|
||||||
ostd::ConsoleOutputHandler& Debugger::Utils::printFullLine(char c, const ostd::ConsoleColors::tConsoleColor& foreground)
|
ostd::ConsoleOutputHandler& Debugger::Utils::printFullLine(char c, const ostd::ConsoleColors::tConsoleColor& foreground)
|
||||||
{
|
{
|
||||||
int32_t cw = ostd::BasicConsole::getConsoleWidth();
|
int32_t cw = ostd::BasicConsole::getConsoleWidth();
|
||||||
ostd::String str = ostd::String::duplicateChar(c, cw);
|
String str = String::duplicateChar(c, cw);
|
||||||
out.fg(foreground).p(str).reset().nl();
|
out.fg(foreground).p(str).reset().nl();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ namespace dragon
|
||||||
ostd::ConsoleOutputHandler& Debugger::Utils::printFullLine(char c, const ostd::ConsoleColors::tConsoleColor& foreground, const ostd::ConsoleColors::tConsoleColor& background)
|
ostd::ConsoleOutputHandler& Debugger::Utils::printFullLine(char c, const ostd::ConsoleColors::tConsoleColor& foreground, const ostd::ConsoleColors::tConsoleColor& background)
|
||||||
{
|
{
|
||||||
int32_t cw = ostd::BasicConsole::getConsoleWidth();
|
int32_t cw = ostd::BasicConsole::getConsoleWidth();
|
||||||
ostd::String str = ostd::String::duplicateChar(c, cw);
|
String str = String::duplicateChar(c, cw);
|
||||||
out.bg(background).fg(foreground).p(str).reset().nl();
|
out.bg(background).fg(foreground).p(str).reset().nl();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +161,7 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
//Debugger::Display
|
//Debugger::Display
|
||||||
void Debugger::Display::colorizeInstructionBody(const ostd::String& instBody, bool currentLine, const DisassemblyList& labelList)
|
void Debugger::Display::colorizeInstructionBody(const String& instBody, bool currentLine, const DisassemblyList& labelList)
|
||||||
{
|
{
|
||||||
ostd::RegexRichString rgxrstr(instBody);
|
ostd::RegexRichString rgxrstr(instBody);
|
||||||
rgxrstr.fg("\\{|\\}|\\+|\\*|\\-|\\/|\\(|\\)|\\[|\\]", "Red"); //Operators
|
rgxrstr.fg("\\{|\\}|\\+|\\*|\\-|\\/|\\(|\\)|\\[|\\]", "Red"); //Operators
|
||||||
|
|
@ -169,18 +169,18 @@ namespace dragon
|
||||||
rgxrstr.fg("(?<!\\w)(r[1-9]|r10|fl|pp|rv|fp|sp|ip|acc)(?!\\w)", "BrightGreen", true); //Registers
|
rgxrstr.fg("(?<!\\w)(r[1-9]|r10|fl|pp|rv|fp|sp|ip|acc)(?!\\w)", "BrightGreen", true); //Registers
|
||||||
rgxrstr.fg("\\%low", "Magenta");
|
rgxrstr.fg("\\%low", "Magenta");
|
||||||
rgxrstr.col("\\$\\w+", "Cyan", "Black"); //Labels
|
rgxrstr.col("\\$\\w+", "Cyan", "Black"); //Labels
|
||||||
ostd::String instEdit = rgxrstr.getRawString();
|
String instEdit = rgxrstr.getRawString();
|
||||||
for (auto& label : labelList)
|
for (auto& label : labelList)
|
||||||
{
|
{
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
ostd::String labelEdit = label.code;
|
String labelEdit = label.code;
|
||||||
labelEdit.trim();
|
labelEdit.trim();
|
||||||
while ((index = instEdit.indexOf(labelEdit, index + 1)) != -1)
|
while ((index = instEdit.indexOf(labelEdit, index + 1)) != -1)
|
||||||
{
|
{
|
||||||
if (index + labelEdit.len() < instEdit.len() && Utils::isValidLabelNameChar(instEdit.at(index + labelEdit.len())))
|
if (index + labelEdit.len() < instEdit.len() && Utils::isValidLabelNameChar(instEdit.at(index + labelEdit.len())))
|
||||||
continue;
|
continue;
|
||||||
ostd::String instStr = instEdit;
|
String instStr = instEdit;
|
||||||
instStr.cpp_str_ref().replace(index, labelEdit.len(), labelEdit.cpp_str() + "[@@ style foreground:brightgray](" + ostd::String::getHexStr(label.addr, true, 2).cpp_str() + ")[@@/]");
|
instStr.cpp_str_ref().replace(index, labelEdit.len(), labelEdit.cpp_str() + "[@@ style foreground:brightgray](" + String::getHexStr(label.addr, true, 2).cpp_str() + ")[@@/]");
|
||||||
instEdit = instStr;
|
instEdit = instStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,11 +192,11 @@ namespace dragon
|
||||||
out.reset().reset();
|
out.reset().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debugger::Display::colorCodeInstructions(const ostd::String& inst, bool currentLine, const DisassemblyList& labelList)
|
void Debugger::Display::colorCodeInstructions(const String& inst, bool currentLine, const DisassemblyList& labelList)
|
||||||
{
|
{
|
||||||
ostd::String instEditor = inst;
|
String instEditor = inst;
|
||||||
ostd::String instBody = "";
|
String instBody = "";
|
||||||
ostd::String instHead = inst;
|
String instHead = inst;
|
||||||
instEditor.trim();
|
instEditor.trim();
|
||||||
if (instEditor.contains(" "))
|
if (instEditor.contains(" "))
|
||||||
{
|
{
|
||||||
|
|
@ -236,13 +236,13 @@ namespace dragon
|
||||||
{
|
{
|
||||||
auto& _da = codeRegion[i];
|
auto& _da = codeRegion[i];
|
||||||
bool currentLine = _da.addr == debugger.currentAddress;
|
bool currentLine = _da.addr == debugger.currentAddress;
|
||||||
ostd::String label = Utils::findSymbol(debugger.labels, _da.addr);
|
String label = Utils::findSymbol(debugger.labels, _da.addr);
|
||||||
bool specialSection = _da.code.startsWith("[") &&_da.code.endsWith("]");
|
bool specialSection = _da.code.startsWith("[") &&_da.code.endsWith("]");
|
||||||
label.fixedLength(debugger.labelLineLength);
|
label.fixedLength(debugger.labelLineLength);
|
||||||
out.fg(ostd::ConsoleColors::Gray).p(label.cpp_str()).p(" ");
|
out.fg(ostd::ConsoleColors::Gray).p(label.cpp_str()).p(" ");
|
||||||
if (currentLine)
|
if (currentLine)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Black).bg(ostd::ConsoleColors::Yellow).p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();;
|
out.fg(ostd::ConsoleColors::Black).bg(ostd::ConsoleColors::Yellow).p(String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -252,7 +252,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red);
|
out.fg(ostd::ConsoleColors::Red);
|
||||||
else
|
else
|
||||||
out.fg(ostd::ConsoleColors::BrightGray);
|
out.fg(ostd::ConsoleColors::BrightGray);
|
||||||
out.p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ");
|
out.p(String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ");
|
||||||
}
|
}
|
||||||
if (specialSection)
|
if (specialSection)
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(_da.code.cpp_str()).nl();
|
out.fg(ostd::ConsoleColors::Cyan).p(_da.code.cpp_str()).nl();
|
||||||
|
|
@ -265,7 +265,7 @@ namespace dragon
|
||||||
void Debugger::Display::printDiff(void)
|
void Debugger::Display::printDiff(void)
|
||||||
{
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
ostd::String str;
|
String str;
|
||||||
str.add("|===============|================PREV================|================CURR================|=====|===PREV====|===CURR====|");
|
str.add("|===============|================PREV================|================CURR================|=====|===PREV====|===CURR====|");
|
||||||
str.add("\n");
|
str.add("\n");
|
||||||
str.add("| InstAddr: |*%PREV_INST_ADDR%*******************|*%CURR_INST_ADDR%*******************| R1 |*%PREV_R1%*|*%CURR_R1%*|");
|
str.add("| InstAddr: |*%PREV_INST_ADDR%*******************|*%CURR_INST_ADDR%*******************| R1 |*%PREV_R1%*|*%CURR_R1%*|");
|
||||||
|
|
@ -328,19 +328,19 @@ namespace dragon
|
||||||
str.replaceAll("*", "");
|
str.replaceAll("*", "");
|
||||||
int32_t item_len = 36;
|
int32_t item_len = 36;
|
||||||
const dragon::DragonRuntime::tMachineDebugInfo& minfo = dragon::DragonRuntime::getMachineInfoDiff();
|
const dragon::DragonRuntime::tMachineDebugInfo& minfo = dragon::DragonRuntime::getMachineInfoDiff();
|
||||||
ostd::String tmp = " ", tmpStyle = "";
|
String tmp = " ", tmpStyle = "";
|
||||||
|
|
||||||
//Instruction Address
|
//Instruction Address
|
||||||
{
|
{
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionAddress, true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionAddress, true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_INST_ADDR%", tmpStyle);
|
str.replaceAll("%PREV_INST_ADDR%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionAddress, true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionAddress, true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionAddress != minfo.previousInstructionAddress)
|
if (minfo.currentInstructionAddress != minfo.previousInstructionAddress)
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -352,23 +352,23 @@ namespace dragon
|
||||||
//Code
|
//Code
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
ostd::String prevCode = " (";
|
String prevCode = " (";
|
||||||
prevCode.add(minfo.previousInstructionOpCode).add(") ");
|
prevCode.add(minfo.previousInstructionOpCode).add(") ");
|
||||||
for (int32_t i = 0; i < minfo.previousInstructionFootprintSize; i++)
|
for (int32_t i = 0; i < minfo.previousInstructionFootprintSize; i++)
|
||||||
prevCode.add(ostd::String::getHexStr(minfo.previousInstructionFootprint[i], false, 1)).add(" ");
|
prevCode.add(String::getHexStr(minfo.previousInstructionFootprint[i], false, 1)).add(" ");
|
||||||
tmp.add(prevCode);
|
tmp.add(prevCode);
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%CURR_CODE%", tmpStyle);
|
str.replaceAll("%CURR_CODE%", tmpStyle);
|
||||||
|
|
||||||
// tmp = " ";
|
// tmp = " ";
|
||||||
// ostd::String currCode = " (";
|
// String currCode = " (";
|
||||||
// currCode.add(minfo.currentInstructionOpCode).add(") ");
|
// currCode.add(minfo.currentInstructionOpCode).add(") ");
|
||||||
// for (int32_t i = 0; i < minfo.currentInstructionFootprintSize; i++)
|
// for (int32_t i = 0; i < minfo.currentInstructionFootprintSize; i++)
|
||||||
// currCode.add(ostd::String::getHexStr(minfo.currentInstructionFootprint[i], false, 1)).add(" ");
|
// currCode.add(String::getHexStr(minfo.currentInstructionFootprint[i], false, 1)).add(" ");
|
||||||
// tmp.add(currCode);
|
// tmp.add(currCode);
|
||||||
// tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
// tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
// // if (currCode != prevCode)
|
// // if (currCode != prevCode)
|
||||||
// // tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
// // tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
// // else
|
// // else
|
||||||
|
|
@ -380,15 +380,15 @@ namespace dragon
|
||||||
//Stack Frame
|
//Stack Frame
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionStackFrameSize, true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionStackFrameSize, true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_STACK_FRAME%", tmpStyle);
|
str.replaceAll("%PREV_STACK_FRAME%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionStackFrameSize, true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionStackFrameSize, true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionStackFrameSize != minfo.previousInstructionStackFrameSize)
|
if (minfo.currentInstructionStackFrameSize != minfo.previousInstructionStackFrameSize)
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -401,14 +401,14 @@ namespace dragon
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(STR_BOOL(minfo.previousInstructionDebugBreak));
|
tmp.add(STR_BOOL(minfo.previousInstructionDebugBreak));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_DBG_BRK%", tmpStyle);
|
str.replaceAll("%PREV_DBG_BRK%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(STR_BOOL(minfo.currentInstructionDebugBreak));
|
tmp.add(STR_BOOL(minfo.currentInstructionDebugBreak));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionDebugBreak != minfo.previousInstructionDebugBreak)
|
if (minfo.currentInstructionDebugBreak != minfo.previousInstructionDebugBreak)
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -421,14 +421,14 @@ namespace dragon
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(minfo.previousInstructionInterruptHandlerCount);
|
tmp.add(minfo.previousInstructionInterruptHandlerCount);
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_INT_HANDLER%", tmpStyle);
|
str.replaceAll("%PREV_INT_HANDLER%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(minfo.currentInstructionInterruptHandlerCount);
|
tmp.add(minfo.currentInstructionInterruptHandlerCount);
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionInterruptHandlerCount != minfo.previousInstructionInterruptHandlerCount)
|
if (minfo.currentInstructionInterruptHandlerCount != minfo.previousInstructionInterruptHandlerCount)
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -441,14 +441,14 @@ namespace dragon
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(STR_BOOL(minfo.previousInstructionBiosMode));
|
tmp.add(STR_BOOL(minfo.previousInstructionBiosMode));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_BIOS_MODE%", tmpStyle);
|
str.replaceAll("%PREV_BIOS_MODE%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(STR_BOOL(minfo.currentInstructionBiosMode));
|
tmp.add(STR_BOOL(minfo.currentInstructionBiosMode));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionBiosMode != minfo.previousInstructionBiosMode)
|
if (minfo.currentInstructionBiosMode != minfo.previousInstructionBiosMode)
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -462,8 +462,8 @@ namespace dragon
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(minfo.previousSubRoutineCounter).add(" (");
|
tmp.add(minfo.previousSubRoutineCounter).add(" (");
|
||||||
tmp.add(STR_BOOL(minfo.previousIsInSubRoutine)).add(")");
|
tmp.add(STR_BOOL(minfo.previousIsInSubRoutine)).add(")");
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
ostd::String old_tmp = tmp;
|
String old_tmp = tmp;
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_SUB_ROUTINE%", tmpStyle);
|
str.replaceAll("%PREV_SUB_ROUTINE%", tmpStyle);
|
||||||
|
|
@ -471,7 +471,7 @@ namespace dragon
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(minfo.currentSubRoutineCounter).add(" (");
|
tmp.add(minfo.currentSubRoutineCounter).add(" (");
|
||||||
tmp.add(STR_BOOL(minfo.currentIsInSubRoutine)).add(")");
|
tmp.add(STR_BOOL(minfo.currentIsInSubRoutine)).add(")");
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (old_tmp != tmp)
|
if (old_tmp != tmp)
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -483,15 +483,15 @@ namespace dragon
|
||||||
//System Registers
|
//System Registers
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::IP], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::IP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_IP%", tmpStyle);
|
str.replaceAll("%PREV_IP%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::IP], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::IP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::IP] != minfo.previousInstructionRegisters[dragon::data::Registers::IP])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::IP] != minfo.previousInstructionRegisters[dragon::data::Registers::IP])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -503,15 +503,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::SP], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::SP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_SP%", tmpStyle);
|
str.replaceAll("%PREV_SP%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::SP], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::SP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::SP] != minfo.previousInstructionRegisters[dragon::data::Registers::SP])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::SP] != minfo.previousInstructionRegisters[dragon::data::Registers::SP])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -523,15 +523,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FP], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_FP%", tmpStyle);
|
str.replaceAll("%PREV_FP%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FP], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::FP] != minfo.previousInstructionRegisters[dragon::data::Registers::FP])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::FP] != minfo.previousInstructionRegisters[dragon::data::Registers::FP])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -543,15 +543,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::RV], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::RV], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_RV%", tmpStyle);
|
str.replaceAll("%PREV_RV%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::RV], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::RV], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::RV] != minfo.previousInstructionRegisters[dragon::data::Registers::RV])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::RV] != minfo.previousInstructionRegisters[dragon::data::Registers::RV])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -563,15 +563,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::PP], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::PP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_PP%", tmpStyle);
|
str.replaceAll("%PREV_PP%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::PP], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::PP], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::PP] != minfo.previousInstructionRegisters[dragon::data::Registers::PP])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::PP] != minfo.previousInstructionRegisters[dragon::data::Registers::PP])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -583,15 +583,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FL], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FL], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_FL%", tmpStyle);
|
str.replaceAll("%PREV_FL%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FL], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FL], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::FL] != minfo.previousInstructionRegisters[dragon::data::Registers::FL])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::FL] != minfo.previousInstructionRegisters[dragon::data::Registers::FL])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -603,15 +603,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::ACC], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::ACC], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_ACC%", tmpStyle);
|
str.replaceAll("%PREV_ACC%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::ACC], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::ACC], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::ACC] != minfo.previousInstructionRegisters[dragon::data::Registers::ACC])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::ACC] != minfo.previousInstructionRegisters[dragon::data::Registers::ACC])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -624,15 +624,15 @@ namespace dragon
|
||||||
//General Registers
|
//General Registers
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R1], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R1], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R1%", tmpStyle);
|
str.replaceAll("%PREV_R1%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R1], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R1], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R1] != minfo.previousInstructionRegisters[dragon::data::Registers::R1])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R1] != minfo.previousInstructionRegisters[dragon::data::Registers::R1])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -644,15 +644,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R2], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R2], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R2%", tmpStyle);
|
str.replaceAll("%PREV_R2%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R2], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R2], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R2] != minfo.previousInstructionRegisters[dragon::data::Registers::R2])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R2] != minfo.previousInstructionRegisters[dragon::data::Registers::R2])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -664,15 +664,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R3], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R3], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R3%", tmpStyle);
|
str.replaceAll("%PREV_R3%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R3], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R3], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R3] != minfo.previousInstructionRegisters[dragon::data::Registers::R3])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R3] != minfo.previousInstructionRegisters[dragon::data::Registers::R3])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -684,15 +684,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R4], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R4], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R4%", tmpStyle);
|
str.replaceAll("%PREV_R4%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R4], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R4], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R4] != minfo.previousInstructionRegisters[dragon::data::Registers::R4])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R4] != minfo.previousInstructionRegisters[dragon::data::Registers::R4])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -704,15 +704,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R5], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R5], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R5%", tmpStyle);
|
str.replaceAll("%PREV_R5%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R5], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R5], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R5] != minfo.previousInstructionRegisters[dragon::data::Registers::R5])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R5] != minfo.previousInstructionRegisters[dragon::data::Registers::R5])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -724,15 +724,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R6], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R6], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R6%", tmpStyle);
|
str.replaceAll("%PREV_R6%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R6], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R6], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R6] != minfo.previousInstructionRegisters[dragon::data::Registers::R6])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R6] != minfo.previousInstructionRegisters[dragon::data::Registers::R6])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -744,15 +744,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R7], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R7], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R7%", tmpStyle);
|
str.replaceAll("%PREV_R7%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R7], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R7], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R7] != minfo.previousInstructionRegisters[dragon::data::Registers::R7])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R7] != minfo.previousInstructionRegisters[dragon::data::Registers::R7])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -764,15 +764,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R8], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R8], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R8%", tmpStyle);
|
str.replaceAll("%PREV_R8%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R8], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R8], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R8] != minfo.previousInstructionRegisters[dragon::data::Registers::R8])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R8] != minfo.previousInstructionRegisters[dragon::data::Registers::R8])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -784,15 +784,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R9], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R9], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R9%", tmpStyle);
|
str.replaceAll("%PREV_R9%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R9], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R9], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R9] != minfo.previousInstructionRegisters[dragon::data::Registers::R9])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R9] != minfo.previousInstructionRegisters[dragon::data::Registers::R9])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -804,15 +804,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R10], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R10], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_R10%", tmpStyle);
|
str.replaceAll("%PREV_R10%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R10], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R10], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::R10] != minfo.previousInstructionRegisters[dragon::data::Registers::R10])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::R10] != minfo.previousInstructionRegisters[dragon::data::Registers::R10])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -824,15 +824,15 @@ namespace dragon
|
||||||
//Special Registers
|
//Special Registers
|
||||||
{
|
{
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S1], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S1], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_S1%", tmpStyle);
|
str.replaceAll("%PREV_S1%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S1], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S1], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::S1] != minfo.previousInstructionRegisters[dragon::data::Registers::S1])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::S1] != minfo.previousInstructionRegisters[dragon::data::Registers::S1])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -844,15 +844,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S2], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S2], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_S2%", tmpStyle);
|
str.replaceAll("%PREV_S2%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S2], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S2], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::S2] != minfo.previousInstructionRegisters[dragon::data::Registers::S2])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::S2] != minfo.previousInstructionRegisters[dragon::data::Registers::S2])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -864,15 +864,15 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
tmp = " ", tmpStyle = "";
|
tmp = " ", tmpStyle = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
|
tmp.add(String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
tmpStyle = "[@@style foreground:Blue]";
|
tmpStyle = "[@@style foreground:Blue]";
|
||||||
tmpStyle.add(tmp).add("[@@/]");
|
tmpStyle.add(tmp).add("[@@/]");
|
||||||
str.replaceAll("%PREV_OF%", tmpStyle);
|
str.replaceAll("%PREV_OF%", tmpStyle);
|
||||||
|
|
||||||
tmp = " ";
|
tmp = " ";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
|
tmp.add(String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
|
||||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
tmp.addPadding(item_len, ' ', String::ePaddingBehavior::AllowOddExtraLeft);
|
||||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET] != minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET])
|
if (minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET] != minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET])
|
||||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||||
else
|
else
|
||||||
|
|
@ -906,7 +906,7 @@ namespace dragon
|
||||||
const dragon::DragonRuntime::tMachineDebugInfo& minfo = dragon::DragonRuntime::getMachineInfoDiff();
|
const dragon::DragonRuntime::tMachineDebugInfo& minfo = dragon::DragonRuntime::getMachineInfoDiff();
|
||||||
if (minfo.trackedAddresses.size() == 0) return;
|
if (minfo.trackedAddresses.size() == 0) return;
|
||||||
int32_t cw = ostd::BasicConsole::getConsoleWidth();
|
int32_t cw = ostd::BasicConsole::getConsoleWidth();
|
||||||
ostd::String header = "|Symbol";
|
String header = "|Symbol";
|
||||||
header.addRightPadding(symbol_len);
|
header.addRightPadding(symbol_len);
|
||||||
header.add("|Bytes");
|
header.add("|Bytes");
|
||||||
header.addRightPadding(header.len() + size_len - 6);
|
header.addRightPadding(header.len() + size_len - 6);
|
||||||
|
|
@ -919,13 +919,13 @@ namespace dragon
|
||||||
header.add("|Current");
|
header.add("|Current");
|
||||||
header.fixedLength(cw - 1);
|
header.fixedLength(cw - 1);
|
||||||
header.addChar('|');
|
header.addChar('|');
|
||||||
ostd::String border = ostd::String::duplicateChar('=', cw);
|
String border = String::duplicateChar('=', cw);
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(border).nl();
|
out.fg(ostd::ConsoleColors::Blue).p(border).nl();
|
||||||
ostd::RegexRichString rgx(header);
|
ostd::RegexRichString rgx(header);
|
||||||
rgx.fg("\\|", "blue");
|
rgx.fg("\\|", "blue");
|
||||||
rgx.fg("Symbol|Bytes|Addr|Map|Previous|Current", "yellow");
|
rgx.fg("Symbol|Bytes|Addr|Map|Previous|Current", "yellow");
|
||||||
out.pStyled(rgx).reset().nl();
|
out.pStyled(rgx).reset().nl();
|
||||||
ostd::String h_sep = ostd::String::duplicateChar('=', cw);
|
String h_sep = String::duplicateChar('=', cw);
|
||||||
h_sep.put(0, '|');
|
h_sep.put(0, '|');
|
||||||
h_sep.put(symbol_len, '|');
|
h_sep.put(symbol_len, '|');
|
||||||
h_sep.put(symbol_len + size_len, '|');
|
h_sep.put(symbol_len + size_len, '|');
|
||||||
|
|
@ -938,7 +938,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
uint16_t data_size = 1;
|
uint16_t data_size = 1;
|
||||||
auto addr = minfo.trackedAddresses[i];
|
auto addr = minfo.trackedAddresses[i];
|
||||||
ostd::String symbol = Utils::findSymbol(debugger.data, addr, &data_size);
|
String symbol = Utils::findSymbol(debugger.data, addr, &data_size);
|
||||||
if (symbol == "")
|
if (symbol == "")
|
||||||
symbol = Utils::findSymbol(debugger.labels, addr, &data_size);
|
symbol = Utils::findSymbol(debugger.labels, addr, &data_size);
|
||||||
bool no_symbol = false;
|
bool no_symbol = false;
|
||||||
|
|
@ -953,7 +953,7 @@ namespace dragon
|
||||||
else
|
else
|
||||||
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::Magenta).p(symbol).reset();
|
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::Magenta).p(symbol).reset();
|
||||||
|
|
||||||
ostd::String tmp = "";
|
String tmp = "";
|
||||||
tmp.add(data_size);
|
tmp.add(data_size);
|
||||||
tmp.fixedLength(size_len - 1);
|
tmp.fixedLength(size_len - 1);
|
||||||
if (no_symbol)
|
if (no_symbol)
|
||||||
|
|
@ -962,7 +962,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::BrightCyan).p(tmp).reset();
|
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::BrightCyan).p(tmp).reset();
|
||||||
|
|
||||||
tmp = "";
|
tmp = "";
|
||||||
tmp.add(ostd::String::getHexStr(addr, true, 2));
|
tmp.add(String::getHexStr(addr, true, 2));
|
||||||
tmp.fixedLength(addr_len - 1);
|
tmp.fixedLength(addr_len - 1);
|
||||||
if (no_symbol)
|
if (no_symbol)
|
||||||
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::Gray).p(tmp).reset();
|
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::Gray).p(tmp).reset();
|
||||||
|
|
@ -978,9 +978,9 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::BrightYellow).p(tmp).reset();
|
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::BrightYellow).p(tmp).reset();
|
||||||
|
|
||||||
tmp = "";
|
tmp = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.previousInstructionTrackedValues[i], false, 1));
|
tmp.add(String::getHexStr(minfo.previousInstructionTrackedValues[i], false, 1));
|
||||||
for (int32_t j = 1; j < data_size; j++)
|
for (int32_t j = 1; j < data_size; j++)
|
||||||
tmp.add(".").add(ostd::String::getHexStr(minfo.previousInstructionTrackedValues[i + j], false, 1));
|
tmp.add(".").add(String::getHexStr(minfo.previousInstructionTrackedValues[i + j], false, 1));
|
||||||
tmp.fixedLength(prev_len - 1);
|
tmp.fixedLength(prev_len - 1);
|
||||||
if (no_symbol)
|
if (no_symbol)
|
||||||
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::Red).p(tmp).reset();
|
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::Red).p(tmp).reset();
|
||||||
|
|
@ -988,10 +988,10 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::BrightRed).p(tmp).reset();
|
out.fg(ostd::ConsoleColors::Blue).p("|").fg(ostd::ConsoleColors::BrightRed).p(tmp).reset();
|
||||||
|
|
||||||
tmp = "";
|
tmp = "";
|
||||||
tmp.add(ostd::String::getHexStr(minfo.currentInstructionTrackedValues[i], false, 1));
|
tmp.add(String::getHexStr(minfo.currentInstructionTrackedValues[i], false, 1));
|
||||||
uint32_t tmp_i = i;
|
uint32_t tmp_i = i;
|
||||||
for (int32_t j = 1; j < data_size; j++, i++)
|
for (int32_t j = 1; j < data_size; j++, i++)
|
||||||
tmp.add(".").add(ostd::String::getHexStr(minfo.currentInstructionTrackedValues[i + 1], false, 1));
|
tmp.add(".").add(String::getHexStr(minfo.currentInstructionTrackedValues[i + 1], false, 1));
|
||||||
tmp.fixedLength(prev_len - 1);
|
tmp.fixedLength(prev_len - 1);
|
||||||
bool data_different = false;
|
bool data_different = false;
|
||||||
for (int32_t j = 0; j < data_size; j++)
|
for (int32_t j = 0; j < data_size; j++)
|
||||||
|
|
@ -1068,29 +1068,29 @@ namespace dragon
|
||||||
|
|
||||||
auto& callStack = minfo.callStack;
|
auto& callStack = minfo.callStack;
|
||||||
int32_t level = -1;
|
int32_t level = -1;
|
||||||
ostd::String ch_ang_u = "";
|
String ch_ang_u = "";
|
||||||
//TODO: Find a fix for the UTF characters
|
//TODO: Find a fix for the UTF characters
|
||||||
ch_ang_u.add("┌");
|
ch_ang_u.add("┌");
|
||||||
// ch_ang_u.addChar((unsigned char)218);
|
// ch_ang_u.addChar((unsigned char)218);
|
||||||
ostd::String ch_ang_l = "|";
|
String ch_ang_l = "|";
|
||||||
ostd::String ch_ang_d = "";
|
String ch_ang_d = "";
|
||||||
ch_ang_d.add("└");
|
ch_ang_d.add("└");
|
||||||
// ch_ang_d.addChar((unsigned char)192);
|
// ch_ang_d.addChar((unsigned char)192);
|
||||||
for (auto& call : callStack)
|
for (auto& call : callStack)
|
||||||
{
|
{
|
||||||
ostd::String call_info = call.info.new_trim().toLower();
|
String call_info = call.info.new_trim().toLower();
|
||||||
ostd::String subroutine_addr = ostd::String::getHexStr(call.addr, true, 2);
|
String subroutine_addr = String::getHexStr(call.addr, true, 2);
|
||||||
ostd::String subroutine_name = Utils::findSymbol(debugger.labels, call.addr);
|
String subroutine_name = Utils::findSymbol(debugger.labels, call.addr);
|
||||||
ostd::String call_str = "";
|
String call_str = "";
|
||||||
bool dec_lvl = false;
|
bool dec_lvl = false;
|
||||||
if (call_info == "int")
|
if (call_info == "int")
|
||||||
{
|
{
|
||||||
call_str = ch_ang_u + "int " + ostd::String::getHexStr(call.addr, true, 1);
|
call_str = ch_ang_u + "int " + String::getHexStr(call.addr, true, 1);
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
else if (call_info == "hw int")
|
else if (call_info == "hw int")
|
||||||
{
|
{
|
||||||
call_str = ch_ang_u + "hwi " + ostd::String::getHexStr(call.addr, true, 1) + " (" + data::InterruptCodes::getInterruptName(call.addr) + ")";
|
call_str = ch_ang_u + "hwi " + String::getHexStr(call.addr, true, 1) + " (" + data::InterruptCodes::getInterruptName(call.addr) + ")";
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
else if (call_info == "ret")
|
else if (call_info == "ret")
|
||||||
|
|
@ -1114,7 +1114,7 @@ namespace dragon
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::String line_str = "";
|
String line_str = "";
|
||||||
for (int32_t i = 0; i < level; i++)
|
for (int32_t i = 0; i < level; i++)
|
||||||
line_str.add("| ");
|
line_str.add("| ");
|
||||||
line_str.add(call_str);
|
line_str.add(call_str);
|
||||||
|
|
@ -1125,7 +1125,7 @@ namespace dragon
|
||||||
rgx.fg("(?<![a-zA-Z\\_\\$\\.])hwi(?! [a-zA-Z\\_\\$\\.])", "Magenta");
|
rgx.fg("(?<![a-zA-Z\\_\\$\\.])hwi(?! [a-zA-Z\\_\\$\\.])", "Magenta");
|
||||||
rgx.fg("(?<![a-zA-Z\\_\\$\\.])call|ret(?! [a-zA-Z\\_\\$\\.])", "Red");
|
rgx.fg("(?<![a-zA-Z\\_\\$\\.])call|ret(?! [a-zA-Z\\_\\$\\.])", "Red");
|
||||||
rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "BrightYellow"); //Number Constants
|
rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "BrightYellow"); //Number Constants
|
||||||
rgx.fg(ostd::String("[\\").add(ch_ang_u).add("\\|\\").add(ch_ang_d).add("]"), "darkgray");
|
rgx.fg(String("[\\").add(ch_ang_u).add("\\|\\").add(ch_ang_d).add("]"), "darkgray");
|
||||||
rgx.fg("\\$\\w+", "Green"); //Labels
|
rgx.fg("\\$\\w+", "Green"); //Labels
|
||||||
|
|
||||||
out.fg(ostd::ConsoleColors::BrightGray).p("|").reset();
|
out.fg(ostd::ConsoleColors::BrightGray).p("|").reset();
|
||||||
|
|
@ -1133,7 +1133,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::BrightGray);
|
out.fg(ostd::ConsoleColors::BrightGray);
|
||||||
else
|
else
|
||||||
out.fg(ostd::ConsoleColors::Magenta);
|
out.fg(ostd::ConsoleColors::Magenta);
|
||||||
out.p(ostd::String::getHexStr(call.inst_addr, true, 2));
|
out.p(String::getHexStr(call.inst_addr, true, 2));
|
||||||
out.fg(ostd::ConsoleColors::BrightGray).p("| > ").reset();
|
out.fg(ostd::ConsoleColors::BrightGray).p("| > ").reset();
|
||||||
out.pStyled(rgx).nl().reset();
|
out.pStyled(rgx).nl().reset();
|
||||||
|
|
||||||
|
|
@ -1153,7 +1153,7 @@ namespace dragon
|
||||||
Utils::printFullLine('#', ostd::ConsoleColors::Black, ostd::ConsoleColors::Red);
|
Utils::printFullLine('#', ostd::ConsoleColors::Black, ostd::ConsoleColors::Red);
|
||||||
|
|
||||||
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available commands:").reset().nl();
|
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available commands:").reset().nl();
|
||||||
ostd::String tmpCommand = "(d)iff-view";
|
String tmpCommand = "(d)iff-view";
|
||||||
tmpCommand.addRightPadding(commandLength);
|
tmpCommand.addRightPadding(commandLength);
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show the state of the machine, comparing the current cycle with the last.").reset().nl();
|
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show the state of the machine, comparing the current cycle with the last.").reset().nl();
|
||||||
tmpCommand = "(q)uit";
|
tmpCommand = "(q)uit";
|
||||||
|
|
@ -1188,7 +1188,7 @@ namespace dragon
|
||||||
Utils::isEscapeKeyPressed(true);
|
Utils::isEscapeKeyPressed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::String Debugger::Display::changeScreen(void)
|
String Debugger::Display::changeScreen(void)
|
||||||
{
|
{
|
||||||
if (debugger.command == "diff-view" || debugger.command == "d")
|
if (debugger.command == "diff-view" || debugger.command == "d")
|
||||||
{
|
{
|
||||||
|
|
@ -1207,7 +1207,7 @@ namespace dragon
|
||||||
else if (debugger.command.startsWith("stack") || debugger.command.startsWith("s"))
|
else if (debugger.command.startsWith("stack") || debugger.command.startsWith("s"))
|
||||||
{
|
{
|
||||||
uint16_t default_stack_rows = 8;
|
uint16_t default_stack_rows = 8;
|
||||||
ostd::String params = debugger.command.new_trim();
|
String params = debugger.command.new_trim();
|
||||||
if (params == "stack" || params == "s")
|
if (params == "stack" || params == "s")
|
||||||
printStack(default_stack_rows);
|
printStack(default_stack_rows);
|
||||||
else if (params.contains(" "))
|
else if (params.contains(" "))
|
||||||
|
|
@ -1250,7 +1250,7 @@ namespace dragon
|
||||||
while (dragon::data::ErrorHandler::hasError())
|
while (dragon::data::ErrorHandler::hasError())
|
||||||
{
|
{
|
||||||
auto err = dragon::data::ErrorHandler::popError();
|
auto err = dragon::data::ErrorHandler::popError();
|
||||||
out.nl().fg(ostd::ConsoleColors::Red).p("Error ").p(ostd::String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl();
|
out.nl().fg(ostd::ConsoleColors::Red).p("Error ").p(String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl();
|
||||||
}
|
}
|
||||||
debugger.args.step_exec = true;
|
debugger.args.step_exec = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1273,7 +1273,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
for (int32_t i = 2; i < argc; i++)
|
for (int32_t i = 2; i < argc; i++)
|
||||||
{
|
{
|
||||||
ostd::String edit(argv[i]);
|
String edit(argv[i]);
|
||||||
if (edit == "--verbose-load")
|
if (edit == "--verbose-load")
|
||||||
debugger.args.verbose_load = true;
|
debugger.args.verbose_load = true;
|
||||||
else if (edit == "--step-exec")
|
else if (edit == "--step-exec")
|
||||||
|
|
@ -1311,12 +1311,15 @@ namespace dragon
|
||||||
|
|
||||||
int32_t Debugger::initRuntime(void)
|
int32_t Debugger::initRuntime(void)
|
||||||
{
|
{
|
||||||
int32_t init_state = dragon::DragonRuntime::initMachine(debugger.args.machine_config_path,
|
|
||||||
debugger.args.verbose_load,
|
dragon::DragonRuntime::tRuntimeInitInfo initInfo;
|
||||||
debugger.args.track_step_diff,
|
initInfo.configFilePath = debugger.args.machine_config_path;
|
||||||
debugger.args.hide_virtual_display,
|
initInfo.verboseLoad = debugger.args.verbose_load;
|
||||||
debugger.args.track_call_stack,
|
initInfo.trackMachineInfoDiff = debugger.args.track_step_diff;
|
||||||
true); //CPU Debug Mode Enabled
|
initInfo.hideVirtualDisplay = debugger.args.hide_virtual_display;
|
||||||
|
initInfo.trackCallStack = debugger.args.track_call_stack;
|
||||||
|
initInfo.debugModeEnabled = true;
|
||||||
|
int32_t init_state = dragon::DragonRuntime::initMachine(initInfo);
|
||||||
closeEventListener.init();
|
closeEventListener.init();
|
||||||
if (init_state != 0) return init_state; //TODO: Error
|
if (init_state != 0) return init_state; //TODO: Error
|
||||||
|
|
||||||
|
|
@ -1331,9 +1334,9 @@ namespace dragon
|
||||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::String Debugger::getCommandInput(void)
|
String Debugger::getCommandInput(void)
|
||||||
{
|
{
|
||||||
ostd::String cmd;
|
String cmd;
|
||||||
ostd::KeyboardController kbc;
|
ostd::KeyboardController kbc;
|
||||||
ostd::eKeys key = ostd::eKeys::NoKeyPressed;
|
ostd::eKeys key = ostd::eKeys::NoKeyPressed;
|
||||||
|
|
||||||
|
|
@ -1344,7 +1347,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
return kbc.getInputString();
|
return kbc.getInputString();
|
||||||
|
|
||||||
// ostd::String cmd;
|
// String cmd;
|
||||||
// std::getline(std::cin, cmd.cpp_str_ref());
|
// std::getline(std::cin, cmd.cpp_str_ref());
|
||||||
// return cmd;
|
// return cmd;
|
||||||
}
|
}
|
||||||
|
|
@ -1472,7 +1475,7 @@ namespace dragon
|
||||||
uint8_t type = TYPE_WORD;
|
uint8_t type = TYPE_WORD;
|
||||||
if (data().command.contains(" "))
|
if (data().command.contains(" "))
|
||||||
{
|
{
|
||||||
ostd::String size_str = data().command.new_substr(0, data().command.indexOf(" ")).trim();
|
String size_str = data().command.new_substr(0, data().command.indexOf(" ")).trim();
|
||||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
||||||
if (size_str == "byte") type = TYPE_BYTE;
|
if (size_str == "byte") type = TYPE_BYTE;
|
||||||
else if (size_str == "word") type = TYPE_WORD;
|
else if (size_str == "word") type = TYPE_WORD;
|
||||||
|
|
@ -1486,15 +1489,15 @@ namespace dragon
|
||||||
type = TYPE_WORD;
|
type = TYPE_WORD;
|
||||||
uint16_t addr = data().command.toInt();
|
uint16_t addr = data().command.toInt();
|
||||||
uint16_t end_addr = addr;
|
uint16_t end_addr = addr;
|
||||||
ostd::String tmp = "";
|
String tmp = "";
|
||||||
tmp.add("*(").add(ostd::String::getHexStr(addr, true, 2));
|
tmp.add("*(").add(String::getHexStr(addr, true, 2));
|
||||||
if (type != TYPE_BYTE)
|
if (type != TYPE_BYTE)
|
||||||
{
|
{
|
||||||
end_addr = addr + type - 1;
|
end_addr = addr + type - 1;
|
||||||
if (end_addr < addr)
|
if (end_addr < addr)
|
||||||
end_addr = addr;
|
end_addr = addr;
|
||||||
else
|
else
|
||||||
tmp.add("-").add(ostd::String::getHexStr(end_addr, true, 2));
|
tmp.add("-").add(String::getHexStr(end_addr, true, 2));
|
||||||
}
|
}
|
||||||
tmp.add(")");
|
tmp.add(")");
|
||||||
ostd::RegexRichString rgx(tmp);
|
ostd::RegexRichString rgx(tmp);
|
||||||
|
|
@ -1507,7 +1510,7 @@ namespace dragon
|
||||||
for (uint16_t a = addr; a <= end_addr; a++)
|
for (uint16_t a = addr; a <= end_addr; a++)
|
||||||
{
|
{
|
||||||
uint8_t value = DragonRuntime::memMap.read8(a);
|
uint8_t value = DragonRuntime::memMap.read8(a);
|
||||||
output().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
|
output().fg(ostd::ConsoleColors::BrightRed).p(String::getHexStr(value, true, 1));
|
||||||
if (a < end_addr)
|
if (a < end_addr)
|
||||||
output().p(" ");
|
output().p(" ");
|
||||||
}
|
}
|
||||||
|
|
@ -1524,10 +1527,10 @@ namespace dragon
|
||||||
output().fg(ostd::ConsoleColors::Red).p("Unknown symbol for <print> command.").reset().nl();
|
output().fg(ostd::ConsoleColors::Red).p("Unknown symbol for <print> command.").reset().nl();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ostd::String tmp = "";
|
String tmp = "";
|
||||||
tmp.add("*(").add(ostd::String::getHexStr(addr, true, 2));
|
tmp.add("*(").add(String::getHexStr(addr, true, 2));
|
||||||
if (size > 1)
|
if (size > 1)
|
||||||
tmp.add("-").add(ostd::String::getHexStr((uint16_t)(addr + size - 1), true, 2));
|
tmp.add("-").add(String::getHexStr((uint16_t)(addr + size - 1), true, 2));
|
||||||
tmp.add(")");
|
tmp.add(")");
|
||||||
ostd::RegexRichString rgx(tmp);
|
ostd::RegexRichString rgx(tmp);
|
||||||
rgx.fg("\\(|\\)|-", "darkgray");
|
rgx.fg("\\(|\\)|-", "darkgray");
|
||||||
|
|
@ -1546,7 +1549,7 @@ namespace dragon
|
||||||
output().fg(ostd::ConsoleColors::BrightRed).pChar((char)value);
|
output().fg(ostd::ConsoleColors::BrightRed).pChar((char)value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
output().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
|
output().fg(ostd::ConsoleColors::BrightRed).p(String::getHexStr(value, true, 1));
|
||||||
if (a < addr + size - 1)
|
if (a < addr + size - 1)
|
||||||
output().p(" ");
|
output().p(" ");
|
||||||
}
|
}
|
||||||
|
|
@ -1590,12 +1593,12 @@ namespace dragon
|
||||||
if (Utils::isBreakPoint(addr))
|
if (Utils::isBreakPoint(addr))
|
||||||
{
|
{
|
||||||
Utils::removeBreakPoint(addr);
|
Utils::removeBreakPoint(addr);
|
||||||
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
|
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(String::getHexStr(addr, true, 2)).reset().nl();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils::addBreakPoint(addr);
|
Utils::addBreakPoint(addr);
|
||||||
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
|
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(String::getHexStr(addr, true, 2)).reset().nl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Display::printPrompt();
|
Display::printPrompt();
|
||||||
|
|
@ -1655,7 +1658,7 @@ namespace dragon
|
||||||
else if (data().command.contains("[") && data().command.endsWith("]"))
|
else if (data().command.contains("[") && data().command.endsWith("]"))
|
||||||
{
|
{
|
||||||
uint16_t nbytes = 1;
|
uint16_t nbytes = 1;
|
||||||
ostd::String str_nbytes = data().command.new_substr(data().command.indexOf("[") + 1).trim();
|
String str_nbytes = data().command.new_substr(data().command.indexOf("[") + 1).trim();
|
||||||
str_nbytes.substr(0, str_nbytes.len() - 1);
|
str_nbytes.substr(0, str_nbytes.len() - 1);
|
||||||
data().command.substr(0, data().command.indexOf("[")).trim();
|
data().command.substr(0, data().command.indexOf("[")).trim();
|
||||||
if (str_nbytes.isNumeric())
|
if (str_nbytes.isNumeric())
|
||||||
|
|
@ -1678,7 +1681,7 @@ namespace dragon
|
||||||
Utils::printFullLine('#', ostd::ConsoleColors::Black, ostd::ConsoleColors::Red);
|
Utils::printFullLine('#', ostd::ConsoleColors::Black, ostd::ConsoleColors::Red);
|
||||||
|
|
||||||
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available commands:").reset().nl();
|
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available commands:").reset().nl();
|
||||||
ostd::String tmpCommand = "(r)un";
|
String tmpCommand = "(r)un";
|
||||||
tmpCommand.addRightPadding(commandLength);
|
tmpCommand.addRightPadding(commandLength);
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to start the runtime.").reset().nl();
|
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to start the runtime.").reset().nl();
|
||||||
tmpCommand = "(q)uit";
|
tmpCommand = "(q)uit";
|
||||||
|
|
@ -1709,7 +1712,7 @@ namespace dragon
|
||||||
int32_t commandLength = 46;
|
int32_t commandLength = 46;
|
||||||
|
|
||||||
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
|
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
|
||||||
ostd::String tmpCommand = "--verbose-load";
|
String tmpCommand = "--verbose-load";
|
||||||
tmpCommand.addRightPadding(commandLength);
|
tmpCommand.addRightPadding(commandLength);
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show more information while loading the virtual machine.").reset().nl();
|
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show more information while loading the virtual machine.").reset().nl();
|
||||||
tmpCommand = "--step-exec";
|
tmpCommand = "--step-exec";
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace dragon
|
||||||
public: struct tCommandLineArgs
|
public: struct tCommandLineArgs
|
||||||
{
|
{
|
||||||
inline tCommandLineArgs(void) { }
|
inline tCommandLineArgs(void) { }
|
||||||
ostd::String machine_config_path = "";
|
String machine_config_path = "";
|
||||||
bool verbose_load = false;
|
bool verbose_load = false;
|
||||||
bool force_load = false;
|
bool force_load = false;
|
||||||
bool step_exec = false;
|
bool step_exec = false;
|
||||||
|
|
@ -21,7 +21,7 @@ namespace dragon
|
||||||
bool hide_virtual_display = true;
|
bool hide_virtual_display = true;
|
||||||
bool track_call_stack = true;
|
bool track_call_stack = true;
|
||||||
bool auto_track_all_data_symbols = true;
|
bool auto_track_all_data_symbols = true;
|
||||||
ostd::String force_load_file = "";
|
String force_load_file = "";
|
||||||
uint16_t force_load_mem_offset = 0x00;
|
uint16_t force_load_mem_offset = 0x00;
|
||||||
};
|
};
|
||||||
public: struct tDebuggerData
|
public: struct tDebuggerData
|
||||||
|
|
@ -32,11 +32,11 @@ namespace dragon
|
||||||
DisassemblyList labels;
|
DisassemblyList labels;
|
||||||
DisassemblyList data;
|
DisassemblyList data;
|
||||||
std::vector<uint16_t> trackedAddresses;
|
std::vector<uint16_t> trackedAddresses;
|
||||||
ostd::String command;
|
String command;
|
||||||
int32_t labelLineLength { 40 };
|
int32_t labelLineLength { 40 };
|
||||||
uint16_t currentAddress { 0 };
|
uint16_t currentAddress { 0 };
|
||||||
bool userQuit { false };
|
bool userQuit { false };
|
||||||
ostd::String disassemblyDirectory { "disassembly" };
|
String disassemblyDirectory { "disassembly" };
|
||||||
std::vector<uint16_t> manualBreakPoints;
|
std::vector<uint16_t> manualBreakPoints;
|
||||||
};
|
};
|
||||||
struct tCloseEventListener : public ostd::BaseObject
|
struct tCloseEventListener : public ostd::BaseObject
|
||||||
|
|
@ -52,8 +52,8 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DisassemblyList findCodeRegion(const DisassemblyList& code, uint16_t address, uint16_t codeRegionMargin);
|
static DisassemblyList findCodeRegion(const DisassemblyList& code, uint16_t address, uint16_t codeRegionMargin);
|
||||||
static ostd::String findSymbol(const DisassemblyList& labels, uint16_t address, uint16_t* outSize = nullptr);
|
static String findSymbol(const DisassemblyList& labels, uint16_t address, uint16_t* outSize = nullptr);
|
||||||
static uint16_t findSymbol(const DisassemblyList& labels, const ostd::String& symbol, uint16_t* outSize = nullptr);
|
static uint16_t findSymbol(const DisassemblyList& labels, const String& symbol, uint16_t* outSize = nullptr);
|
||||||
static bool isValidLabelNameChar(char c);
|
static bool isValidLabelNameChar(char c);
|
||||||
static void clearConsoleLine(void);
|
static void clearConsoleLine(void);
|
||||||
static bool isEscapeKeyPressed(bool blocking = false);
|
static bool isEscapeKeyPressed(bool blocking = false);
|
||||||
|
|
@ -66,8 +66,8 @@ namespace dragon
|
||||||
public: class Display
|
public: class Display
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void colorizeInstructionBody(const ostd::String& instBody, bool currentLine, const DisassemblyList& labelList);
|
static void colorizeInstructionBody(const String& instBody, bool currentLine, const DisassemblyList& labelList);
|
||||||
static void colorCodeInstructions(const ostd::String& inst, bool currentLine, const DisassemblyList& labelList);
|
static void colorCodeInstructions(const String& inst, bool currentLine, const DisassemblyList& labelList);
|
||||||
static void printPrompt(void);
|
static void printPrompt(void);
|
||||||
static void printStep(void);
|
static void printStep(void);
|
||||||
static void printDiff(void);
|
static void printDiff(void);
|
||||||
|
|
@ -75,13 +75,13 @@ namespace dragon
|
||||||
static void printStack(uint16_t nrows);
|
static void printStack(uint16_t nrows);
|
||||||
static void printCallStack(void);
|
static void printCallStack(void);
|
||||||
static void printHelp(void);
|
static void printHelp(void);
|
||||||
static ostd::String changeScreen(void);
|
static String changeScreen(void);
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
static void processErrors(void);
|
static void processErrors(void);
|
||||||
static int32_t loadArguments(int argc, char** argv);
|
static int32_t loadArguments(int argc, char** argv);
|
||||||
static int32_t initRuntime(void);
|
static int32_t initRuntime(void);
|
||||||
static ostd::String getCommandInput(void);
|
static String getCommandInput(void);
|
||||||
static inline tDebuggerData& data(void) { return debugger; }
|
static inline tDebuggerData& data(void) { return debugger; }
|
||||||
static inline ostd::ConsoleOutputHandler& output(void) { return out; }
|
static inline ostd::ConsoleOutputHandler& output(void) { return out; }
|
||||||
static int32_t topLevelPrompt(void);
|
static int32_t topLevelPrompt(void);
|
||||||
|
|
@ -100,6 +100,6 @@ namespace dragon
|
||||||
static tCloseEventListener closeEventListener;
|
static tCloseEventListener closeEventListener;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline static const ostd::String InputCommandQuit = "//quit//";
|
inline static const String InputCommandQuit = "//quit//";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,768 +0,0 @@
|
||||||
#include "DebuggerNew.hpp"
|
|
||||||
#include <SDL2/SDL_keycode.h>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <ogfx/render/BasicRenderer.hpp>
|
|
||||||
#include <ogfx/gui/Window.hpp>
|
|
||||||
#include <ostd/io/Memory.hpp>
|
|
||||||
#include <ostd/math/Geometry.hpp>
|
|
||||||
#include <ostd/io/IOHandlers.hpp>
|
|
||||||
#include <ostd/math/Random.hpp>
|
|
||||||
#include <ostd/string/String.hpp>
|
|
||||||
#include <ostd/utils/Signals.hpp>
|
|
||||||
#include "DisassemblyLoader.hpp"
|
|
||||||
#include "../runtime/DragonRuntime.hpp"
|
|
||||||
|
|
||||||
namespace ogfx
|
|
||||||
{
|
|
||||||
namespace gui
|
|
||||||
{
|
|
||||||
CustomButton::EventListener::EventListener(CustomButton& _parent) : parent(_parent)
|
|
||||||
{
|
|
||||||
connectSignal(ostd::BuiltinSignals::KeyPressed);
|
|
||||||
connectSignal(ostd::BuiltinSignals::KeyReleased);
|
|
||||||
connectSignal(ostd::BuiltinSignals::MouseMoved);
|
|
||||||
connectSignal(ostd::BuiltinSignals::MousePressed);
|
|
||||||
connectSignal(ostd::BuiltinSignals::MouseReleased);
|
|
||||||
connectSignal(ostd::BuiltinSignals::OnGuiEvent);
|
|
||||||
connectSignal(ostd::BuiltinSignals::WindowResized);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::EventListener::handleSignal(ostd::Signal& signal)
|
|
||||||
{
|
|
||||||
if (signal.ID == ostd::BuiltinSignals::KeyPressed)
|
|
||||||
{
|
|
||||||
if (m_lastEvent != eEventType::KeyPressed)
|
|
||||||
{
|
|
||||||
m_lastEvent = eEventType::KeyPressed;
|
|
||||||
}
|
|
||||||
auto& data = (ogfx::KeyEventData&)signal.userData;
|
|
||||||
if (data.keyCode == SDLK_BACKSPACE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (data.keyCode == SDLK_LEFT)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (data.keyCode == SDLK_RIGHT)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (data.keyCode == SDLK_RETURN)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (data.keyCode == SDLK_TAB)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (signal.ID == ostd::BuiltinSignals::MouseMoved)
|
|
||||||
{
|
|
||||||
auto& data = (ogfx::MouseEventData&)signal.userData;
|
|
||||||
if (parent.contains((float)data.position_x, (float)data.position_y))
|
|
||||||
parent.m_mouseInside = true;
|
|
||||||
else
|
|
||||||
parent.m_mouseInside = false;
|
|
||||||
}
|
|
||||||
else if (signal.ID == ostd::BuiltinSignals::MousePressed)
|
|
||||||
{
|
|
||||||
auto& data = (ogfx::MouseEventData&)signal.userData;
|
|
||||||
if (data.button == ogfx::MouseEventData::eButton::Left && parent.m_gfx != nullptr && parent.m_mouseInside)
|
|
||||||
{
|
|
||||||
ostd::String text = parent.m_text;
|
|
||||||
ostd::Vec2 relativePosition = { (float)data.position_x, (float)data.position_y };
|
|
||||||
relativePosition -= (parent.getPosition());
|
|
||||||
parent.m_pressed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (signal.ID == ostd::BuiltinSignals::MouseReleased)
|
|
||||||
{
|
|
||||||
auto& data = (ogfx::MouseEventData&)signal.userData;
|
|
||||||
if (data.button == ogfx::MouseEventData::eButton::Left && parent.m_gfx != nullptr)
|
|
||||||
{
|
|
||||||
if (parent.m_pressed)
|
|
||||||
{
|
|
||||||
ActionEventData aed(parent, parent.getName(), eActionEventType::Pressed, ostd::BaseObject::InvalidRef());
|
|
||||||
ostd::SignalHandler::emitSignal(CustomButton::actionEventSignalID, ostd::Signal::Priority::RealTime, aed);
|
|
||||||
}
|
|
||||||
parent.m_pressed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onSignalHandled(signal);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CustomButton& CustomButton::create(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name)
|
|
||||||
{
|
|
||||||
setPosition(position);
|
|
||||||
setSize(size);
|
|
||||||
m_name = name;
|
|
||||||
m_eventListener = new EventListener(*this); //TODO: Delete -- Memory Leak
|
|
||||||
m_theme = tDefaultThemes::DefaultTheme;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::render(ogfx::BasicRenderer2D& gfx)
|
|
||||||
{
|
|
||||||
m_gfx = &gfx;
|
|
||||||
ostd::Color backgroundColor = m_theme.backgroundColor;
|
|
||||||
ostd::Color borderColor = m_theme.borderColor;
|
|
||||||
ostd::Color textColor = m_theme.textColor;
|
|
||||||
if (m_pressed)
|
|
||||||
{
|
|
||||||
backgroundColor = m_theme.backgroundColor_Pressed;
|
|
||||||
borderColor = m_theme.borderColor_Pressed;
|
|
||||||
textColor = m_theme.textColor_Pressed;
|
|
||||||
}
|
|
||||||
else if (m_mouseInside)
|
|
||||||
{
|
|
||||||
backgroundColor = m_theme.backgroundColor_Hover;
|
|
||||||
borderColor = m_theme.borderColor_Hover;
|
|
||||||
textColor = m_theme.textColor_Hover;
|
|
||||||
}
|
|
||||||
gfx.outlinedRect(*this, backgroundColor, borderColor, 2);
|
|
||||||
if (m_text.len() > 0)
|
|
||||||
{
|
|
||||||
ostd::IPoint strSize = gfx.getStringDimensions(m_text, m_theme.fontSize);
|
|
||||||
ostd::Vec2 txtPos = getPosition() + ostd::Vec2 { (getw() / 2.0f) - (strSize.x / 2.0f), (geth() / 2.0f) - (strSize.y / 2.0f) };
|
|
||||||
gfx.drawString(m_text, txtPos, textColor, m_theme.fontSize);
|
|
||||||
}
|
|
||||||
onRender(gfx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::update(void)
|
|
||||||
{
|
|
||||||
onUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::fixedUpdate(void)
|
|
||||||
{
|
|
||||||
onFixedUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::setText(const ostd::String& text)
|
|
||||||
{
|
|
||||||
m_text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::appendText(const ostd::String& text)
|
|
||||||
{
|
|
||||||
m_text.add(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomButton::setTheme(Theme theme)
|
|
||||||
{
|
|
||||||
m_theme = theme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace dragon
|
|
||||||
{
|
|
||||||
//DebuggerNew::Utils
|
|
||||||
DisassemblyList DebuggerNew::findCodeRegion(const DisassemblyList& code, uint16_t address, uint16_t codeRegionMargin)
|
|
||||||
{
|
|
||||||
if (code.size() <= (codeRegionMargin * 2) + 1) return code;
|
|
||||||
std::vector<dragon::code::Assembler::tDisassemblyLine> codeRegion;
|
|
||||||
uint16_t start = 0;
|
|
||||||
uint16_t end = (codeRegionMargin * 2);
|
|
||||||
for (int32_t i = 0; i < code.size(); i++)
|
|
||||||
{
|
|
||||||
if (code[i].addr != address) continue;
|
|
||||||
if (i + 1 <= codeRegionMargin) break;
|
|
||||||
if (code.size() - (i + 1) < codeRegionMargin)
|
|
||||||
{
|
|
||||||
end = code.size() - 1;
|
|
||||||
start = end - ((codeRegionMargin * 2) + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
start = i - codeRegionMargin;
|
|
||||||
end = i + codeRegionMargin;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for (int16_t i = start; i <= end; i++)
|
|
||||||
codeRegion.push_back(code[i]);
|
|
||||||
return codeRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
ostd::String DebuggerNew::findSymbol(const DisassemblyList& list, uint16_t address, uint16_t* outSize)
|
|
||||||
{
|
|
||||||
for (auto& line : list)
|
|
||||||
{
|
|
||||||
if (line.addr == address)
|
|
||||||
{
|
|
||||||
if (outSize != nullptr)
|
|
||||||
*outSize = line.size;
|
|
||||||
return line.code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t DebuggerNew::findSymbol(const DisassemblyList& list, const ostd::String& symbol, uint16_t* outSize)
|
|
||||||
{
|
|
||||||
for (auto& line : list)
|
|
||||||
{
|
|
||||||
if (line.code == symbol)
|
|
||||||
{
|
|
||||||
if (outSize != nullptr)
|
|
||||||
*outSize = line.size;
|
|
||||||
return line.addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0x0000;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DebuggerNew::isValidLabelNameChar(char c)
|
|
||||||
{
|
|
||||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::removeBreakPoint(uint16_t addr)
|
|
||||||
{
|
|
||||||
if (debugger.manualBreakPoints.size() == 0)
|
|
||||||
return;
|
|
||||||
int32_t i = 0;
|
|
||||||
for ( ; i < debugger.manualBreakPoints.size(); i++)
|
|
||||||
{
|
|
||||||
if (debugger.manualBreakPoints[i] == addr)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= debugger.manualBreakPoints.size())
|
|
||||||
return;
|
|
||||||
debugger.manualBreakPoints.erase(debugger.manualBreakPoints.begin() + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DebuggerNew::isBreakPoint(uint16_t addr)
|
|
||||||
{
|
|
||||||
for (const auto& b : debugger.manualBreakPoints)
|
|
||||||
if (b == addr) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::addBreakPoint(uint16_t addr)
|
|
||||||
{
|
|
||||||
debugger.manualBreakPoints.push_back(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Debugger
|
|
||||||
void DebuggerNew::processErrors(void)
|
|
||||||
{
|
|
||||||
if (!dragon::DragonRuntime::hasError()) return;
|
|
||||||
while (dragon::data::ErrorHandler::hasError())
|
|
||||||
{
|
|
||||||
auto err = dragon::data::ErrorHandler::popError();
|
|
||||||
out().nl().fg(ostd::ConsoleColors::Red).p("Error ").p(ostd::String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl();
|
|
||||||
}
|
|
||||||
debugger.args.step_exec = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t DebuggerNew::loadArguments(int argc, char** argv)
|
|
||||||
{
|
|
||||||
if (argc < 2)
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Error: too few arguments.").nl();
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Use the --help option for more info.").reset().nl();
|
|
||||||
return DragonRuntime::RETURN_VAL_TOO_FEW_ARGUMENTS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
debugger.args.machine_config_path = argv[1];
|
|
||||||
if (debugger.args.machine_config_path == "--help")
|
|
||||||
{
|
|
||||||
// print_application_help();
|
|
||||||
return DragonRuntime::RETURN_VAL_CLOSE_DEBUGGER;
|
|
||||||
}
|
|
||||||
for (int32_t i = 2; i < argc; i++)
|
|
||||||
{
|
|
||||||
ostd::String edit(argv[i]);
|
|
||||||
if (edit == "--verbose-load")
|
|
||||||
debugger.args.verbose_load = true;
|
|
||||||
else if (edit == "--step-exec")
|
|
||||||
debugger.args.step_exec = true;
|
|
||||||
else if (edit == "--track-step-diff-off")
|
|
||||||
debugger.args.track_step_diff = false;
|
|
||||||
else if (edit == "--auto-track-data-off")
|
|
||||||
debugger.args.auto_track_all_data_symbols = false;
|
|
||||||
else if (edit == "--hide-vdisplay")
|
|
||||||
debugger.args.hide_virtual_display = true;
|
|
||||||
else if (edit == "--auto-start")
|
|
||||||
debugger.args.auto_start_debug = true;
|
|
||||||
else if (edit == "--force-load")
|
|
||||||
{
|
|
||||||
if ((argc - 1) - i < 2)
|
|
||||||
return DragonRuntime::RETURN_VAL_MISSING_PARAM;
|
|
||||||
i++;
|
|
||||||
debugger.args.force_load_file = argv[i];
|
|
||||||
i++;
|
|
||||||
edit = argv[i];
|
|
||||||
if (!edit.isNumeric())
|
|
||||||
return DragonRuntime::RETURN_VAL_PARAMETER_NOT_NUMERIC;
|
|
||||||
debugger.args.force_load_mem_offset = (uint16_t)edit.toInt();
|
|
||||||
debugger.args.force_load = true;
|
|
||||||
}
|
|
||||||
else if (edit == "--help")
|
|
||||||
{
|
|
||||||
// print_application_help();
|
|
||||||
return DragonRuntime::RETURN_VAL_CLOSE_DEBUGGER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t DebuggerNew::initRuntime(void)
|
|
||||||
{
|
|
||||||
int32_t init_state = dragon::DragonRuntime::initMachine(debugger.args.machine_config_path,
|
|
||||||
debugger.args.verbose_load,
|
|
||||||
debugger.args.track_step_diff,
|
|
||||||
debugger.args.hide_virtual_display,
|
|
||||||
debugger.args.track_call_stack,
|
|
||||||
true); //CPU Debug Mode Enabled
|
|
||||||
// closeEventListener.init();
|
|
||||||
if (init_state != 0) return init_state; //TODO: Error
|
|
||||||
|
|
||||||
if (debugger.args.force_load)
|
|
||||||
dragon::DragonRuntime::forceLoad(debugger.args.force_load_file, debugger.args.force_load_mem_offset);
|
|
||||||
|
|
||||||
dragon::DisassemblyLoader::loadDirectory(debugger.disassemblyDirectory);
|
|
||||||
debugger.code = dragon::DisassemblyLoader::getCodeTable();
|
|
||||||
debugger.labels = dragon::DisassemblyLoader::getLabelTable();
|
|
||||||
debugger.data = dragon::DisassemblyLoader::getDataTable();
|
|
||||||
|
|
||||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ostd::String DebuggerNew::getCommandInput(void)
|
|
||||||
{
|
|
||||||
// ostd::String cmd;
|
|
||||||
// ostd::KeyboardController kbc;
|
|
||||||
// ostd::eKeys key = ostd::eKeys::NoKeyPressed;
|
|
||||||
|
|
||||||
// while ((key = kbc.getPressedKey()) != ostd::eKeys::Enter)
|
|
||||||
// {
|
|
||||||
// if (key == ostd::eKeys::Escape)
|
|
||||||
// return InputCommandQuit;
|
|
||||||
// }
|
|
||||||
// return kbc.getInputString();
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t DebuggerNew::executeRuntime(void)
|
|
||||||
{
|
|
||||||
int32_t rValue = 0;
|
|
||||||
bool userQuit = false;
|
|
||||||
out().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl();
|
|
||||||
if (!data().args.step_exec)
|
|
||||||
out().fg(ostd::ConsoleColors::Yellow).p("Press <Escape> to enter in step-execution mode...").reset().nl();
|
|
||||||
while (!userQuit)
|
|
||||||
{
|
|
||||||
ostd::SignalHandler::handleDelegateSignals();
|
|
||||||
// if (closeEventListener.hasHappened())
|
|
||||||
// userQuit = true;
|
|
||||||
data().command.clr();
|
|
||||||
if (!userQuit && data().args.step_exec)
|
|
||||||
rValue = step_execution(userQuit, true);
|
|
||||||
else if (!userQuit)
|
|
||||||
rValue = normal_runtime(userQuit);
|
|
||||||
data().currentAddress = DragonRuntime::cpu.readRegister(data::Registers::IP);
|
|
||||||
}
|
|
||||||
out().nl().fg(ostd::ConsoleColors::Yellow).p("Execution terminated.").nl().nl().reset();
|
|
||||||
return rValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t DebuggerNew::step_execution(bool& outUserQuit, bool exec_first_step)
|
|
||||||
{
|
|
||||||
if (exec_first_step && !DragonRuntime::cpu.isHalted())
|
|
||||||
DragonRuntime::runStep(data().trackedAddresses);
|
|
||||||
// Display::printStep();
|
|
||||||
processErrors();
|
|
||||||
if (DragonRuntime::cpu.isInDebugBreakPoint())
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Reached Debug Break Point.").reset().nl();
|
|
||||||
// Display::printPrompt();
|
|
||||||
data().command = getCommandInput();
|
|
||||||
data().command.trim().toLower();
|
|
||||||
while (data().command != "")
|
|
||||||
{
|
|
||||||
if (data().command == "q" || data().command == "quit" || data().command == InputCommandQuit)
|
|
||||||
{
|
|
||||||
out().nl();
|
|
||||||
outUserQuit = true;
|
|
||||||
data().command = "";
|
|
||||||
}
|
|
||||||
else if (data().command == "c" || data().command == "continue")
|
|
||||||
{
|
|
||||||
data().args.step_exec = false;
|
|
||||||
data().command = "";
|
|
||||||
out().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl();
|
|
||||||
out().fg(ostd::ConsoleColors::Yellow).p("Press <Escape> to enter in step-execution mode...").reset().nl();
|
|
||||||
}
|
|
||||||
else if (data().command.startsWith("p ") || data().command.startsWith("print "))
|
|
||||||
{
|
|
||||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
|
||||||
const uint8_t TYPE_STRING = 0;
|
|
||||||
const uint8_t TYPE_BYTE = 1;
|
|
||||||
const uint8_t TYPE_WORD = 2;
|
|
||||||
const uint8_t TYPE_DWORD = 4;
|
|
||||||
const uint8_t TYPE_QWORD = 8;
|
|
||||||
uint8_t type = TYPE_WORD;
|
|
||||||
if (data().command.contains(" "))
|
|
||||||
{
|
|
||||||
ostd::String size_str = data().command.new_substr(0, data().command.indexOf(" ")).trim();
|
|
||||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
|
||||||
if (size_str == "byte") type = TYPE_BYTE;
|
|
||||||
else if (size_str == "word") type = TYPE_WORD;
|
|
||||||
else if (size_str == "dword") type = TYPE_DWORD;
|
|
||||||
else if (size_str == "qword") type = TYPE_QWORD;
|
|
||||||
else if (size_str == "string") type = TYPE_STRING;
|
|
||||||
}
|
|
||||||
if (data().command.isNumeric())
|
|
||||||
{
|
|
||||||
if (type == TYPE_STRING)
|
|
||||||
type = TYPE_WORD;
|
|
||||||
uint16_t addr = data().command.toInt();
|
|
||||||
uint16_t end_addr = addr;
|
|
||||||
ostd::String tmp = "";
|
|
||||||
tmp.add("*(").add(ostd::String::getHexStr(addr, true, 2));
|
|
||||||
if (type != TYPE_BYTE)
|
|
||||||
{
|
|
||||||
end_addr = addr + type - 1;
|
|
||||||
if (end_addr < addr)
|
|
||||||
end_addr = addr;
|
|
||||||
else
|
|
||||||
tmp.add("-").add(ostd::String::getHexStr(end_addr, true, 2));
|
|
||||||
}
|
|
||||||
tmp.add(")");
|
|
||||||
ostd::RegexRichString rgx(tmp);
|
|
||||||
rgx.fg("\\(|\\)|-", "darkgray");
|
|
||||||
rgx.fg("\\*", "red");
|
|
||||||
rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "cyan"); //Number Constants
|
|
||||||
out().pStyled(rgx);
|
|
||||||
out().fg(ostd::ConsoleColors::White).p(" = ");
|
|
||||||
out().fg(ostd::ConsoleColors::Gray).p("[");
|
|
||||||
for (uint16_t a = addr; a <= end_addr; a++)
|
|
||||||
{
|
|
||||||
uint8_t value = DragonRuntime::memMap.read8(a);
|
|
||||||
out().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
|
|
||||||
if (a < end_addr)
|
|
||||||
out().p(" ");
|
|
||||||
}
|
|
||||||
out().fg(ostd::ConsoleColors::Gray).p("]");
|
|
||||||
out().reset().nl();
|
|
||||||
}
|
|
||||||
else if (data().command.startsWith("$"))
|
|
||||||
{
|
|
||||||
uint16_t size = 0;
|
|
||||||
uint16_t addr = findSymbol(debugger.data, data().command, &size);
|
|
||||||
if (addr == 0)
|
|
||||||
addr = findSymbol(debugger.labels, data().command, &size);
|
|
||||||
if (addr == 0)
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Unknown symbol for <print> command.").reset().nl();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ostd::String tmp = "";
|
|
||||||
tmp.add("*(").add(ostd::String::getHexStr(addr, true, 2));
|
|
||||||
if (size > 1)
|
|
||||||
tmp.add("-").add(ostd::String::getHexStr((uint16_t)(addr + size - 1), true, 2));
|
|
||||||
tmp.add(")");
|
|
||||||
ostd::RegexRichString rgx(tmp);
|
|
||||||
rgx.fg("\\(|\\)|-", "darkgray");
|
|
||||||
rgx.fg("\\*", "red");
|
|
||||||
rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "cyan"); //Number Constants
|
|
||||||
out().pStyled(rgx);
|
|
||||||
out().fg(ostd::ConsoleColors::White).p(" = ");
|
|
||||||
out().fg(ostd::ConsoleColors::Gray).p("[");
|
|
||||||
if (type == TYPE_STRING)
|
|
||||||
out().fg(ostd::ConsoleColors::BrightRed).p("\"");
|
|
||||||
for (uint16_t a = addr; a < addr + size; a++)
|
|
||||||
{
|
|
||||||
uint8_t value = DragonRuntime::memMap.read8(a);
|
|
||||||
if (type == TYPE_STRING)
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::BrightRed).pChar((char)value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
out().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
|
|
||||||
if (a < addr + size - 1)
|
|
||||||
out().p(" ");
|
|
||||||
}
|
|
||||||
if (type == TYPE_STRING)
|
|
||||||
out().fg(ostd::ConsoleColors::BrightRed).p("\"");
|
|
||||||
out().fg(ostd::ConsoleColors::Gray).p("]");
|
|
||||||
out().reset().nl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Invalid value for <print> command.").reset().nl();
|
|
||||||
}
|
|
||||||
// Display::printPrompt();
|
|
||||||
data().command = getCommandInput();
|
|
||||||
}
|
|
||||||
else if (data().command.startsWith("b ") || data().command.startsWith("break "))
|
|
||||||
{//0x2C1D
|
|
||||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
|
||||||
uint16_t addr = 0;
|
|
||||||
bool valid = false;
|
|
||||||
if (data().command.isNumeric())
|
|
||||||
{
|
|
||||||
addr = (uint16_t)data().command.toInt();
|
|
||||||
valid = true;
|
|
||||||
}
|
|
||||||
else if (data().command.startsWith("$"))
|
|
||||||
{
|
|
||||||
addr = findSymbol(debugger.labels, data().command);
|
|
||||||
if (addr == 0x0000 || addr == 0xFFFF)
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Invalid symbol: ").p(data().command).reset().nl();
|
|
||||||
else
|
|
||||||
valid = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("Invalid value for <break> command.").reset().nl();
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
{
|
|
||||||
if (isBreakPoint(addr))
|
|
||||||
{
|
|
||||||
removeBreakPoint(addr);
|
|
||||||
out().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addBreakPoint(addr);
|
|
||||||
out().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Display::printPrompt();
|
|
||||||
data().command = getCommandInput();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
data().command = "";//Display::changeScreen();
|
|
||||||
}
|
|
||||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t DebuggerNew::normal_runtime(bool& outUserQuit)
|
|
||||||
{
|
|
||||||
bool result = DragonRuntime::runStep(data().trackedAddresses);
|
|
||||||
if (isBreakPoint((uint16_t)DragonRuntime::cpu.readRegister(data::Registers::IP)))
|
|
||||||
{
|
|
||||||
data().args.step_exec = true;
|
|
||||||
return step_execution(outUserQuit, false);
|
|
||||||
}
|
|
||||||
bool hasError = DragonRuntime::hasError();
|
|
||||||
bool enableStepExec = !result || hasError || DragonRuntime::cpu.isInDebugBreakPoint();
|
|
||||||
data().args.step_exec = enableStepExec;
|
|
||||||
if (enableStepExec)
|
|
||||||
return step_execution(outUserQuit, false);
|
|
||||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Display
|
|
||||||
void DebuggerNew::colorizeInstructionBody(const ostd::String& instBody, bool currentLine, const DisassemblyList& labelList)
|
|
||||||
{
|
|
||||||
ostd::RegexRichString rgxrstr(instBody);
|
|
||||||
rgxrstr.fg("\\{|\\}|\\+|\\*|\\-|\\/|\\(|\\)|\\[|\\]", "Red"); //Operators
|
|
||||||
rgxrstr.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "Blue"); //Number Constants
|
|
||||||
rgxrstr.fg("(?<!\\w)(r[1-9]|r10|fl|pp|rv|fp|sp|ip|acc)(?!\\w)", "BrightGreen", true); //Registers
|
|
||||||
rgxrstr.fg("\\%low", "Magenta");
|
|
||||||
rgxrstr.col("\\$\\w+", "Cyan", "Black"); //Labels
|
|
||||||
ostd::String instEdit = rgxrstr.getRawString();
|
|
||||||
for (auto& label : labelList)
|
|
||||||
{
|
|
||||||
int32_t index = -1;
|
|
||||||
ostd::String labelEdit = label.code;
|
|
||||||
labelEdit.trim();
|
|
||||||
while ((index = instEdit.indexOf(labelEdit, index + 1)) != -1)
|
|
||||||
{
|
|
||||||
if (index + labelEdit.len() < instEdit.len() && isValidLabelNameChar(instEdit.at(index + labelEdit.len())))
|
|
||||||
continue;
|
|
||||||
ostd::String instStr = instEdit;
|
|
||||||
instStr.cpp_str_ref().replace(index, labelEdit.len(), labelEdit.cpp_str() + "[@@ style foreground:brightgray](" + ostd::String::getHexStr(label.addr, true, 2).cpp_str() + ")[@@/]");
|
|
||||||
instEdit = instStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rgxrstr.setRawString(instEdit);
|
|
||||||
m_wout.tab().pStyled(rgxrstr);
|
|
||||||
if (currentLine)
|
|
||||||
m_wout.p(" ").bg(ostd::ConsoleColors::Yellow).fg(ostd::ConsoleColors::Red).p(" <-- ");
|
|
||||||
m_wout.nl();
|
|
||||||
m_wout.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::colorCodeInstructions(const ostd::String& inst, bool currentLine, const DisassemblyList& labelList)
|
|
||||||
{
|
|
||||||
ostd::String instEditor = inst;
|
|
||||||
ostd::String instBody = "";
|
|
||||||
ostd::String instHead = inst;
|
|
||||||
instEditor.trim();
|
|
||||||
if (instEditor.contains(" "))
|
|
||||||
{
|
|
||||||
instHead = instEditor.new_substr(0, instEditor.indexOf(" "));
|
|
||||||
instBody = instEditor.new_substr(instEditor.indexOf(" "));
|
|
||||||
}
|
|
||||||
if (currentLine)
|
|
||||||
{
|
|
||||||
m_wout.bg(ostd::ConsoleColors::Yellow).fg(ostd::ConsoleColors::Red);
|
|
||||||
}
|
|
||||||
else if (instHead == "call" || instHead == "ret" || instHead == "int" || instHead == "rti")
|
|
||||||
m_wout.bg(ostd::ConsoleColors::BrightRed).fg(ostd::ConsoleColors::White);
|
|
||||||
else if (instHead == "hlt" || instHead == "debug_break")
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Red);
|
|
||||||
else if (instHead == "nop")
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Gray);
|
|
||||||
else if(instHead.isNumeric())
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Magenta);
|
|
||||||
else
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Yellow);
|
|
||||||
m_wout.p(instHead.cpp_str());
|
|
||||||
m_wout.reset();
|
|
||||||
colorizeInstructionBody(instBody, currentLine, labelList);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::printStep(void)
|
|
||||||
{
|
|
||||||
m_wout.clear();
|
|
||||||
int32_t codeRegionSpan = (m_consoleSize.y / 2) - 1;
|
|
||||||
auto codeRegion = findCodeRegion(debugger.code, debugger.currentAddress, codeRegionSpan);
|
|
||||||
for (int32_t i = 0; i < codeRegion.size(); i++)
|
|
||||||
{
|
|
||||||
auto& _da = codeRegion[i];
|
|
||||||
bool currentLine = _da.addr == debugger.currentAddress;
|
|
||||||
ostd::String label = findSymbol(debugger.labels, _da.addr);
|
|
||||||
bool specialSection = _da.code.startsWith("[") &&_da.code.endsWith("]");
|
|
||||||
label.fixedLength(debugger.labelLineLength);
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Gray).p(label.cpp_str()).p(" ");
|
|
||||||
if (currentLine)
|
|
||||||
{
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Black).bg(ostd::ConsoleColors::Yellow).p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (specialSection)
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Cyan);
|
|
||||||
else if (_da.code == "debug_break")
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Red);
|
|
||||||
else
|
|
||||||
m_wout.fg(ostd::ConsoleColors::BrightGray);
|
|
||||||
m_wout.p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ");
|
|
||||||
}
|
|
||||||
if (specialSection)
|
|
||||||
m_wout.fg(ostd::ConsoleColors::Cyan).p(_da.code.cpp_str()).nl();
|
|
||||||
colorCodeInstructions(_da.code, currentLine, debugger.labels);
|
|
||||||
m_wout.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//General
|
|
||||||
void DebuggerNew::onInitialize(void)
|
|
||||||
{
|
|
||||||
enableSignals();
|
|
||||||
connectSignal(ostd::BuiltinSignals::KeyReleased);
|
|
||||||
connectSignal(ogfx::gui::RawTextInput::actionEventSignalID);
|
|
||||||
connectSignal(ogfx::gui::CustomButton::actionEventSignalID);
|
|
||||||
|
|
||||||
// DisassemblyLoader::loadDirectory("disassembly");
|
|
||||||
// m_codeTable = DisassemblyLoader::getCodeTable();
|
|
||||||
// m_codeRandomIndex = ostd::Random::geti32(0, m_codeTable.size() - m_consoleSize.y - 1);
|
|
||||||
|
|
||||||
m_gfx.init(*this);
|
|
||||||
m_gfx.openFont("res/Courier Prime.ttf");
|
|
||||||
|
|
||||||
float w = m_consolePosition.x - 12;
|
|
||||||
float h = 40.0f;
|
|
||||||
m_textInput.create({ 0.0f, (float)(getWindowHeight() - h) }, { w, h }, "CmdTxt");
|
|
||||||
m_textInput.setEventListener(m_sigHandler);
|
|
||||||
m_textInput.getTheme().extraPaddingTop = 3;
|
|
||||||
|
|
||||||
m_testBtn.create({ 100.0f, 100.0f }, { 120.0f, 90.0f }, "TestBTN");
|
|
||||||
m_testBtn.setText("BTN");
|
|
||||||
m_testBtn.setEventListener(m_btnSigHandler);
|
|
||||||
|
|
||||||
m_wout.attachWindow(*this);
|
|
||||||
m_wout.setMonospaceFont("res/UbuntuMono-R.ttf");
|
|
||||||
m_wout.setFontSize(22);
|
|
||||||
m_wout.setConsoleMaxCharacters(m_consoleSize);
|
|
||||||
m_wout.setConsolePosition(m_consolePosition);
|
|
||||||
m_wout.setWrapMode(ogfx::GraphicsWindowOutputHandler::eWrapMode::TripleDots);
|
|
||||||
m_wout.setDefaultForegroundColor({ 180, 180, 180, 255 });
|
|
||||||
|
|
||||||
std::cout << STR_BOOL(ostd::Memory::loadByteStreamFromFile("./bios.bin", m_test)) << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::handleSignal(ostd::Signal& signal)
|
|
||||||
{
|
|
||||||
if (signal.ID == ostd::BuiltinSignals::KeyReleased)
|
|
||||||
{
|
|
||||||
auto& evtData = (ogfx::KeyEventData&)signal.userData;
|
|
||||||
if (evtData.keyCode == SDLK_ESCAPE)
|
|
||||||
close();
|
|
||||||
// else if (evtData.keyCode == SDLK_SPACE)
|
|
||||||
// m_codeRandomIndex = ostd::Random::geti32(0, m_codeTable.size() - m_consoleSize.y - 1);
|
|
||||||
}
|
|
||||||
else if (signal.ID == ogfx::gui::RawTextInput::actionEventSignalID)
|
|
||||||
{
|
|
||||||
auto& data = (ogfx::gui::RawTextInput::ActionEventData&)signal.userData;
|
|
||||||
if (data.senderName != "MainInputTXT")
|
|
||||||
return;
|
|
||||||
if (data.eventType == ogfx::gui::RawTextInput::eActionEventType::Enter)
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::Green).p(data.sender.getText()).reset().nl();
|
|
||||||
data.sender.setText("");
|
|
||||||
}
|
|
||||||
else if (data.eventType == ogfx::gui::RawTextInput::eActionEventType::Tab)
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::Red).p("TAB").reset().nl();
|
|
||||||
data.sender.appendText("TAB");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (signal.ID == ogfx::gui::CustomButton::actionEventSignalID)
|
|
||||||
{
|
|
||||||
auto& data = (ogfx::gui::CustomButton::ActionEventData&)signal.userData;
|
|
||||||
if (data.senderName != "TestBTN")
|
|
||||||
return;
|
|
||||||
if (data.eventType == ogfx::gui::CustomButton::eActionEventType::Pressed)
|
|
||||||
{
|
|
||||||
out().fg(ostd::ConsoleColors::Green).p(data.sender.getText()).reset().nl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::onRender(void)
|
|
||||||
{
|
|
||||||
m_gfx.outlinedRect(m_wout.getConsoleBounds(), { 0, 0, 20, 255 }, { 255, 255, 255, 200 }, 2);
|
|
||||||
|
|
||||||
m_wout.beginFrame();
|
|
||||||
ostd::Memory::printByteStream(m_test, 0, 16, 16, m_wout, 8, 4, "HELLO");
|
|
||||||
// printStep();
|
|
||||||
|
|
||||||
m_textInput.render(m_gfx);
|
|
||||||
// m_testBtn.render(m_gfx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::onFixedUpdate(double frameTime_s)
|
|
||||||
{
|
|
||||||
m_textInput.fixedUpdate();
|
|
||||||
m_testBtn.fixedUpdate();
|
|
||||||
// std::cout << getFPS() << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerNew::onUpdate(void)
|
|
||||||
{
|
|
||||||
m_textInput.update();
|
|
||||||
m_testBtn.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,237 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ostd/data/Color.hpp>
|
|
||||||
#include <ostd/math/Geometry.hpp>
|
|
||||||
#include <ostd/data/Types.hpp>
|
|
||||||
#include <ostd/io/IOHandlers.hpp>
|
|
||||||
#include <ogfx/gui/Window.hpp>
|
|
||||||
#include <ogfx/render/BasicRenderer.hpp>
|
|
||||||
#include <ogfx/gui/RawTextInput.hpp>
|
|
||||||
#include <ogfx/gui/WindowOutputHandler.hpp>
|
|
||||||
#include "../assembler/Assembler.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ogfx
|
|
||||||
{
|
|
||||||
namespace gui
|
|
||||||
{
|
|
||||||
class CustomButton : public ostd::Rectangle
|
|
||||||
{
|
|
||||||
public: class EventListener : public ostd::BaseObject
|
|
||||||
{
|
|
||||||
public: enum class eEventType { None = 0, MousePressed, KeyPressed, KeyReleased };
|
|
||||||
public:
|
|
||||||
EventListener(CustomButton& _parent);
|
|
||||||
virtual void handleSignal(ostd::Signal& signal) override;
|
|
||||||
inline virtual void onSignalHandled(ostd::Signal& signal) { }
|
|
||||||
inline CustomButton& getParent(void) { return parent; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
CustomButton& parent;
|
|
||||||
eEventType m_lastEvent { eEventType::None };
|
|
||||||
};
|
|
||||||
public: class Theme
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ostd::Color textColor { 0, 0, 0, 0 };
|
|
||||||
ostd::Color borderColor { 0, 0, 0, 0 };
|
|
||||||
ostd::Color backgroundColor { 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
ostd::Color textColor_Hover { 0, 0, 0, 0 };
|
|
||||||
ostd::Color borderColor_Hover { 0, 0, 0, 0 };
|
|
||||||
ostd::Color backgroundColor_Hover { 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
ostd::Color textColor_Pressed { 0, 0, 0, 0 };
|
|
||||||
ostd::Color borderColor_Pressed { 0, 0, 0, 0 };
|
|
||||||
ostd::Color backgroundColor_Pressed { 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
int32_t fontSize { 0 };
|
|
||||||
};
|
|
||||||
public: struct tDefaultThemes
|
|
||||||
{
|
|
||||||
inline static const Theme DebugTheme {
|
|
||||||
{ 220, 220, 255 }, //Text Color
|
|
||||||
{ 10, 20, 120 }, //Border Color
|
|
||||||
{ 0, 0, 22 }, //Background Color
|
|
||||||
|
|
||||||
{ 220, 220, 255 }, //Text Color Hover
|
|
||||||
{ 10, 20, 120 }, //Border Color Hover
|
|
||||||
{ 0, 0, 22 }, //Background Color Hover
|
|
||||||
|
|
||||||
{ 220, 220, 255 }, //Text Color Pressed
|
|
||||||
{ 10, 20, 120 }, //Border Color Pressed
|
|
||||||
{ 0, 0, 22 }, //Background Color Pressed
|
|
||||||
|
|
||||||
20 //Font Size
|
|
||||||
};
|
|
||||||
inline static const Theme DefaultTheme {
|
|
||||||
{ 120, 120, 180 }, //Text Color
|
|
||||||
{ 10, 20, 120 }, //Border Color
|
|
||||||
{ 0, 2, 10 }, //Background Color
|
|
||||||
|
|
||||||
{ 120, 120, 210 }, //Text Color Hover
|
|
||||||
{ 10, 20, 180 }, //Border Color Hover
|
|
||||||
{ 0, 2, 50 }, //Background Color Hover
|
|
||||||
|
|
||||||
{ 120, 120, 120 }, //Text Color Pressed
|
|
||||||
{ 10, 20, 60 }, //Border Color Pressed
|
|
||||||
{ 0, 2, 0 }, //Background Color Pressed
|
|
||||||
|
|
||||||
20 //Font Size
|
|
||||||
};
|
|
||||||
};
|
|
||||||
public: enum eActionEventType { None = 0, Pressed };
|
|
||||||
public: class ActionEventData : public ostd::BaseObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline ActionEventData(CustomButton& _sender, const ostd::String& _senderName, eActionEventType _eventType, ostd::BaseObject& _userData) :
|
|
||||||
sender(_sender),
|
|
||||||
senderName(_senderName),
|
|
||||||
eventType(_eventType),
|
|
||||||
userData(_userData)
|
|
||||||
{
|
|
||||||
setTypeName("ogfx::gui::CustomButton::ActionEventData");
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
CustomButton& sender;
|
|
||||||
ostd::String senderName { "" };
|
|
||||||
eActionEventType eventType { eActionEventType::None };
|
|
||||||
ostd::BaseObject& userData { ostd::BaseObject::InvalidRef() };
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
inline CustomButton(void) { create({ 0.0f, 0.0f }, { 200.0f, 30.0f }, "UnnamedButton"); }
|
|
||||||
inline CustomButton(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name) { create(position, size, name); }
|
|
||||||
CustomButton& create(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name);
|
|
||||||
|
|
||||||
virtual void render(ogfx::BasicRenderer2D& gfx);
|
|
||||||
virtual void update(void);
|
|
||||||
virtual void fixedUpdate(void);
|
|
||||||
|
|
||||||
virtual inline void onRender(ogfx::BasicRenderer2D& gfx) { }
|
|
||||||
virtual inline void onUpdate(void) { }
|
|
||||||
virtual inline void onFixedUpdate(void) { }
|
|
||||||
|
|
||||||
void setText(const ostd::String& text);
|
|
||||||
void appendText(const ostd::String& text);
|
|
||||||
void setTheme(Theme theme);
|
|
||||||
|
|
||||||
inline void setEventListener(EventListener& evtl) { m_eventListener = &evtl; }
|
|
||||||
inline void setName(const ostd::String& name) { m_name = name; }
|
|
||||||
|
|
||||||
inline EventListener* getEventListener(void) const { return m_eventListener; }
|
|
||||||
inline ostd::String getText(void) const { return m_text; }
|
|
||||||
inline Theme& getTheme(void) { return m_theme; }
|
|
||||||
inline ostd::String getName(void) const { return m_name; }
|
|
||||||
inline bool isMouseInside(void) const { return m_mouseInside; }
|
|
||||||
inline bool isPressed(void) const { return m_pressed; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
EventListener* m_eventListener { nullptr };
|
|
||||||
ogfx::BasicRenderer2D* m_gfx { nullptr };
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ostd::String m_name { "" };
|
|
||||||
ostd::String m_text { "" };
|
|
||||||
Theme m_theme;
|
|
||||||
bool m_mouseInside { false };
|
|
||||||
bool m_pressed { false };
|
|
||||||
|
|
||||||
public:
|
|
||||||
inline static const uint32_t actionEventSignalID { ostd::SignalHandler::newCustomSignal(12400) };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace dragon
|
|
||||||
{
|
|
||||||
typedef std::vector<dragon::code::Assembler::tDisassemblyLine> DisassemblyList;
|
|
||||||
|
|
||||||
class DebuggerNew : public ogfx::GraphicsWindow
|
|
||||||
{
|
|
||||||
public: struct tCommandLineArgs
|
|
||||||
{
|
|
||||||
inline tCommandLineArgs(void) { }
|
|
||||||
ostd::String machine_config_path = "";
|
|
||||||
bool verbose_load = false;
|
|
||||||
bool force_load = false;
|
|
||||||
bool step_exec = false;
|
|
||||||
bool track_step_diff = true;
|
|
||||||
bool auto_start_debug = false;
|
|
||||||
bool hide_virtual_display = true;
|
|
||||||
bool track_call_stack = true;
|
|
||||||
bool auto_track_all_data_symbols = true;
|
|
||||||
ostd::String force_load_file = "";
|
|
||||||
uint16_t force_load_mem_offset = 0x00;
|
|
||||||
};
|
|
||||||
public: struct tDebuggerData
|
|
||||||
{
|
|
||||||
inline tDebuggerData(void) { }
|
|
||||||
tCommandLineArgs args;
|
|
||||||
DisassemblyList code;
|
|
||||||
DisassemblyList labels;
|
|
||||||
DisassemblyList data;
|
|
||||||
std::vector<uint16_t> trackedAddresses;
|
|
||||||
ostd::String command;
|
|
||||||
int32_t labelLineLength { 40 };
|
|
||||||
uint16_t currentAddress { 0 };
|
|
||||||
bool userQuit { false };
|
|
||||||
ostd::String disassemblyDirectory { "disassembly" };
|
|
||||||
std::vector<uint16_t> manualBreakPoints;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
//Utils
|
|
||||||
DisassemblyList findCodeRegion(const DisassemblyList& code, uint16_t address, uint16_t codeRegionMargin);
|
|
||||||
ostd::String findSymbol(const DisassemblyList& labels, uint16_t address, uint16_t* outSize = nullptr);
|
|
||||||
uint16_t findSymbol(const DisassemblyList& labels, const ostd::String& symbol, uint16_t* outSize = nullptr);
|
|
||||||
bool isValidLabelNameChar(char c);
|
|
||||||
void removeBreakPoint(uint16_t addr);
|
|
||||||
bool isBreakPoint(uint16_t addr);
|
|
||||||
void addBreakPoint(uint16_t addr);
|
|
||||||
|
|
||||||
//Debugger
|
|
||||||
void processErrors(void);
|
|
||||||
int32_t loadArguments(int argc, char** argv);
|
|
||||||
int32_t initRuntime(void);
|
|
||||||
ostd::String getCommandInput(void);
|
|
||||||
inline tDebuggerData& data(void) { return debugger; }
|
|
||||||
int32_t executeRuntime(void);
|
|
||||||
int32_t step_execution(bool& outUserQuit, bool exec_first_step = true);
|
|
||||||
int32_t normal_runtime(bool& outUserQuit);
|
|
||||||
|
|
||||||
//Display
|
|
||||||
void colorizeInstructionBody(const ostd::String& instBody, bool currentLine, const DisassemblyList& labelList);
|
|
||||||
void colorCodeInstructions(const ostd::String& inst, bool currentLine, const DisassemblyList& labelList);
|
|
||||||
void printStep(void);
|
|
||||||
|
|
||||||
//General
|
|
||||||
inline DebuggerNew(void) : m_sigHandler(m_textInput, *this), m_btnSigHandler(m_testBtn) { }
|
|
||||||
void onInitialize(void) override;
|
|
||||||
void handleSignal(ostd::Signal& signal) override;
|
|
||||||
void onRender(void) override;
|
|
||||||
void onFixedUpdate(double frameTime_s) override;
|
|
||||||
void onUpdate(void) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
tDebuggerData debugger;
|
|
||||||
ogfx::gui::RawTextInput m_textInput;
|
|
||||||
ogfx::BasicRenderer2D m_gfx;
|
|
||||||
ogfx::gui::RawTextInputEventListener m_sigHandler;
|
|
||||||
ogfx::gui::RawTextInputNumberCharacterFilter m_numCharFilter;
|
|
||||||
|
|
||||||
ogfx::gui::CustomButton m_testBtn;
|
|
||||||
ogfx::gui::CustomButton::EventListener m_btnSigHandler;
|
|
||||||
|
|
||||||
ogfx::GraphicsWindowOutputHandler m_wout;
|
|
||||||
ostd::IPoint m_consoleSize { 300, 50 };
|
|
||||||
ostd::Vec2 m_consolePosition { 650, 8 };
|
|
||||||
// std::vector<code::Assembler::tDisassemblyLine> m_codeTable;
|
|
||||||
// int32_t m_codeRandomIndex { 0 };
|
|
||||||
ostd::ByteStream m_test;
|
|
||||||
|
|
||||||
public:
|
|
||||||
inline static const ostd::String InputCommandQuit = "//quit//";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
const DisassemblyTable DisassemblyTable::DefaultObject;
|
const DisassemblyTable DisassemblyTable::DefaultObject;
|
||||||
|
|
||||||
void DisassemblyTable::init(const ostd::String& filePath)
|
void DisassemblyTable::init(const String& filePath)
|
||||||
{
|
{
|
||||||
ostd::ByteStream stream;
|
ostd::ByteStream stream;
|
||||||
if (!ostd::Memory::loadByteStreamFromFile(filePath, stream))
|
if (!ostd::Memory::loadByteStreamFromFile(filePath, stream))
|
||||||
|
|
@ -32,7 +32,7 @@ namespace dragon
|
||||||
int32_t line_addr = 0;
|
int32_t line_addr = 0;
|
||||||
int16_t data_size = 1;
|
int16_t data_size = 1;
|
||||||
int8_t line_code_char = 0;
|
int8_t line_code_char = 0;
|
||||||
ostd::String header_string = "";
|
String header_string = "";
|
||||||
serializer.r_NullTerminatedString(0, header_string);
|
serializer.r_NullTerminatedString(0, header_string);
|
||||||
if (header_string != "{ DRAGON_DEBUG_DISASSEMBLY }") return;
|
if (header_string != "{ DRAGON_DEBUG_DISASSEMBLY }") return;
|
||||||
addr += (header_string.len() + 1) * ostd::tTypeSize::BYTE;
|
addr += (header_string.len() + 1) * ostd::tTypeSize::BYTE;
|
||||||
|
|
@ -42,7 +42,7 @@ namespace dragon
|
||||||
addr += ostd::tTypeSize::DWORD;
|
addr += ostd::tTypeSize::DWORD;
|
||||||
serializer.r_Word(addr, data_size);
|
serializer.r_Word(addr, data_size);
|
||||||
addr += ostd::tTypeSize::WORD;
|
addr += ostd::tTypeSize::WORD;
|
||||||
ostd::String code_line = "";
|
String code_line = "";
|
||||||
serializer.r_NullTerminatedString(addr, code_line);
|
serializer.r_NullTerminatedString(addr, code_line);
|
||||||
addr += (code_line.len() + 1) * ostd::tTypeSize::BYTE;
|
addr += (code_line.len() + 1) * ostd::tTypeSize::BYTE;
|
||||||
if (code_line == "{ DATA }")
|
if (code_line == "{ DATA }")
|
||||||
|
|
@ -66,18 +66,18 @@ namespace dragon
|
||||||
line.size = data_size;
|
line.size = data_size;
|
||||||
if (mode == MODE_CODE)
|
if (mode == MODE_CODE)
|
||||||
{
|
{
|
||||||
ostd::String codeEdit(line.code);
|
String codeEdit(line.code);
|
||||||
codeEdit.trim();
|
codeEdit.trim();
|
||||||
if (codeEdit.contains(" "))
|
if (codeEdit.contains(" "))
|
||||||
{
|
{
|
||||||
ostd::String part1 = codeEdit.new_substr(0, codeEdit.indexOf(" "));
|
String part1 = codeEdit.new_substr(0, codeEdit.indexOf(" "));
|
||||||
ostd::String part2 = codeEdit.new_substr(codeEdit.indexOf(" ") + 1);
|
String part2 = codeEdit.new_substr(codeEdit.indexOf(" ") + 1);
|
||||||
part1.trim();
|
part1.trim();
|
||||||
part2.trim();
|
part2.trim();
|
||||||
int32_t opCodeLen = 10;
|
int32_t opCodeLen = 10;
|
||||||
if (part1.len() < opCodeLen)
|
if (part1.len() < opCodeLen)
|
||||||
{
|
{
|
||||||
codeEdit = part1 + ostd::String::duplicateChar(' ', opCodeLen - part1.len()) + part2;
|
codeEdit = part1 + String::duplicateChar(' ', opCodeLen - part1.len()) + part2;
|
||||||
line.code = codeEdit;
|
line.code = codeEdit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,14 +93,14 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DisassemblyLoader::loadDirectory(const ostd::String& directoryPath)
|
void DisassemblyLoader::loadDirectory(const String& directoryPath)
|
||||||
{
|
{
|
||||||
auto list = ostd::FileSystem::listFilesInDirectory(directoryPath);
|
auto list = ostd::FileSystem::listFilesInDirectory(directoryPath);
|
||||||
for (auto& path : list)
|
for (auto& path : list)
|
||||||
loadFile(path.string());
|
loadFile(path.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisassemblyTable& DisassemblyLoader::loadFile(const ostd::String& filePath)
|
const DisassemblyTable& DisassemblyLoader::loadFile(const String& filePath)
|
||||||
{
|
{
|
||||||
DisassemblyTable table(filePath);
|
DisassemblyTable table(filePath);
|
||||||
if (!table.isInitialized()) return DisassemblyTable::DefaultObject; //TODO: Error
|
if (!table.isInitialized()) return DisassemblyTable::DefaultObject; //TODO: Error
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline DisassemblyTable(void) { m_initialized = false; }
|
inline DisassemblyTable(void) { m_initialized = false; }
|
||||||
inline DisassemblyTable(const ostd::String& filePath) { init(filePath); }
|
inline DisassemblyTable(const String& filePath) { init(filePath); }
|
||||||
void init(const ostd::String& filePath);
|
void init(const String& filePath);
|
||||||
|
|
||||||
inline const std::vector<code::Assembler::tDisassemblyLine>& getCodeTable(void) const { return m_code; }
|
inline const std::vector<code::Assembler::tDisassemblyLine>& getCodeTable(void) const { return m_code; }
|
||||||
inline const std::vector<code::Assembler::tDisassemblyLine>& getDataTable(void) const { return m_data; }
|
inline const std::vector<code::Assembler::tDisassemblyLine>& getDataTable(void) const { return m_data; }
|
||||||
|
|
@ -27,7 +27,7 @@ namespace dragon
|
||||||
std::vector<code::Assembler::tDisassemblyLine> m_labels;
|
std::vector<code::Assembler::tDisassemblyLine> m_labels;
|
||||||
std::vector<code::Assembler::tDisassemblyLine> m_data;
|
std::vector<code::Assembler::tDisassemblyLine> m_data;
|
||||||
bool m_initialized { false };
|
bool m_initialized { false };
|
||||||
ostd::String m_filePath { "" };
|
String m_filePath { "" };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const DisassemblyTable DefaultObject;
|
static const DisassemblyTable DefaultObject;
|
||||||
|
|
@ -36,8 +36,8 @@ namespace dragon
|
||||||
class DisassemblyLoader
|
class DisassemblyLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void loadDirectory(const ostd::String& directoryPath);
|
static void loadDirectory(const String& directoryPath);
|
||||||
static const DisassemblyTable& loadFile(const ostd::String& filePath);
|
static const DisassemblyTable& loadFile(const String& filePath);
|
||||||
|
|
||||||
static std::vector<code::Assembler::tDisassemblyLine> getCodeTable(void);
|
static std::vector<code::Assembler::tDisassemblyLine> getCodeTable(void);
|
||||||
static std::vector<code::Assembler::tDisassemblyLine> getDataTable(void);
|
static std::vector<code::Assembler::tDisassemblyLine> getDataTable(void);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
namespace cpuext
|
namespace cpuext
|
||||||
{
|
{
|
||||||
ostd::String ExtMov::getOpCodeString(uint8_t opCode)
|
String ExtMov::getOpCodeString(uint8_t opCode)
|
||||||
{
|
{
|
||||||
switch (opCode)
|
switch (opCode)
|
||||||
{
|
{
|
||||||
|
|
@ -467,7 +467,7 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ostd::String ExtAlu::getOpCodeString(uint8_t opCode)
|
String ExtAlu::getOpCodeString(uint8_t opCode)
|
||||||
{
|
{
|
||||||
switch (opCode)
|
switch (opCode)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace dragon
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
inline ExtMov(void) : data::CPUExtension(data::OpCodes::Ext01, "extmov") { }
|
inline ExtMov(void) : data::CPUExtension(data::OpCodes::Ext01, "extmov") { }
|
||||||
ostd::String getOpCodeString(uint8_t opCode) override;
|
String getOpCodeString(uint8_t opCode) override;
|
||||||
uint8_t getInstructionSIze(uint8_t opCode) override;
|
uint8_t getInstructionSIze(uint8_t opCode) override;
|
||||||
bool execute(VirtualCPU& vcpu) override;
|
bool execute(VirtualCPU& vcpu) override;
|
||||||
};
|
};
|
||||||
|
|
@ -94,7 +94,7 @@ namespace dragon
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
inline ExtAlu(void) : data::CPUExtension(data::OpCodes::Ext02, "extalu") { }
|
inline ExtAlu(void) : data::CPUExtension(data::OpCodes::Ext02, "extalu") { }
|
||||||
ostd::String getOpCodeString(uint8_t opCode) override;
|
String getOpCodeString(uint8_t opCode) override;
|
||||||
uint8_t getInstructionSIze(uint8_t opCode) override;
|
uint8_t getInstructionSIze(uint8_t opCode) override;
|
||||||
bool execute(VirtualCPU& vcpu) override;
|
bool execute(VirtualCPU& vcpu) override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@ namespace dragon
|
||||||
return region->device->write16(finalAddr, value);
|
return region->device->write16(finalAddr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryMapper::mapDevice(IMemoryDevice& device, uint16_t startAddr, uint16_t endAddr, bool remap, ostd::String name)
|
void MemoryMapper::mapDevice(IMemoryDevice& device, uint16_t startAddr, uint16_t endAddr, bool remap, String name)
|
||||||
{
|
{
|
||||||
m_regions.push_back({ &device, startAddr, endAddr, remap, name });
|
m_regions.push_back({ &device, startAddr, endAddr, remap, name });
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::String MemoryMapper::getMemoryRegionName(uint16_t address)
|
String MemoryMapper::getMemoryRegionName(uint16_t address)
|
||||||
{
|
{
|
||||||
tMemoryRegion* region = findRegion(address);
|
tMemoryRegion* region = findRegion(address);
|
||||||
if (region == nullptr) return "Invalid";
|
if (region == nullptr) return "Invalid";
|
||||||
|
|
@ -67,7 +67,7 @@ namespace dragon
|
||||||
if (address >= region.startAddress && address <= region.endAddress)
|
if (address >= region.startAddress && address <= region.endAddress)
|
||||||
return ®ion;
|
return ®ion;
|
||||||
}
|
}
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::MM_RegionNotFound, ostd::String("Memory device not found for address: ").add(ostd::String::getHexStr(address, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::MM_RegionNotFound, String("Memory device not found for address: ").add(String::getHexStr(address, true, 2)));
|
||||||
return nullptr; //TODO: Error
|
return nullptr; //TODO: Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace dragon
|
||||||
uint16_t startAddress { 0x0000 };
|
uint16_t startAddress { 0x0000 };
|
||||||
uint16_t endAddress { 0x0000 };
|
uint16_t endAddress { 0x0000 };
|
||||||
bool remap { false };
|
bool remap { false };
|
||||||
ostd::String name { "" };
|
String name { "" };
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -26,9 +26,9 @@ namespace dragon
|
||||||
int8_t write8(uint16_t addr, int8_t value) override;
|
int8_t write8(uint16_t addr, int8_t value) override;
|
||||||
int16_t write16(uint16_t addr, int16_t value) override;
|
int16_t write16(uint16_t addr, int16_t value) override;
|
||||||
|
|
||||||
void mapDevice(IMemoryDevice& device, uint16_t startAddr, uint16_t endAddr, bool remap = false, ostd::String name = "");
|
void mapDevice(IMemoryDevice& device, uint16_t startAddr, uint16_t endAddr, bool remap = false, String name = "");
|
||||||
|
|
||||||
ostd::String getMemoryRegionName(uint16_t address);
|
String getMemoryRegionName(uint16_t address);
|
||||||
|
|
||||||
ostd::ByteStream* getByteStream(void) override;
|
ostd::ByteStream* getByteStream(void) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ namespace dragon
|
||||||
tu = ostd::eTimeUnits::Nanoseconds;
|
tu = ostd::eTimeUnits::Nanoseconds;
|
||||||
else if (static_cast<eDebugProfilerTimeUnits>(timeUnit) == eDebugProfilerTimeUnits::Secs)
|
else if (static_cast<eDebugProfilerTimeUnits>(timeUnit) == eDebugProfilerTimeUnits::Secs)
|
||||||
tu = ostd::eTimeUnits::Seconds;
|
tu = ostd::eTimeUnits::Seconds;
|
||||||
m_profilerTimer.start(true, ostd::String("DebugProfiler [").add(ostd::String::getHexStr(id, true, 1)).add("]"), tu);
|
m_profilerTimer.start(true, String("DebugProfiler [").add(String::getHexStr(id, true, 1)).add("]"), tu);
|
||||||
m_debugProfilerStarted = true;
|
m_debugProfilerStarted = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -888,14 +888,14 @@ namespace dragon
|
||||||
case data::OpCodes::Ext15:
|
case data::OpCodes::Ext15:
|
||||||
case data::OpCodes::Ext16:
|
case data::OpCodes::Ext16:
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CPU_UnsupportedExtension, ostd::String("Unsupported Extension: ").add(ostd::String::getHexStr(inst, true, 1)));
|
data::ErrorHandler::pushError(data::ErrorCodes::CPU_UnsupportedExtension, String("Unsupported Extension: ").add(String::getHexStr(inst, true, 1)));
|
||||||
m_halt = true;
|
m_halt = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CPU_UnknownInstruction, ostd::String("Unknown instruction: ").add(ostd::String::getHexStr(inst, true, 1)));
|
data::ErrorHandler::pushError(data::ErrorCodes::CPU_UnknownInstruction, String("Unknown instruction: ").add(String::getHexStr(inst, true, 1)));
|
||||||
m_halt = true;
|
m_halt = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -907,7 +907,7 @@ namespace dragon
|
||||||
void VirtualCPU::__debug_store_stack_frame_string_on_push(void)
|
void VirtualCPU::__debug_store_stack_frame_string_on_push(void)
|
||||||
{
|
{
|
||||||
if (!m_debugModeEnabled) return;
|
if (!m_debugModeEnabled) return;
|
||||||
ostd::String stackFrameString = "";
|
String stackFrameString = "";
|
||||||
|
|
||||||
uint16_t argStartAddr = readRegister(data::Registers::SP) + 2;
|
uint16_t argStartAddr = readRegister(data::Registers::SP) + 2;
|
||||||
uint16_t argCount = m_memory.read16(argStartAddr);
|
uint16_t argCount = m_memory.read16(argStartAddr);
|
||||||
|
|
@ -916,44 +916,44 @@ namespace dragon
|
||||||
else
|
else
|
||||||
argStartAddr += (argCount * 2);
|
argStartAddr += (argCount * 2);
|
||||||
|
|
||||||
stackFrameString.add("args: ").add(ostd::String::getHexStr(argStartAddr, true, 2)).add(", argc: ").add(argCount).add("\n");
|
stackFrameString.add("args: ").add(String::getHexStr(argStartAddr, true, 2)).add(", argc: ").add(argCount).add("\n");
|
||||||
|
|
||||||
pushToStack(readRegister(data::Registers::R1));
|
pushToStack(readRegister(data::Registers::R1));
|
||||||
stackFrameString.add("R1: ").add(ostd::String::getHexStr(readRegister(data::Registers::R1), true, 2));
|
stackFrameString.add("R1: ").add(String::getHexStr(readRegister(data::Registers::R1), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R2));
|
pushToStack(readRegister(data::Registers::R2));
|
||||||
stackFrameString.add(" R2: ").add(ostd::String::getHexStr(readRegister(data::Registers::R2), true, 2));
|
stackFrameString.add(" R2: ").add(String::getHexStr(readRegister(data::Registers::R2), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R3));
|
pushToStack(readRegister(data::Registers::R3));
|
||||||
stackFrameString.add(" R3: ").add(ostd::String::getHexStr(readRegister(data::Registers::R3), true, 2));
|
stackFrameString.add(" R3: ").add(String::getHexStr(readRegister(data::Registers::R3), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R4));
|
pushToStack(readRegister(data::Registers::R4));
|
||||||
stackFrameString.add(" R4: ").add(ostd::String::getHexStr(readRegister(data::Registers::R4), true, 2));
|
stackFrameString.add(" R4: ").add(String::getHexStr(readRegister(data::Registers::R4), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R5));
|
pushToStack(readRegister(data::Registers::R5));
|
||||||
stackFrameString.add(" R5: ").add(ostd::String::getHexStr(readRegister(data::Registers::R5), true, 2));
|
stackFrameString.add(" R5: ").add(String::getHexStr(readRegister(data::Registers::R5), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R6));
|
pushToStack(readRegister(data::Registers::R6));
|
||||||
stackFrameString.add(" R6: ").add(ostd::String::getHexStr(readRegister(data::Registers::R6), true, 2));
|
stackFrameString.add(" R6: ").add(String::getHexStr(readRegister(data::Registers::R6), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R7));
|
pushToStack(readRegister(data::Registers::R7));
|
||||||
stackFrameString.add(" R7: ").add(ostd::String::getHexStr(readRegister(data::Registers::R7), true, 2));
|
stackFrameString.add(" R7: ").add(String::getHexStr(readRegister(data::Registers::R7), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R8));
|
pushToStack(readRegister(data::Registers::R8));
|
||||||
stackFrameString.add(" R8: ").add(ostd::String::getHexStr(readRegister(data::Registers::R8), true, 2));
|
stackFrameString.add(" R8: ").add(String::getHexStr(readRegister(data::Registers::R8), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R9));
|
pushToStack(readRegister(data::Registers::R9));
|
||||||
stackFrameString.add(" R9: ").add(ostd::String::getHexStr(readRegister(data::Registers::R9), true, 2));
|
stackFrameString.add(" R9: ").add(String::getHexStr(readRegister(data::Registers::R9), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::R10));
|
pushToStack(readRegister(data::Registers::R10));
|
||||||
stackFrameString.add(" R10: ").add(ostd::String::getHexStr(readRegister(data::Registers::R10), true, 2));
|
stackFrameString.add(" R10: ").add(String::getHexStr(readRegister(data::Registers::R10), true, 2));
|
||||||
stackFrameString.add("\n");
|
stackFrameString.add("\n");
|
||||||
pushToStack(readRegister(data::Registers::PP));
|
pushToStack(readRegister(data::Registers::PP));
|
||||||
stackFrameString.add("PP: ").add(ostd::String::getHexStr(readRegister(data::Registers::PP), true, 2));
|
stackFrameString.add("PP: ").add(String::getHexStr(readRegister(data::Registers::PP), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::ACC));
|
pushToStack(readRegister(data::Registers::ACC));
|
||||||
stackFrameString.add(" ACC: ").add(ostd::String::getHexStr(readRegister(data::Registers::ACC), true, 2));
|
stackFrameString.add(" ACC: ").add(String::getHexStr(readRegister(data::Registers::ACC), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::IP));
|
pushToStack(readRegister(data::Registers::IP));
|
||||||
stackFrameString.add(" IP: ").add(ostd::String::getHexStr(readRegister(data::Registers::IP), true, 2));
|
stackFrameString.add(" IP: ").add(String::getHexStr(readRegister(data::Registers::IP), true, 2));
|
||||||
pushToStack(readRegister(data::Registers::FP));
|
pushToStack(readRegister(data::Registers::FP));
|
||||||
stackFrameString.add(" FP: ").add(ostd::String::getHexStr(readRegister(data::Registers::FP), true, 2));
|
stackFrameString.add(" FP: ").add(String::getHexStr(readRegister(data::Registers::FP), true, 2));
|
||||||
stackFrameString.add("\n");
|
stackFrameString.add("\n");
|
||||||
pushToStack(m_stackFrameSize);
|
pushToStack(m_stackFrameSize);
|
||||||
stackFrameString.add("StackFrame: ").add(m_stackFrameSize).add(", ");
|
stackFrameString.add("StackFrame: ").add(m_stackFrameSize).add(", ");
|
||||||
|
|
||||||
writeRegister16(data::Registers::PP, argStartAddr);
|
writeRegister16(data::Registers::PP, argStartAddr);
|
||||||
writeRegister16(data::Registers::FP, readRegister(data::Registers::SP));
|
writeRegister16(data::Registers::FP, readRegister(data::Registers::SP));
|
||||||
stackFrameString.add("New FP: ").add(ostd::String::getHexStr(readRegister(data::Registers::FP), true, 2));
|
stackFrameString.add("New FP: ").add(String::getHexStr(readRegister(data::Registers::FP), true, 2));
|
||||||
m_stackFrameSize = 0;
|
m_stackFrameSize = 0;
|
||||||
|
|
||||||
m_debug_stackFrameStrings.push_back(stackFrameString);
|
m_debug_stackFrameStrings.push_back(stackFrameString);
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ namespace dragon
|
||||||
data::CPUExtension* m_currentExtension { nullptr };
|
data::CPUExtension* m_currentExtension { nullptr };
|
||||||
uint8_t m_currentExtInst { 0x00 };
|
uint8_t m_currentExtInst { 0x00 };
|
||||||
|
|
||||||
std::vector<ostd::String> m_debug_stackFrameStrings;
|
std::vector<String> m_debug_stackFrameStrings;
|
||||||
|
|
||||||
ostd::Counter m_profilerTimer;
|
ostd::Counter m_profilerTimer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace dragon
|
||||||
ostd::Color foreground = m_text16_Currentpalette->getColor(cell.foregroundColor);
|
ostd::Color foreground = m_text16_Currentpalette->getColor(cell.foregroundColor);
|
||||||
char character = static_cast<char>(cell.character);
|
char character = static_cast<char>(cell.character);
|
||||||
auto xy = CONVERT_1D_2D(i, ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_H);
|
auto xy = CONVERT_1D_2D(i, ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_H);
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(character), xy.x, xy.y, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, foreground, background);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(character), xy.x, xy.y, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, foreground, background);
|
||||||
}
|
}
|
||||||
m_refreshScreen = false;
|
m_refreshScreen = false;
|
||||||
}
|
}
|
||||||
|
|
@ -225,11 +225,11 @@ namespace dragon
|
||||||
uint8_t invert_colors = mem.read8(vga_addr + tRegisters::TextSingleInvertColors);
|
uint8_t invert_colors = mem.read8(vga_addr + tRegisters::TextSingleInvertColors);
|
||||||
if (m_singleTextLines.size() == 0)
|
if (m_singleTextLines.size() == 0)
|
||||||
{
|
{
|
||||||
m_singleTextLines.push_back(ostd::String().addChar(c));
|
m_singleTextLines.push_back(String().addChar(c));
|
||||||
if (invert_colors == 0)
|
if (invert_colors == 0)
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(c), 0, 0, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(c), 0, 0, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
||||||
else
|
else
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(c), 0, 0, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(c), 0, 0, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto& line = m_singleTextLines[m_singleTextLines.size() - 1];
|
auto& line = m_singleTextLines[m_singleTextLines.size() - 1];
|
||||||
|
|
@ -239,20 +239,20 @@ namespace dragon
|
||||||
{
|
{
|
||||||
if (line.len() == ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_H)
|
if (line.len() == ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_H)
|
||||||
{
|
{
|
||||||
m_singleTextLines.push_back(ostd::String().addChar(c));
|
m_singleTextLines.push_back(String().addChar(c));
|
||||||
auto& line = m_singleTextLines[m_singleTextLines.size() - 1];
|
auto& line = m_singleTextLines[m_singleTextLines.size() - 1];
|
||||||
if (invert_colors == 0)
|
if (invert_colors == 0)
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
||||||
else
|
else
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.addChar(c);
|
line.addChar(c);
|
||||||
if (invert_colors == 0)
|
if (invert_colors == 0)
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
||||||
else
|
else
|
||||||
ogfx::PixelRenderer::TextRenderer::drawString(ostd::String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
ogfx::PixelRenderer::TextRenderer::drawString(String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_font.m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace dragon
|
||||||
inline static constexpr uint8_t RedrawScreen = 0xE2;
|
inline static constexpr uint8_t RedrawScreen = 0xE2;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
inline void setFont(const ostd::String& fontPath) { m_font.init(fontPath); }
|
inline void setFont(const String& fontPath) { m_font.init(fontPath); }
|
||||||
|
|
||||||
void onInitialize(void) override;
|
void onInitialize(void) override;
|
||||||
void onDestroy(void) override;
|
void onDestroy(void) override;
|
||||||
|
|
@ -83,8 +83,8 @@ namespace dragon
|
||||||
ogfx::PixelRenderer m_renderer;
|
ogfx::PixelRenderer m_renderer;
|
||||||
ogfx::PixelRenderer::Font m_font;
|
ogfx::PixelRenderer::Font m_font;
|
||||||
|
|
||||||
std::vector<ostd::String> m_singleTextLines;
|
std::vector<String> m_singleTextLines;
|
||||||
ostd::String m_singleTextBuffer { "" };
|
String m_singleTextBuffer { "" };
|
||||||
|
|
||||||
std::vector<hw::interface::Graphics::tText16_Cell> m_text16_buffer;
|
std::vector<hw::interface::Graphics::tText16_Cell> m_text16_buffer;
|
||||||
std::vector<data::IBiosVideoPalette*> m_text16_palettes;
|
std::vector<data::IBiosVideoPalette*> m_text16_palettes;
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ namespace dragon
|
||||||
{
|
{
|
||||||
namespace hw
|
namespace hw
|
||||||
{
|
{
|
||||||
void VirtualHardDrive::init(const ostd::String& dataFilePath)
|
void VirtualHardDrive::init(const String& dataFilePath)
|
||||||
{
|
{
|
||||||
m_dataFile.open(dataFilePath.cpp_str(), std::ios::out | std::ios::in | std::ios::binary);
|
m_dataFile.open(dataFilePath.cpp_str(), std::ios::out | std::ios::in | std::ios::binary);
|
||||||
if(!m_dataFile)
|
if(!m_dataFile)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::HardDrive_UnableToMount, ostd::String("Unable to mount virtual HardDrive: ").add(dataFilePath));
|
data::ErrorHandler::pushError(data::ErrorCodes::HardDrive_UnableToMount, String("Unable to mount virtual HardDrive: ").add(dataFilePath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_fileSize = m_dataFile.tellg();
|
m_fileSize = m_dataFile.tellg();
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline VirtualHardDrive(void) { m_initialized = false; }
|
inline VirtualHardDrive(void) { m_initialized = false; }
|
||||||
inline VirtualHardDrive(const ostd::String& dataFilePath) { init(dataFilePath); }
|
inline VirtualHardDrive(const String& dataFilePath) { init(dataFilePath); }
|
||||||
void init(const ostd::String& dataFilePath);
|
void init(const String& dataFilePath);
|
||||||
|
|
||||||
bool read(uint32_t addr, uint16_t size, ostd::ByteStream& outData);
|
bool read(uint32_t addr, uint16_t size, ostd::ByteStream& outData);
|
||||||
bool write(uint32_t addr, int8_t value);
|
bool write(uint32_t addr, int8_t value);
|
||||||
|
|
|
||||||
|
|
@ -17,40 +17,40 @@ namespace dragon
|
||||||
{
|
{
|
||||||
namespace hw
|
namespace hw
|
||||||
{
|
{
|
||||||
void VirtualBIOS::init(const ostd::String& biosFilePath)
|
void VirtualBIOS::init(const String& biosFilePath)
|
||||||
{
|
{
|
||||||
bool loaded = ostd::Memory::loadByteStreamFromFile(biosFilePath, m_bios);
|
bool loaded = ostd::Memory::loadByteStreamFromFile(biosFilePath, m_bios);
|
||||||
if (!loaded)
|
if (!loaded)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_FailedToLoad, "Failed to load BIOS data.");
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_FailedToLoad, "Failed to load BIOS data.");
|
||||||
if (m_bios.size() != 4096) //TODO: Hardcoded
|
if (m_bios.size() != 4096) //TODO: Hardcoded
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidSize, ostd::String("Invalid BIOS size: ").add(ostd::String::getHexStr(m_bios.size(), true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidSize, String("Invalid BIOS size: ").add(String::getHexStr(m_bios.size(), true, 2)));
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t VirtualBIOS::read8(uint16_t addr)
|
int8_t VirtualBIOS::read8(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_bios.size())
|
if (addr >= m_bios.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Byte BIOS location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, String("Invalid Byte BIOS location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return m_bios[addr];
|
return m_bios[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t VirtualBIOS::read16(uint16_t addr)
|
int16_t VirtualBIOS::read16(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_bios.size() - 1)
|
if (addr >= m_bios.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Word BIOS location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, String("Invalid Word BIOS location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return ((m_bios[addr + 0] << 8) & 0xFF00U)
|
return ((m_bios[addr + 0] << 8) & 0xFF00U)
|
||||||
| ( m_bios[addr + 1] & 0x00FFU);
|
| ( m_bios[addr + 1] & 0x00FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t VirtualBIOS::write8(uint16_t addr, int8_t value)
|
int8_t VirtualBIOS::write8(uint16_t addr, int8_t value)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_WriteAttempt, ostd::String("Attempting to write to BIOS memory map: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_WriteAttempt, String("Attempting to write to BIOS memory map: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t VirtualBIOS::write16(uint16_t addr, int16_t value)
|
int16_t VirtualBIOS::write16(uint16_t addr, int16_t value)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_WriteAttempt, ostd::String("Attempting to write to BIOS memory map: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_WriteAttempt, String("Attempting to write to BIOS memory map: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0x0000;
|
return 0x0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,14 +73,14 @@ namespace dragon
|
||||||
int8_t InterruptVector::read8(uint16_t addr)
|
int8_t InterruptVector::read8(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size())
|
if (addr >= m_data.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Byte IntVector location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Byte IntVector location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return m_data[addr];
|
return m_data[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t InterruptVector::read16(uint16_t addr)
|
int16_t InterruptVector::read16(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size() - 1)
|
if (addr >= m_data.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word IntVector location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return ((m_data[addr + 0] << 8) & 0xFF00U)
|
return ((m_data[addr + 0] << 8) & 0xFF00U)
|
||||||
| ( m_data[addr + 1] & 0x00FFU);
|
| ( m_data[addr + 1] & 0x00FFU);
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +88,7 @@ namespace dragon
|
||||||
int8_t InterruptVector::write8(uint16_t addr, int8_t value)
|
int8_t InterruptVector::write8(uint16_t addr, int8_t value)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size())
|
if (addr >= m_data.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word IntVector location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
m_data[addr] = value;
|
m_data[addr] = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +96,7 @@ namespace dragon
|
||||||
int16_t InterruptVector::write16(uint16_t addr, int16_t value)
|
int16_t InterruptVector::write16(uint16_t addr, int16_t value)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size() - 1)
|
if (addr >= m_data.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word IntVector location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
m_data[addr + 0] = (value >> 8) & 0xFF;
|
m_data[addr + 0] = (value >> 8) & 0xFF;
|
||||||
m_data[addr + 1] = value & 0xFF;
|
m_data[addr + 1] = value & 0xFF;
|
||||||
return value;
|
return value;
|
||||||
|
|
@ -126,14 +126,14 @@ namespace dragon
|
||||||
int8_t VirtualKeyboard::read8(uint16_t addr)
|
int8_t VirtualKeyboard::read8(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size())
|
if (addr >= m_data.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Byte KeyboardController location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Byte KeyboardController location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return m_data[addr];
|
return m_data[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t VirtualKeyboard::read16(uint16_t addr)
|
int16_t VirtualKeyboard::read16(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size() - 1)
|
if (addr >= m_data.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word KeyboardController location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word KeyboardController location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return ((m_data[addr + 0] << 8) & 0xFF00U)
|
return ((m_data[addr + 0] << 8) & 0xFF00U)
|
||||||
| ( m_data[addr + 1] & 0x00FFU);
|
| ( m_data[addr + 1] & 0x00FFU);
|
||||||
}
|
}
|
||||||
|
|
@ -141,10 +141,10 @@ namespace dragon
|
||||||
int8_t VirtualKeyboard::write8(uint16_t addr, int8_t value)
|
int8_t VirtualKeyboard::write8(uint16_t addr, int8_t value)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size())
|
if (addr >= m_data.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word KeyboardController location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word KeyboardController location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
if (!DragonRuntime::cpu.isInBIOSMOde())
|
if (!DragonRuntime::cpu.isInBIOSMOde())
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, ostd::String("Attempting to write byte to KeyboardController while not in BIOS mode. Address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, String("Attempting to write byte to KeyboardController while not in BIOS mode. Address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return __write8(addr, value);
|
return __write8(addr, value);
|
||||||
|
|
@ -153,10 +153,10 @@ namespace dragon
|
||||||
int16_t VirtualKeyboard::write16(uint16_t addr, int16_t value)
|
int16_t VirtualKeyboard::write16(uint16_t addr, int16_t value)
|
||||||
{
|
{
|
||||||
if (addr >= m_data.size() - 1)
|
if (addr >= m_data.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word KeyboardController location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word KeyboardController location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
if (!DragonRuntime::cpu.isInBIOSMOde())
|
if (!DragonRuntime::cpu.isInBIOSMOde())
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, ostd::String("Attempting to write word to KeyboardController while not in BIOS mode. Address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, String("Attempting to write word to KeyboardController while not in BIOS mode. Address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return __write16(addr, value);
|
return __write16(addr, value);
|
||||||
|
|
@ -398,14 +398,14 @@ namespace dragon
|
||||||
int8_t VirtualBootloader::read8(uint16_t addr)
|
int8_t VirtualBootloader::read8(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_mbr.size())
|
if (addr >= m_mbr.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Byte MBR location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, String("Invalid Byte MBR location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return m_mbr[addr];
|
return m_mbr[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t VirtualBootloader::read16(uint16_t addr)
|
int16_t VirtualBootloader::read16(uint16_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= m_mbr.size() - 1)
|
if (addr >= m_mbr.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Word MBR location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, String("Invalid Word MBR location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return ((m_mbr[addr + 0] << 8) & 0xFF00U)
|
return ((m_mbr[addr + 0] << 8) & 0xFF00U)
|
||||||
| ( m_mbr[addr + 1] & 0x00FFU);
|
| ( m_mbr[addr + 1] & 0x00FFU);
|
||||||
}
|
}
|
||||||
|
|
@ -413,7 +413,7 @@ namespace dragon
|
||||||
int8_t VirtualBootloader::write8(uint16_t addr, int8_t value)
|
int8_t VirtualBootloader::write8(uint16_t addr, int8_t value)
|
||||||
{
|
{
|
||||||
if (addr >= m_mbr.size())
|
if (addr >= m_mbr.size())
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word IntVector location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
m_mbr[addr] = value;
|
m_mbr[addr] = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -421,7 +421,7 @@ namespace dragon
|
||||||
int16_t VirtualBootloader::write16(uint16_t addr, int16_t value)
|
int16_t VirtualBootloader::write16(uint16_t addr, int16_t value)
|
||||||
{
|
{
|
||||||
if (addr >= m_mbr.size() - 1)
|
if (addr >= m_mbr.size() - 1)
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, String("Invalid Word IntVector location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
m_mbr[addr + 0] = (value >> 8) & 0xFF;
|
m_mbr[addr + 0] = (value >> 8) & 0xFF;
|
||||||
m_mbr[addr + 1] = value & 0xFF;
|
m_mbr[addr + 1] = value & 0xFF;
|
||||||
return value;
|
return value;
|
||||||
|
|
@ -857,7 +857,7 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CMOS::init(const ostd::String& cmosFilePath)
|
void CMOS::init(const String& cmosFilePath)
|
||||||
{
|
{
|
||||||
m_size = data::MemoryMapAddresses::CMOS_End - data::MemoryMapAddresses::CMOS_Start + 1;
|
m_size = data::MemoryMapAddresses::CMOS_End - data::MemoryMapAddresses::CMOS_Start + 1;
|
||||||
m_dataFile.open(cmosFilePath.cpp_str(), std::ios::out | std::ios::in | std::ios::binary);
|
m_dataFile.open(cmosFilePath.cpp_str(), std::ios::out | std::ios::in | std::ios::binary);
|
||||||
|
|
@ -872,7 +872,7 @@ namespace dragon
|
||||||
m_dataFile.seekg( 0, std::ios::beg );
|
m_dataFile.seekg( 0, std::ios::beg );
|
||||||
if (m_fileSize != m_size)
|
if (m_fileSize != m_size)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidSize, ostd::String("Invalid virtual CMOS chhip size: ").add(m_fileSize));
|
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidSize, String("Invalid virtual CMOS chhip size: ").add(m_fileSize));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
|
|
@ -887,7 +887,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
if (addr >= m_size)
|
if (addr >= m_size)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Byte CMOS location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, String("Invalid Byte CMOS location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int8_t value = 0;
|
int8_t value = 0;
|
||||||
|
|
@ -905,7 +905,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
if (addr >= m_size - 1)
|
if (addr >= m_size - 1)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Word CMOS location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, String("Invalid Word CMOS location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int8_t b1 = read8(addr);
|
int8_t b1 = read8(addr);
|
||||||
|
|
@ -923,12 +923,12 @@ namespace dragon
|
||||||
}
|
}
|
||||||
if (addr >= m_size)
|
if (addr >= m_size)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Byte CMOS location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, String("Invalid Byte CMOS location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!DragonRuntime::cpu.isInBIOSMOde())
|
if (!DragonRuntime::cpu.isInBIOSMOde())
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, ostd::String("Attempting to write byte to CMOS while not in BIOS mode. Address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, String("Attempting to write byte to CMOS while not in BIOS mode. Address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
m_dataFile.seekp(addr);
|
m_dataFile.seekp(addr);
|
||||||
|
|
@ -945,12 +945,12 @@ namespace dragon
|
||||||
}
|
}
|
||||||
if (addr >= m_size - 1)
|
if (addr >= m_size - 1)
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Word CMOS location at address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, String("Invalid Word CMOS location at address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!DragonRuntime::cpu.isInBIOSMOde())
|
if (!DragonRuntime::cpu.isInBIOSMOde())
|
||||||
{
|
{
|
||||||
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, ostd::String("Attempting to write word to CMOS while not in BIOS mode. Address: ").add(ostd::String::getHexStr(addr, true, 2)));
|
data::ErrorHandler::pushError(data::ErrorCodes::AccessViolation_BiosModeRequired, String("Attempting to write word to CMOS while not in BIOS mode. Address: ").add(String::getHexStr(addr, true, 2)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int8_t b1 = (value >> 8) & 0xFF;
|
int8_t b1 = (value >> 8) & 0xFF;
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline VirtualBIOS(void) { m_initialized = 0; }
|
inline VirtualBIOS(void) { m_initialized = 0; }
|
||||||
inline VirtualBIOS(const ostd::String& biosFilePath) { init(biosFilePath); }
|
inline VirtualBIOS(const String& biosFilePath) { init(biosFilePath); }
|
||||||
void init(const ostd::String& biosFilePath);
|
void init(const String& biosFilePath);
|
||||||
int8_t read8(uint16_t addr) override;
|
int8_t read8(uint16_t addr) override;
|
||||||
int16_t read16(uint16_t addr) override;
|
int16_t read16(uint16_t addr) override;
|
||||||
int8_t write8(uint16_t addr, int8_t value) override;
|
int8_t write8(uint16_t addr, int8_t value) override;
|
||||||
|
|
@ -412,8 +412,8 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline CMOS(void) { m_initialized = false; }
|
inline CMOS(void) { m_initialized = false; }
|
||||||
inline CMOS(const ostd::String& cmosFilePath) { init(cmosFilePath); }
|
inline CMOS(const String& cmosFilePath) { init(cmosFilePath); }
|
||||||
void init(const ostd::String& cmosFilePath);
|
void init(const String& cmosFilePath);
|
||||||
int8_t read8(uint16_t addr) override;
|
int8_t read8(uint16_t addr) override;
|
||||||
int16_t read16(uint16_t addr) override;
|
int16_t read16(uint16_t addr) override;
|
||||||
int8_t write8(uint16_t addr, int8_t value) override;
|
int8_t write8(uint16_t addr, int8_t value) override;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace dragon
|
namespace dragon
|
||||||
{
|
{
|
||||||
const tMachineConfig MachineConfigLoader::loadConfig(const ostd::String& configFilePath)
|
const tMachineConfig MachineConfigLoader::loadConfig(const String& configFilePath)
|
||||||
{
|
{
|
||||||
tMachineConfig config;
|
tMachineConfig config;
|
||||||
ostd::TextFileBuffer file(configFilePath.cpp_str());
|
ostd::TextFileBuffer file(configFilePath.cpp_str());
|
||||||
|
|
@ -12,7 +12,7 @@ namespace dragon
|
||||||
auto lines = file.getLines();
|
auto lines = file.getLines();
|
||||||
for (auto& line : lines)
|
for (auto& line : lines)
|
||||||
{
|
{
|
||||||
ostd::String lineEdit = line;
|
String lineEdit = line;
|
||||||
if (!lineEdit.contains("=")) continue; //TODO: Warning
|
if (!lineEdit.contains("=")) continue; //TODO: Warning
|
||||||
auto tokens = lineEdit.tokenize("=");
|
auto tokens = lineEdit.tokenize("=");
|
||||||
if (tokens.count() != 2) continue; //TODO: Warning
|
if (tokens.count() != 2) continue; //TODO: Warning
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ namespace dragon
|
||||||
{
|
{
|
||||||
struct tMachineConfig
|
struct tMachineConfig
|
||||||
{
|
{
|
||||||
std::map<int32_t, ostd::String> vdisk_paths;
|
std::map<int32_t, String> vdisk_paths;
|
||||||
std::map<int32_t, data::CPUExtension*> cpuext_list;
|
std::map<int32_t, data::CPUExtension*> cpuext_list;
|
||||||
int32_t clock_rate_sec { 500 };
|
int32_t clock_rate_sec { 500 };
|
||||||
uint8_t memory_extension_pages { 0 };
|
uint8_t memory_extension_pages { 0 };
|
||||||
bool fixed_clock { true };
|
bool fixed_clock { true };
|
||||||
ostd::String bios_path;
|
String bios_path;
|
||||||
ostd::String cmos_path;
|
String cmos_path;
|
||||||
ostd::Color singleColor_background;
|
ostd::Color singleColor_background;
|
||||||
ostd::Color singleColor_foreground;
|
ostd::Color singleColor_foreground;
|
||||||
uint8_t text16_palette { 0 };
|
uint8_t text16_palette { 0 };
|
||||||
|
|
@ -32,7 +32,7 @@ namespace dragon
|
||||||
class MachineConfigLoader
|
class MachineConfigLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const tMachineConfig loadConfig(const ostd::String& configFilePath);
|
static const tMachineConfig loadConfig(const String& configFilePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const tMachineConfig& validate_machine_config(tMachineConfig& config);
|
static const tMachineConfig& validate_machine_config(tMachineConfig& config);
|
||||||
|
|
|
||||||
|
|
@ -27,39 +27,39 @@ namespace dragon
|
||||||
|
|
||||||
void DragonRuntime::printRegisters(dragon::hw::VirtualCPU& cpu)
|
void DragonRuntime::printRegisters(dragon::hw::VirtualCPU& cpu)
|
||||||
{
|
{
|
||||||
out.fg("green").p("IP: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::IP), true, 2).cpp_str());
|
out.fg("green").p("IP: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::IP), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R1: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R1), true, 2).cpp_str());
|
out.fg("yellow").p("R1: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R1), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R2: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R2), true, 2).cpp_str()).nl();
|
out.fg("yellow").p("R2: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R2), true, 2).cpp_str()).nl();
|
||||||
|
|
||||||
out.fg("green").p("SP: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::SP), true, 2).cpp_str());
|
out.fg("green").p("SP: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::SP), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R3: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R3), true, 2).cpp_str());
|
out.fg("yellow").p("R3: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R3), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R4: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R4), true, 2).cpp_str()).nl();
|
out.fg("yellow").p("R4: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R4), true, 2).cpp_str()).nl();
|
||||||
|
|
||||||
out.fg("green").p("FP: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::FP), true, 2).cpp_str());
|
out.fg("green").p("FP: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::FP), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R5: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R5), true, 2).cpp_str());
|
out.fg("yellow").p("R5: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R5), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R6: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R6), true, 2).cpp_str()).nl();
|
out.fg("yellow").p("R6: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R6), true, 2).cpp_str()).nl();
|
||||||
|
|
||||||
out.fg("green").p("RV: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::RV), true, 2).cpp_str());
|
out.fg("green").p("RV: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::RV), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R7: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R7), true, 2).cpp_str());
|
out.fg("yellow").p("R7: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R7), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R8: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R8), true, 2).cpp_str()).nl();
|
out.fg("yellow").p("R8: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R8), true, 2).cpp_str()).nl();
|
||||||
|
|
||||||
out.fg("green").p("PP: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::PP), true, 2).cpp_str());
|
out.fg("green").p("PP: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::PP), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R9: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R9), true, 2).cpp_str());
|
out.fg("yellow").p("R9: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R9), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("R10: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R10), true, 2).cpp_str()).nl();
|
out.fg("yellow").p("R10: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::R10), true, 2).cpp_str()).nl();
|
||||||
|
|
||||||
out.fg("green").p("ACC: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::ACC), true, 2).cpp_str());
|
out.fg("green").p("ACC: ").fg("white").p(String::getHexStr(cpu.readRegister(dragon::data::Registers::ACC), true, 2).cpp_str());
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.fg("yellow").p("FL: ").fg("white").p(ostd::String::getBinStr(cpu.readRegister(dragon::data::Registers::FL), true, 2).cpp_str());
|
out.fg("yellow").p("FL: ").fg("white").p(String::getBinStr(cpu.readRegister(dragon::data::Registers::FL), true, 2).cpp_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DragonRuntime::processErrors(void)
|
void DragonRuntime::processErrors(void)
|
||||||
|
|
@ -67,7 +67,7 @@ namespace dragon
|
||||||
while (dragon::data::ErrorHandler::hasError())
|
while (dragon::data::ErrorHandler::hasError())
|
||||||
{
|
{
|
||||||
auto err = dragon::data::ErrorHandler::popError();
|
auto err = dragon::data::ErrorHandler::popError();
|
||||||
out.nl().fg(ostd::ConsoleColors::Red).p("Error ").p(ostd::String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl();
|
out.nl().fg(ostd::ConsoleColors::Red).p("Error ").p(String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ namespace dragon
|
||||||
}
|
}
|
||||||
for (int32_t i = 2; i < argc; i++)
|
for (int32_t i = 2; i < argc; i++)
|
||||||
{
|
{
|
||||||
ostd::String edit(argv[i]);
|
String edit(argv[i]);
|
||||||
if (edit == "--verbose-load")
|
if (edit == "--verbose-load")
|
||||||
args.verbose_load = true;
|
args.verbose_load = true;
|
||||||
else if (edit == "--force-load")
|
else if (edit == "--force-load")
|
||||||
|
|
@ -128,188 +128,183 @@ namespace dragon
|
||||||
return RETURN_VAL_EXIT_SUCCESS;
|
return RETURN_VAL_EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t DragonRuntime::initMachine(const ostd::String& configFilePath,
|
int32_t DragonRuntime::initMachine(const tRuntimeInitInfo& info)
|
||||||
bool verbose,
|
|
||||||
bool trackMachineInfoDiff,
|
|
||||||
bool hideVirtualDisplay,
|
|
||||||
bool trackCallStack,
|
|
||||||
bool debugModeEnabled)
|
|
||||||
{
|
{
|
||||||
s_signalListener.init();
|
s_signalListener.init();
|
||||||
vKeyboard.init();
|
vKeyboard.init();
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p("Loading machine config: ").fg(ostd::ConsoleColors::BrightYellow).p(configFilePath.cpp_str()).nl();
|
out.fg(ostd::ConsoleColors::Magenta).p("Loading machine config: ").fg(ostd::ConsoleColors::BrightYellow).p(info.configFilePath.cpp_str()).nl();
|
||||||
machine_config = dragon::MachineConfigLoader::loadConfig(configFilePath);
|
machine_config = dragon::MachineConfigLoader::loadConfig(info.configFilePath);
|
||||||
if (!machine_config.isValid()) return RETURN_VAL_INVALID_MACHINE_CONFIG; //TODO: Error
|
if (!machine_config.isValid()) return RETURN_VAL_INVALID_MACHINE_CONFIG; //TODO: Error
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing virtual display:").nl();
|
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing virtual display:").nl();
|
||||||
int32_t w = ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_H * ogfx::PixelRenderer::TextRenderer::FONT_CHAR_W; //60 * 16;
|
int32_t w = ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_H * ogfx::PixelRenderer::TextRenderer::FONT_CHAR_W; //60 * 16;
|
||||||
int32_t h = ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_V * ogfx::PixelRenderer::TextRenderer::FONT_CHAR_H; //60 * 9;
|
int32_t h = ogfx::PixelRenderer::TextRenderer::CONSOLE_CHARS_V * ogfx::PixelRenderer::TextRenderer::FONT_CHAR_H; //60 * 9;
|
||||||
vDisplay.initialize(w, h, "DragonVM");
|
vDisplay.initialize(w, h, "DragonVM");
|
||||||
vDisplay.setFont("font.bmp");
|
vDisplay.setFont("font.bmp");
|
||||||
if (hideVirtualDisplay)
|
if (info.hideVirtualDisplay)
|
||||||
vDisplay.hide();
|
vDisplay.hide();
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(" Done. (").p(w).p("x").p(h).p(")");
|
out.p(" Done. (").p(w).p("x").p(h).p(")");
|
||||||
if (hideVirtualDisplay)
|
if (info.hideVirtualDisplay)
|
||||||
out.p(" - HIDDEN").nl();
|
out.p(" - HIDDEN").nl();
|
||||||
else
|
else
|
||||||
out.nl();
|
out.nl();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (machine_config.vdisk_paths.size() == 0) return RETURN_VAL_NO_DISK; //TODO: Error
|
if (machine_config.vdisk_paths.size() == 0) return RETURN_VAL_NO_DISK; //TODO: Error
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing virtual disks:").nl();
|
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing virtual disks:").nl();
|
||||||
for (auto const& disk_path : machine_config.vdisk_paths)
|
for (auto const& disk_path : machine_config.vdisk_paths)
|
||||||
{
|
{
|
||||||
vDisks[disk_path.first] = dragon::hw::VirtualHardDrive(disk_path.second);
|
vDisks[disk_path.first] = dragon::hw::VirtualHardDrive(disk_path.second);
|
||||||
vDiskInterface.connectDisk(vDisks[disk_path.first], disk_path.first);
|
vDiskInterface.connectDisk(vDisks[disk_path.first], disk_path.first);
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" Disk").p(disk_path.first).p(" connected: ").p(disk_path.second.cpp_str()).nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" Disk").p(disk_path.first).p(" connected: ").p(disk_path.second.cpp_str()).nl();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" Loading vBIOS file: ").fg(ostd::ConsoleColors::BrightYellow).p(machine_config.bios_path.cpp_str()).nl();
|
out.fg(ostd::ConsoleColors::Magenta).p(" Loading vBIOS file: ").fg(ostd::ConsoleColors::BrightYellow).p(machine_config.bios_path.cpp_str()).nl();
|
||||||
vBIOS.init(machine_config.bios_path);
|
vBIOS.init(machine_config.bios_path);
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" Loading vCMOS file: ").fg(ostd::ConsoleColors::BrightYellow).p(machine_config.cmos_path.cpp_str()).nl();
|
out.fg(ostd::ConsoleColors::Magenta).p(" Loading vCMOS file: ").fg(ostd::ConsoleColors::BrightYellow).p(machine_config.cmos_path.cpp_str()).nl();
|
||||||
vCMOS.init(machine_config.cmos_path);
|
vCMOS.init(machine_config.cmos_path);
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing Memory Mapper:").nl();
|
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing Memory Mapper:").nl();
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vBIOS: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vBIOS: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::BIOS_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::BIOS_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::BIOS_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::BIOS_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=false)").nl();
|
out.p(" (remap=false)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vBIOS, dragon::data::MemoryMapAddresses::BIOS_Start, dragon::data::MemoryMapAddresses::BIOS_End, false, "BIOS");
|
memMap.mapDevice(vBIOS, dragon::data::MemoryMapAddresses::BIOS_Start, dragon::data::MemoryMapAddresses::BIOS_End, false, "BIOS");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vCMOS: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vCMOS: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::CMOS_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::CMOS_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::CMOS_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::CMOS_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=true)").nl();
|
out.p(" (remap=true)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vCMOS, dragon::data::MemoryMapAddresses::CMOS_Start, dragon::data::MemoryMapAddresses::CMOS_End, true, "CMOS");
|
memMap.mapDevice(vCMOS, dragon::data::MemoryMapAddresses::CMOS_Start, dragon::data::MemoryMapAddresses::CMOS_End, true, "CMOS");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" intVec: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" intVec: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::IntVector_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::IntVector_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::IntVector_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::IntVector_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=true)").nl();
|
out.p(" (remap=true)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(intVec, dragon::data::MemoryMapAddresses::IntVector_Start, dragon::data::MemoryMapAddresses::IntVector_End, true, "intVec");
|
memMap.mapDevice(intVec, dragon::data::MemoryMapAddresses::IntVector_Start, dragon::data::MemoryMapAddresses::IntVector_End, true, "intVec");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vKeyboard: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vKeyboard: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=false)").nl();
|
out.p(" (remap=false)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vKeyboard, dragon::data::MemoryMapAddresses::Keyboard_Start, dragon::data::MemoryMapAddresses::Keyboard_End, true, "Keyb.");
|
memMap.mapDevice(vKeyboard, dragon::data::MemoryMapAddresses::Keyboard_Start, dragon::data::MemoryMapAddresses::Keyboard_End, true, "Keyb.");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vMouse: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vMouse: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Mouse_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::Mouse_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Mouse_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::Mouse_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=false)").nl();
|
out.p(" (remap=false)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vMouse, dragon::data::MemoryMapAddresses::Mouse_Start, dragon::data::MemoryMapAddresses::Mouse_End, false, "Mouse");
|
memMap.mapDevice(vMouse, dragon::data::MemoryMapAddresses::Mouse_Start, dragon::data::MemoryMapAddresses::Mouse_End, false, "Mouse");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vMBR: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vMBR: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::MBR_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::MBR_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::MBR_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::MBR_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=true)").nl();
|
out.p(" (remap=true)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vMBR, dragon::data::MemoryMapAddresses::MBR_Start, dragon::data::MemoryMapAddresses::MBR_End, true, "MBR");
|
memMap.mapDevice(vMBR, dragon::data::MemoryMapAddresses::MBR_Start, dragon::data::MemoryMapAddresses::MBR_End, true, "MBR");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vDiskInterface: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vDiskInterface: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=true)").nl();
|
out.p(" (remap=true)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vDiskInterface, dragon::data::MemoryMapAddresses::DiskInterface_Start, dragon::data::MemoryMapAddresses::DiskInterface_End, true, "Disk");
|
memMap.mapDevice(vDiskInterface, dragon::data::MemoryMapAddresses::DiskInterface_Start, dragon::data::MemoryMapAddresses::DiskInterface_End, true, "Disk");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vGraphicsInterface: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vGraphicsInterface: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=true)").nl();
|
out.p(" (remap=true)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vGraphicsInterface, dragon::data::MemoryMapAddresses::VideoCardInterface_Start, dragon::data::MemoryMapAddresses::VideoCardInterface_End, true, "VGA");
|
memMap.mapDevice(vGraphicsInterface, dragon::data::MemoryMapAddresses::VideoCardInterface_Start, dragon::data::MemoryMapAddresses::VideoCardInterface_End, true, "VGA");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" vSerialInterface: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" vSerialInterface: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=true)").nl();
|
out.p(" (remap=true)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(vSerialInterface, dragon::data::MemoryMapAddresses::SerialInterface_Start, dragon::data::MemoryMapAddresses::SerialInterface_End, true, "serial");
|
memMap.mapDevice(vSerialInterface, dragon::data::MemoryMapAddresses::SerialInterface_Start, dragon::data::MemoryMapAddresses::SerialInterface_End, true, "serial");
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" RAM: ");
|
out.fg(ostd::ConsoleColors::Magenta).p(" RAM: ");
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow);
|
out.fg(ostd::ConsoleColors::BrightYellow);
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Memory_Start, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::Memory_Start, true, 2).cpp_str());
|
||||||
out.p(" to ");
|
out.p(" to ");
|
||||||
out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Memory_End, true, 2).cpp_str());
|
out.p(String::getHexStr(dragon::data::MemoryMapAddresses::Memory_End, true, 2).cpp_str());
|
||||||
out.p(" (remap=false)").nl();
|
out.p(" (remap=false)").nl();
|
||||||
}
|
}
|
||||||
memMap.mapDevice(ram, dragon::data::MemoryMapAddresses::Memory_Start, dragon::data::MemoryMapAddresses::Memory_End, false, "RAM");
|
memMap.mapDevice(ram, dragon::data::MemoryMapAddresses::Memory_Start, dragon::data::MemoryMapAddresses::Memory_End, false, "RAM");
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing vCPU reset sequence:").nl();
|
out.fg(ostd::ConsoleColors::Magenta).p(" Initializing vCPU reset sequence:").nl();
|
||||||
|
|
||||||
uint16_t reset_ip_addr = 0x0000;
|
uint16_t reset_ip_addr = 0x0000;
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" Reset IP register: ").p(ostd::String::getHexStr(reset_ip_addr, true, 2).cpp_str()).nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" Reset IP register: ").p(String::getHexStr(reset_ip_addr, true, 2).cpp_str()).nl();
|
||||||
cpu.writeRegister16(dragon::data::Registers::IP, reset_ip_addr);
|
cpu.writeRegister16(dragon::data::Registers::IP, reset_ip_addr);
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" Debug mode enabled: ").p(STR_BOOL(debugModeEnabled)).nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" Debug mode enabled: ").p(STR_BOOL(info.debugModeEnabled)).nl();
|
||||||
cpu.m_debugModeEnabled = debugModeEnabled;
|
cpu.m_debugModeEnabled = info.debugModeEnabled;
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" BIOS mode enabled").nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" BIOS mode enabled").nl();
|
||||||
cpu.m_biosMode = true;
|
cpu.m_biosMode = true;
|
||||||
|
|
||||||
if (machine_config.cpuext_list.size() > 0)
|
if (machine_config.cpuext_list.size() > 0)
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" Loading CPU Extensions").nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" Loading CPU Extensions").nl();
|
||||||
for (auto& ext : machine_config.cpuext_list)
|
for (auto& ext : machine_config.cpuext_list)
|
||||||
{
|
{
|
||||||
cpu.m_extensions[ext.first] = ext.second;
|
cpu.m_extensions[ext.first] = ext.second;
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" ").p(ext.first + 1).p(": ").p(ext.second->m_name).nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" ").p(ext.first + 1).p(": ").p(ext.second->m_name).nl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" Fixed clock enabled: ").p(STR_BOOL(machine_config.fixed_clock)).nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" Fixed clock enabled: ").p(STR_BOOL(machine_config.fixed_clock)).nl();
|
||||||
if (machine_config.fixed_clock)
|
if (machine_config.fixed_clock)
|
||||||
|
|
@ -332,15 +327,15 @@ namespace dragon
|
||||||
ostd::Bits::set(disk_list_bitfield, i);
|
ostd::Bits::set(disk_list_bitfield, i);
|
||||||
}
|
}
|
||||||
vCMOS.write16(data::CMOSRegisters::DiskList, disk_list_bitfield.value);
|
vCMOS.write16(data::CMOSRegisters::DiskList, disk_list_bitfield.value);
|
||||||
if (verbose)
|
if (info.verboseLoad)
|
||||||
out.fg(ostd::ConsoleColors::BrightYellow).p(" Loading CMOS Machine info").nl();
|
out.fg(ostd::ConsoleColors::BrightYellow).p(" Loading CMOS Machine info").nl();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
out.nl().nl();
|
out.nl().nl();
|
||||||
s_trackMachineInfo = trackMachineInfoDiff;
|
s_trackMachineInfo = info.trackMachineInfoDiff;
|
||||||
s_trackCallStack = trackCallStack;
|
s_trackCallStack = info.trackCallStack;
|
||||||
return RETURN_VAL_EXIT_SUCCESS;
|
return RETURN_VAL_EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -423,7 +418,7 @@ namespace dragon
|
||||||
return running || vDiskInterface.isBusy();
|
return running || vDiskInterface.isBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DragonRuntime::forceLoad(const ostd::String& filePath, uint16_t loadAddress)
|
void DragonRuntime::forceLoad(const String& filePath, uint16_t loadAddress)
|
||||||
{
|
{
|
||||||
ostd::ByteStream code;
|
ostd::ByteStream code;
|
||||||
ostd::Memory::loadByteStreamFromFile(filePath, code);
|
ostd::Memory::loadByteStreamFromFile(filePath, code);
|
||||||
|
|
@ -467,7 +462,7 @@ namespace dragon
|
||||||
uint16_t instAddr = cpu.readRegister(data::Registers::IP);
|
uint16_t instAddr = cpu.readRegister(data::Registers::IP);
|
||||||
uint8_t int_op_code = memMap.read8(instAddr);
|
uint8_t int_op_code = memMap.read8(instAddr);
|
||||||
uint8_t instSize = data::OpCodes::getInstructionSIze(int_op_code);
|
uint8_t instSize = data::OpCodes::getInstructionSIze(int_op_code);
|
||||||
ostd::String opCode = data::OpCodes::getOpCodeString(int_op_code);
|
String opCode = data::OpCodes::getOpCodeString(int_op_code);
|
||||||
uint16_t stackFrameSize = cpu.m_stackFrameSize;
|
uint16_t stackFrameSize = cpu.m_stackFrameSize;
|
||||||
int32_t subRoutineCounter = cpu.m_subroutineCounter;
|
int32_t subRoutineCounter = cpu.m_subroutineCounter;
|
||||||
|
|
||||||
|
|
@ -566,7 +561,7 @@ namespace dragon
|
||||||
int32_t commandLength = 46;
|
int32_t commandLength = 46;
|
||||||
|
|
||||||
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
|
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
|
||||||
ostd::String tmpCommand = "--verbose-load";
|
String tmpCommand = "--verbose-load";
|
||||||
tmpCommand.addRightPadding(commandLength);
|
tmpCommand.addRightPadding(commandLength);
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show more information while loading the virtual machine.").reset().nl();
|
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show more information while loading the virtual machine.").reset().nl();
|
||||||
tmpCommand = "--force-load <binary-file> <ram-offset>";
|
tmpCommand = "--force-load <binary-file> <ram-offset>";
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,29 @@ namespace dragon
|
||||||
public: struct tCallInfo : public ostd::BaseObject
|
public: struct tCallInfo : public ostd::BaseObject
|
||||||
{
|
{
|
||||||
inline tCallInfo(void) { }
|
inline tCallInfo(void) { }
|
||||||
inline tCallInfo(const ostd::String& _info, uint16_t _addr, uint16_t _inst_addr, bool ints_disabled) : info(_info), addr(_addr), inst_addr(_inst_addr), interrupts_disabled(ints_disabled) { }
|
inline tCallInfo(const String& _info, uint16_t _addr, uint16_t _inst_addr, bool ints_disabled) : info(_info), addr(_addr), inst_addr(_inst_addr), interrupts_disabled(ints_disabled) { }
|
||||||
ostd::String info;
|
String info;
|
||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
uint16_t inst_addr;
|
uint16_t inst_addr;
|
||||||
bool interrupts_disabled;
|
bool interrupts_disabled;
|
||||||
};
|
};
|
||||||
public: struct tCommandLineArgs
|
public: struct tCommandLineArgs
|
||||||
{
|
{
|
||||||
ostd::String machine_config_path = "";
|
String machine_config_path = "";
|
||||||
bool verbose_load = false;
|
bool verbose_load = false;
|
||||||
bool force_load = false;
|
bool force_load = false;
|
||||||
ostd::String force_load_file = "";
|
String force_load_file = "";
|
||||||
uint16_t force_load_mem_offset = 0x00;
|
uint16_t force_load_mem_offset = 0x00;
|
||||||
};
|
};
|
||||||
|
public: struct tRuntimeInitInfo
|
||||||
|
{
|
||||||
|
String configFilePath;
|
||||||
|
bool verboseLoad { false };
|
||||||
|
bool trackMachineInfoDiff { false };
|
||||||
|
bool hideVirtualDisplay { false };
|
||||||
|
bool trackCallStack { false };
|
||||||
|
bool debugModeEnabled { false };
|
||||||
|
};
|
||||||
public: struct tMachineDebugInfo
|
public: struct tMachineDebugInfo
|
||||||
{
|
{
|
||||||
inline tMachineDebugInfo(void) { }
|
inline tMachineDebugInfo(void) { }
|
||||||
|
|
@ -55,8 +64,8 @@ namespace dragon
|
||||||
int32_t previousSubRoutineCounter { 0x00000000 };
|
int32_t previousSubRoutineCounter { 0x00000000 };
|
||||||
int32_t currentSubRoutineCounter { 0x00000000 };
|
int32_t currentSubRoutineCounter { 0x00000000 };
|
||||||
|
|
||||||
ostd::String previousInstructionOpCode { "" };
|
String previousInstructionOpCode { "" };
|
||||||
ostd::String currentInstructionOpCode { "" };
|
String currentInstructionOpCode { "" };
|
||||||
|
|
||||||
int8_t previousInstructionFootprint[5] { 0x00, 0x00, 0x00, 0x00, 0x00 };
|
int8_t previousInstructionFootprint[5] { 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
int8_t currentInstructionFootprint[5] { 0x00, 0x00, 0x00, 0x00, 0x00 };
|
int8_t currentInstructionFootprint[5] { 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
|
@ -86,16 +95,11 @@ namespace dragon
|
||||||
static void processErrors(void);
|
static void processErrors(void);
|
||||||
static std::vector<data::ErrorHandler::tError> getErrorList(void);
|
static std::vector<data::ErrorHandler::tError> getErrorList(void);
|
||||||
static int32_t loadArguments(int argc, char** argv, tCommandLineArgs& args);
|
static int32_t loadArguments(int argc, char** argv, tCommandLineArgs& args);
|
||||||
static int32_t initMachine(const ostd::String& configFilePath,
|
static int32_t initMachine(const tRuntimeInitInfo& info);
|
||||||
bool verbose = false,
|
|
||||||
bool trackMachineInfoDiff = false,
|
|
||||||
bool hideVirtualDisplay = false,
|
|
||||||
bool rackCallStack = false,
|
|
||||||
bool debugModeEnabled = false);
|
|
||||||
static void shutdownMachine(void);
|
static void shutdownMachine(void);
|
||||||
static void runMachine(void);
|
static void runMachine(void);
|
||||||
static bool runStep(std::vector<uint16_t> trackedAddresses = { });
|
static bool runStep(std::vector<uint16_t> trackedAddresses = { });
|
||||||
static void forceLoad(const ostd::String& filePath, uint16_t loadAddress);
|
static void forceLoad(const String& filePath, uint16_t loadAddress);
|
||||||
|
|
||||||
inline static const tMachineDebugInfo& getMachineInfoDiff(void) { return s_machineInfo; }
|
inline static const tMachineDebugInfo& getMachineInfoDiff(void) { return s_machineInfo; }
|
||||||
inline static bool hasError(void) { return data::ErrorHandler::hasError(); }
|
inline static bool hasError(void) { return data::ErrorHandler::hasError(); }
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@ int main(int argc, char** argv)
|
||||||
if (rValue != 0) return rValue;
|
if (rValue != 0) return rValue;
|
||||||
|
|
||||||
//Initializing the runtime
|
//Initializing the runtime
|
||||||
rValue = dragon::DragonRuntime::initMachine(args.machine_config_path, args.verbose_load);
|
dragon::DragonRuntime::tRuntimeInitInfo initInfo;
|
||||||
|
initInfo.configFilePath = args.machine_config_path;
|
||||||
|
initInfo.verboseLoad = args.verbose_load;
|
||||||
|
rValue = dragon::DragonRuntime::initMachine(initInfo);
|
||||||
if (rValue == dragon::DragonRuntime::RETURN_VAL_CLOSE_RUNTIME)
|
if (rValue == dragon::DragonRuntime::RETURN_VAL_CLOSE_RUNTIME)
|
||||||
return 0;
|
return 0;
|
||||||
if (rValue != 0) return rValue;
|
if (rValue != 0) return rValue;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
ostd::String OpCodes::getOpCodeString(uint8_t opCode)
|
String OpCodes::getOpCodeString(uint8_t opCode)
|
||||||
{
|
{
|
||||||
CPUExtension* ext = DragonRuntime::cpu.getCurrentCPUExtension();
|
CPUExtension* ext = DragonRuntime::cpu.getCurrentCPUExtension();
|
||||||
if (ext != nullptr)
|
if (ext != nullptr)
|
||||||
|
|
|
||||||
|
|
@ -65,11 +65,11 @@ namespace dragon
|
||||||
public: struct tError
|
public: struct tError
|
||||||
{
|
{
|
||||||
uint64_t code;
|
uint64_t code;
|
||||||
ostd::String text;
|
String text;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline static void pushError(uint64_t code, ostd::String text) { m_errorStack.push_back({ code, text }); }
|
inline static void pushError(uint64_t code, String text) { m_errorStack.push_back({ code, text }); }
|
||||||
inline static bool hasError(void) { return m_errorStack.size() > 0; }
|
inline static bool hasError(void) { return m_errorStack.size() > 0; }
|
||||||
inline static tError popError(void)
|
inline static tError popError(void)
|
||||||
{
|
{
|
||||||
|
|
@ -201,7 +201,7 @@ namespace dragon
|
||||||
|
|
||||||
inline static constexpr uint8_t Text16ModeScreenRefreshed = 0xE0;
|
inline static constexpr uint8_t Text16ModeScreenRefreshed = 0xE0;
|
||||||
|
|
||||||
inline static ostd::String getInterruptName(uint8_t code)
|
inline static String getInterruptName(uint8_t code)
|
||||||
{
|
{
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
|
|
@ -278,14 +278,14 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline virtual ~CPUExtension(void) { }
|
inline virtual ~CPUExtension(void) { }
|
||||||
inline CPUExtension(uint8_t code, ostd::String name) : m_code(code), m_name(name) { }
|
inline CPUExtension(uint8_t code, String name) : m_code(code), m_name(name) { }
|
||||||
virtual ostd::String getOpCodeString(uint8_t opCode) = 0;
|
virtual String getOpCodeString(uint8_t opCode) = 0;
|
||||||
virtual uint8_t getInstructionSIze(uint8_t opCode) = 0;
|
virtual uint8_t getInstructionSIze(uint8_t opCode) = 0;
|
||||||
virtual bool execute(hw::VirtualCPU& vcpu) = 0;
|
virtual bool execute(hw::VirtualCPU& vcpu) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint8_t m_code { 0x00 };
|
uint8_t m_code { 0x00 };
|
||||||
ostd::String m_name { "" };
|
String m_name { "" };
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpCodes
|
class OpCodes
|
||||||
|
|
@ -394,7 +394,7 @@ namespace dragon
|
||||||
inline static constexpr uint8_t Int = 0xFE;
|
inline static constexpr uint8_t Int = 0xFE;
|
||||||
inline static constexpr uint8_t Halt = 0xFF;
|
inline static constexpr uint8_t Halt = 0xFF;
|
||||||
|
|
||||||
static ostd::String getOpCodeString(uint8_t opCode);
|
static String getOpCodeString(uint8_t opCode);
|
||||||
static uint8_t getInstructionSIze(uint8_t opCode);
|
static uint8_t getInstructionSIze(uint8_t opCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace dragon
|
namespace dragon
|
||||||
{
|
{
|
||||||
bool Tools::createVirtualHardDrive(uint32_t sizeInBytes, const ostd::String& dataFilePath)
|
bool Tools::createVirtualHardDrive(uint32_t sizeInBytes, const String& dataFilePath)
|
||||||
{
|
{
|
||||||
std::ofstream rf(dataFilePath.cpp_str(), std::ios::out | std::ios::binary);
|
std::ofstream rf(dataFilePath.cpp_str(), std::ios::out | std::ios::binary);
|
||||||
if(!rf) return false;
|
if(!rf) return false;
|
||||||
|
|
@ -25,7 +25,7 @@ namespace dragon
|
||||||
|
|
||||||
int32_t Tools::execute(int argc, char** argv)
|
int32_t Tools::execute(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ostd::String tool = "";
|
String tool = "";
|
||||||
int32_t rValue = get_tool(argc, argv, tool);
|
int32_t rValue = get_tool(argc, argv, tool);
|
||||||
if (rValue != ErrorNoError)
|
if (rValue != ErrorNoError)
|
||||||
return rValue;
|
return rValue;
|
||||||
|
|
@ -82,8 +82,8 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools new-vdisk <destination_file> <size_in_bytes>").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools new-vdisk <destination_file> <size_in_bytes>").reset().nl();
|
||||||
return ErrorNewVDiskTooFewArgs;
|
return ErrorNewVDiskTooFewArgs;
|
||||||
}
|
}
|
||||||
ostd::String dest = argv[2];
|
String dest = argv[2];
|
||||||
ostd::String str_size = argv[3];
|
String str_size = argv[3];
|
||||||
if (!str_size.isInt())
|
if (!str_size.isInt())
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Red).p("Error: <size_in_bytes> parameter must be integer.").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p("Error: <size_in_bytes> parameter must be integer.").reset().nl();
|
||||||
|
|
@ -109,9 +109,9 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools load-binary <virtual_disk_file> <data_file> <destination_address>").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools load-binary <virtual_disk_file> <data_file> <destination_address>").reset().nl();
|
||||||
return ErrorLoadProgTooFewArgs;
|
return ErrorLoadProgTooFewArgs;
|
||||||
}
|
}
|
||||||
ostd::String vdisk_file = argv[2];
|
String vdisk_file = argv[2];
|
||||||
ostd::String data_file = argv[3];
|
String data_file = argv[3];
|
||||||
ostd::String str_addr = argv[4];
|
String str_addr = argv[4];
|
||||||
if (!str_addr.isInt())
|
if (!str_addr.isInt())
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Red).p("Error: <destination_address> parameter must be integer.").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p("Error: <destination_address> parameter must be integer.").reset().nl();
|
||||||
|
|
@ -140,7 +140,7 @@ namespace dragon
|
||||||
out.nl().fg(ostd::ConsoleColors::Green).p("Success. Data written to Virtual Disk:").nl();
|
out.nl().fg(ostd::ConsoleColors::Green).p("Success. Data written to Virtual Disk:").nl();
|
||||||
out.p(" Data Path: ").p(data_file.cpp_str()).nl();
|
out.p(" Data Path: ").p(data_file.cpp_str()).nl();
|
||||||
out.p(" Disk Path: ").p(vdisk_file.cpp_str()).nl();
|
out.p(" Disk Path: ").p(vdisk_file.cpp_str()).nl();
|
||||||
out.p(" Data Address: ").p(ostd::String::getHexStr(addr, true, 4).cpp_str()).nl();
|
out.p(" Data Address: ").p(String::getHexStr(addr, true, 4).cpp_str()).nl();
|
||||||
out.p(" Size: ").p(code.size()).reset().nl();
|
out.p(" Size: ").p(code.size()).reset().nl();
|
||||||
return ErrorNoError;
|
return ErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools read-dpt <virtual_disk_file>").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools read-dpt <virtual_disk_file>").reset().nl();
|
||||||
return ErrorReadDPTTooFewArgs;
|
return ErrorReadDPTTooFewArgs;
|
||||||
}
|
}
|
||||||
ostd::String vdisk_file = argv[2];
|
String vdisk_file = argv[2];
|
||||||
dragon::hw::VirtualHardDrive vHDD(vdisk_file);
|
dragon::hw::VirtualHardDrive vHDD(vdisk_file);
|
||||||
if (!vHDD.isInitialized())
|
if (!vHDD.isInitialized())
|
||||||
{
|
{
|
||||||
|
|
@ -199,7 +199,7 @@ namespace dragon
|
||||||
uint32_t startAddress { 0 };
|
uint32_t startAddress { 0 };
|
||||||
uint32_t size { 0 };
|
uint32_t size { 0 };
|
||||||
ostd::BitField_16 flags { 0 };
|
ostd::BitField_16 flags { 0 };
|
||||||
ostd::String label { "" };
|
String label { "" };
|
||||||
};
|
};
|
||||||
std::vector<tPartitionData> partitionList;
|
std::vector<tPartitionData> partitionList;
|
||||||
for (int32_t i = 0; i < part_count; i++)
|
for (int32_t i = 0; i < part_count; i++)
|
||||||
|
|
@ -219,27 +219,27 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::BrightRed).p("Disk: ").p(vdisk_file).p(" (").p(vHDD.getSize()).p(" bytes)").nl();
|
out.fg(ostd::ConsoleColors::BrightRed).p("Disk: ").p(vdisk_file).p(" (").p(vHDD.getSize()).p(" bytes)").nl();
|
||||||
auto print_part_size = [](uint32_t size, ostd::ConsoleOutputHandler& out, uint16_t line_len) {
|
auto print_part_size = [](uint32_t size, ostd::ConsoleOutputHandler& out, uint16_t line_len) {
|
||||||
double dsize = size;
|
double dsize = size;
|
||||||
ostd::String units[4] = { " bytes", " Kb", " Mb", " Gb" };
|
String units[4] = { " bytes", " Kb", " Mb", " Gb" };
|
||||||
int32_t unit_index = 0;
|
int32_t unit_index = 0;
|
||||||
while (dsize > 1024 && unit_index < 3)
|
while (dsize > 1024 && unit_index < 3)
|
||||||
{
|
{
|
||||||
unit_index++;
|
unit_index++;
|
||||||
dsize /= 1024.0;
|
dsize /= 1024.0;
|
||||||
}
|
}
|
||||||
out.p(ostd::String("").add(dsize, 2).add(units[unit_index]).new_fixedLength(line_len));
|
out.p(String("").add(dsize, 2).add(units[unit_index]).new_fixedLength(line_len));
|
||||||
};
|
};
|
||||||
uint16_t len = 20;
|
uint16_t len = 20;
|
||||||
out.nl().fg(ostd::ConsoleColors::BrightGray);
|
out.nl().fg(ostd::ConsoleColors::BrightGray);
|
||||||
out.p(ostd::String("=").new_fixedLength(5 * len, '=')).nl();
|
out.p(String("=").new_fixedLength(5 * len, '=')).nl();
|
||||||
out.fg(ostd::ConsoleColors::Blue);
|
out.fg(ostd::ConsoleColors::Blue);
|
||||||
out.p(" ");
|
out.p(" ");
|
||||||
out.p(ostd::String("LABEL").new_fixedLength(len));
|
out.p(String("LABEL").new_fixedLength(len));
|
||||||
out.p(ostd::String("SIZE").new_fixedLength(len));
|
out.p(String("SIZE").new_fixedLength(len));
|
||||||
out.p(ostd::String("START").new_fixedLength(len));
|
out.p(String("START").new_fixedLength(len));
|
||||||
out.p(ostd::String("END").new_fixedLength(len));
|
out.p(String("END").new_fixedLength(len));
|
||||||
out.p(ostd::String("FLAGS").new_fixedLength(len));
|
out.p(String("FLAGS").new_fixedLength(len));
|
||||||
out.nl().fg(ostd::ConsoleColors::BrightGray);
|
out.nl().fg(ostd::ConsoleColors::BrightGray);
|
||||||
out.p(ostd::String("=").new_fixedLength(5 * len, '=')).nl();
|
out.p(String("=").new_fixedLength(5 * len, '=')).nl();
|
||||||
for (int32_t i = 0; i < partitionList.size(); i++)
|
for (int32_t i = 0; i < partitionList.size(); i++)
|
||||||
{
|
{
|
||||||
auto& part = partitionList[i];
|
auto& part = partitionList[i];
|
||||||
|
|
@ -248,9 +248,9 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Cyan).p(" ");
|
out.fg(ostd::ConsoleColors::Cyan).p(" ");
|
||||||
out.p(part.label.new_fixedLength(len));
|
out.p(part.label.new_fixedLength(len));
|
||||||
print_part_size(part.size, out, len);
|
print_part_size(part.size, out, len);
|
||||||
out.p(ostd::String::getHexStr(part.startAddress, true, 4).new_fixedLength(len));
|
out.p(String::getHexStr(part.startAddress, true, 4).new_fixedLength(len));
|
||||||
out.p(ostd::String::getHexStr(part.startAddress + part.size, true, 4).new_fixedLength(len));
|
out.p(String::getHexStr(part.startAddress + part.size, true, 4).new_fixedLength(len));
|
||||||
ostd::String flags_str = "";
|
String flags_str = "";
|
||||||
for (uint8_t bit = 0; bit < sizeof(part.flags) * 8; bit++)
|
for (uint8_t bit = 0; bit < sizeof(part.flags) * 8; bit++)
|
||||||
{
|
{
|
||||||
if (m_dpt_flags_str.count(bit) == 0)
|
if (m_dpt_flags_str.count(bit) == 0)
|
||||||
|
|
@ -264,7 +264,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Yellow).p(flags_str).fg(ostd::ConsoleColors::Cyan).nl();
|
out.fg(ostd::ConsoleColors::Yellow).p(flags_str).fg(ostd::ConsoleColors::Cyan).nl();
|
||||||
}
|
}
|
||||||
out.fg(ostd::ConsoleColors::BrightGray);
|
out.fg(ostd::ConsoleColors::BrightGray);
|
||||||
out.p(ostd::String("=").new_fixedLength(5 * len, '=')).nl();
|
out.p(String("=").new_fixedLength(5 * len, '=')).nl();
|
||||||
out.reset().nl();
|
out.reset().nl();
|
||||||
return ErrorNoError;
|
return ErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
@ -277,7 +277,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools new-dpt <virtual_disk_file> -p -s SIZE [-l LABEL] [-f FLAG1] [-f FLAG2] [-p SIZE ...]").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools new-dpt <virtual_disk_file> -p -s SIZE [-l LABEL] [-f FLAG1] [-f FLAG2] [-p SIZE ...]").reset().nl();
|
||||||
return ErrorLoadProgTooFewArgs;
|
return ErrorLoadProgTooFewArgs;
|
||||||
}
|
}
|
||||||
ostd::String vdisk_file = argv[2];
|
String vdisk_file = argv[2];
|
||||||
dragon::hw::VirtualHardDrive vHDD(vdisk_file);
|
dragon::hw::VirtualHardDrive vHDD(vdisk_file);
|
||||||
if (!vHDD.isInitialized())
|
if (!vHDD.isInitialized())
|
||||||
{
|
{
|
||||||
|
|
@ -287,7 +287,7 @@ namespace dragon
|
||||||
uint64_t disk_size = vHDD.getSize();
|
uint64_t disk_size = vHDD.getSize();
|
||||||
|
|
||||||
auto& _dpt_flags_str = m_dpt_flags_str;
|
auto& _dpt_flags_str = m_dpt_flags_str;
|
||||||
auto get_flag_from_str = [_dpt_flags_str](const ostd::String& flag_str) -> int8_t {
|
auto get_flag_from_str = [_dpt_flags_str](const String& flag_str) -> int8_t {
|
||||||
for (auto& flag : _dpt_flags_str)
|
for (auto& flag : _dpt_flags_str)
|
||||||
{
|
{
|
||||||
if (flag.second == flag_str)
|
if (flag.second == flag_str)
|
||||||
|
|
@ -306,7 +306,7 @@ namespace dragon
|
||||||
uint32_t size { 0 };
|
uint32_t size { 0 };
|
||||||
uint32_t address { 0 };
|
uint32_t address { 0 };
|
||||||
std::vector<uint8_t> flags;
|
std::vector<uint8_t> flags;
|
||||||
ostd::String label { "" };
|
String label { "" };
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<tPartData> partitions;
|
std::vector<tPartData> partitions;
|
||||||
|
|
@ -318,7 +318,7 @@ namespace dragon
|
||||||
uint32_t part_start_addr = data::DPTStructure::DiskStartAddr;
|
uint32_t part_start_addr = data::DPTStructure::DiskStartAddr;
|
||||||
while (has_args)
|
while (has_args)
|
||||||
{
|
{
|
||||||
ostd::String arg = argv[arg_index];
|
String arg = argv[arg_index];
|
||||||
arg.trim();
|
arg.trim();
|
||||||
if (part_started)
|
if (part_started)
|
||||||
{
|
{
|
||||||
|
|
@ -365,13 +365,13 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p("Error: No partition size specified.").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p("Error: No partition size specified.").reset().nl();
|
||||||
return ErrorNewDPTNoPartitionSize;
|
return ErrorNewDPTNoPartitionSize;
|
||||||
}
|
}
|
||||||
else if (!ostd::String(argv[arg_index + 1]).isInt())
|
else if (!String(argv[arg_index + 1]).isInt())
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Red).p("Error: Partition size must be an integer.").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p("Error: Partition size must be an integer.").reset().nl();
|
||||||
return ErrorNewDPTInvalidPartitionSize;
|
return ErrorNewDPTInvalidPartitionSize;
|
||||||
}
|
}
|
||||||
arg_index++;
|
arg_index++;
|
||||||
uint32_t part_size = ostd::String(argv[arg_index]).toInt();
|
uint32_t part_size = String(argv[arg_index]).toInt();
|
||||||
if (part_start_addr + part_size > disk_size)
|
if (part_start_addr + part_size > disk_size)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::Red).p("Error: Not enough space on disk.").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p("Error: Not enough space on disk.").reset().nl();
|
||||||
|
|
@ -446,7 +446,7 @@ namespace dragon
|
||||||
vHDD.unmount();
|
vHDD.unmount();
|
||||||
out.nl().fg(ostd::ConsoleColors::Green).p("Success. DPT Block created on Virtual Disk:").nl();
|
out.nl().fg(ostd::ConsoleColors::Green).p("Success. DPT Block created on Virtual Disk:").nl();
|
||||||
out.p(" Disk Path: ").p(vdisk_file.cpp_str()).nl();
|
out.p(" Disk Path: ").p(vdisk_file.cpp_str()).nl();
|
||||||
out.p(" DPT Block Address: ").p(ostd::String::getHexStr(data::DPTStructure::DiskAddress, true, 4).cpp_str()).nl();
|
out.p(" DPT Block Address: ").p(String::getHexStr(data::DPTStructure::DiskAddress, true, 4).cpp_str()).nl();
|
||||||
out.p(" DPT Block Size: ").p(data::DPTStructure::DPTBlockSizeBytes).nl();
|
out.p(" DPT Block Size: ").p(data::DPTStructure::DPTBlockSizeBytes).nl();
|
||||||
return ErrorNoError;
|
return ErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +460,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools print-disassembly <disassembly_file>").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p(" Usage: ./dtools print-disassembly <disassembly_file>").reset().nl();
|
||||||
return ErrorPrintDisassemblyTooFewArgs;
|
return ErrorPrintDisassemblyTooFewArgs;
|
||||||
}
|
}
|
||||||
ostd::String arg1 = argv[2];
|
String arg1 = argv[2];
|
||||||
arg1.trim();
|
arg1.trim();
|
||||||
TableList codeTable;
|
TableList codeTable;
|
||||||
TableList labelTable;
|
TableList labelTable;
|
||||||
|
|
@ -499,7 +499,7 @@ namespace dragon
|
||||||
out.bg(ostd::ConsoleColors::White).fg(ostd::ConsoleColors::Black).p("DATA:").reset().nl();
|
out.bg(ostd::ConsoleColors::White).fg(ostd::ConsoleColors::Black).p("DATA:").reset().nl();
|
||||||
for (const auto& line : dataTable)
|
for (const auto& line : dataTable)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::BrightGray).p(ostd::String::getHexStr(line.addr, true, 2)).p("\t\t");
|
out.fg(ostd::ConsoleColors::BrightGray).p(String::getHexStr(line.addr, true, 2)).p("\t\t");
|
||||||
out.fg(ostd::ConsoleColors::Green).p(line.code).p("\t\t");
|
out.fg(ostd::ConsoleColors::Green).p(line.code).p("\t\t");
|
||||||
out.fg(ostd::ConsoleColors::Blue).p(line.size).p(" bytes\t\t");
|
out.fg(ostd::ConsoleColors::Blue).p(line.size).p(" bytes\t\t");
|
||||||
out.reset().nl();
|
out.reset().nl();
|
||||||
|
|
@ -508,7 +508,7 @@ namespace dragon
|
||||||
out.bg(ostd::ConsoleColors::White).fg(ostd::ConsoleColors::Black).p("LABELS:").reset().nl();
|
out.bg(ostd::ConsoleColors::White).fg(ostd::ConsoleColors::Black).p("LABELS:").reset().nl();
|
||||||
for (const auto& line : labelTable)
|
for (const auto& line : labelTable)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::BrightGray).p(ostd::String::getHexStr(line.addr, true, 2)).p("\t\t");
|
out.fg(ostd::ConsoleColors::BrightGray).p(String::getHexStr(line.addr, true, 2)).p("\t\t");
|
||||||
out.fg(ostd::ConsoleColors::Green).p(line.code).p("\t\t");
|
out.fg(ostd::ConsoleColors::Green).p(line.code).p("\t\t");
|
||||||
out.reset().nl();
|
out.reset().nl();
|
||||||
}
|
}
|
||||||
|
|
@ -516,7 +516,7 @@ namespace dragon
|
||||||
out.bg(ostd::ConsoleColors::White).fg(ostd::ConsoleColors::Black).p("CODE:").reset().nl();
|
out.bg(ostd::ConsoleColors::White).fg(ostd::ConsoleColors::Black).p("CODE:").reset().nl();
|
||||||
for (const auto& line : codeTable)
|
for (const auto& line : codeTable)
|
||||||
{
|
{
|
||||||
out.fg(ostd::ConsoleColors::BrightGray).p(ostd::String::getHexStr(line.addr, true, 2)).p("\t\t");
|
out.fg(ostd::ConsoleColors::BrightGray).p(String::getHexStr(line.addr, true, 2)).p("\t\t");
|
||||||
out.fg(ostd::ConsoleColors::Green).p(line.code).p("\t\t");
|
out.fg(ostd::ConsoleColors::Green).p(line.code).p("\t\t");
|
||||||
out.reset().nl();
|
out.reset().nl();
|
||||||
}
|
}
|
||||||
|
|
@ -561,7 +561,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Magenta).p("Usage: ./dtools <tool_name> [...arguments...]").nl().nl().reset();
|
out.fg(ostd::ConsoleColors::Magenta).p("Usage: ./dtools <tool_name> [...arguments...]").nl().nl().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Tools::get_tool(int argc, char** argv, ostd::String& outTool)
|
int32_t Tools::get_tool(int argc, char** argv, String& outTool)
|
||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
|
|
@ -569,7 +569,7 @@ namespace dragon
|
||||||
out.fg(ostd::ConsoleColors::Red).p("Use the --help option for more info.").reset().nl();
|
out.fg(ostd::ConsoleColors::Red).p("Use the --help option for more info.").reset().nl();
|
||||||
return ErrorTopLevelTooFewArgs;
|
return ErrorTopLevelTooFewArgs;
|
||||||
}
|
}
|
||||||
ostd::String tool = argv[1];
|
String tool = argv[1];
|
||||||
tool = tool.trim().toLower();
|
tool = tool.trim().toLower();
|
||||||
outTool = tool;
|
outTool = tool;
|
||||||
return ErrorNoError;
|
return ErrorNoError;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static inline ostd::ConsoleOutputHandler& output(void) { return out; }
|
static inline ostd::ConsoleOutputHandler& output(void) { return out; }
|
||||||
static bool createVirtualHardDrive(uint32_t sizeInBytes, const ostd::String& dataFilePath);
|
static bool createVirtualHardDrive(uint32_t sizeInBytes, const String& dataFilePath);
|
||||||
static int32_t execute(int argc, char** argv);
|
static int32_t execute(int argc, char** argv);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -20,12 +20,12 @@ namespace dragon
|
||||||
static int32_t tool_new_dpt(int argc, char** argv);
|
static int32_t tool_new_dpt(int argc, char** argv);
|
||||||
static int32_t tool_print_disassembly(int argc, char** argv);
|
static int32_t tool_print_disassembly(int argc, char** argv);
|
||||||
static void print_application_help(void);
|
static void print_application_help(void);
|
||||||
static int32_t get_tool(int argc, char** argv, ostd::String& outTool);
|
static int32_t get_tool(int argc, char** argv, String& outTool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static ostd::ConsoleOutputHandler out;
|
inline static ostd::ConsoleOutputHandler out;
|
||||||
|
|
||||||
inline static std::unordered_map<uint8_t, ostd::String> m_dpt_flags_str {
|
inline static std::unordered_map<uint8_t, String> m_dpt_flags_str {
|
||||||
{ data::DPTStructure::tFlags::Boot, "boot" }
|
{ data::DPTStructure::tFlags::Boot, "boot" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ namespace dragon
|
||||||
{
|
{
|
||||||
static const std::vector<char> g_symbols = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
|
static const std::vector<char> g_symbols = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
|
||||||
|
|
||||||
ostd::String Utils::genRandomName(uint8_t length)
|
String Utils::genRandomName(uint8_t length)
|
||||||
{
|
{
|
||||||
auto rnd_char = []() -> char {
|
auto rnd_char = []() -> char {
|
||||||
return g_symbols[ostd::Random::getui8(0, g_symbols.size())];
|
return g_symbols[ostd::Random::getui8(0, g_symbols.size())];
|
||||||
};
|
};
|
||||||
ostd::String name = "";
|
String name = "";
|
||||||
for (int32_t i = 0; i < length; i++)
|
for (int32_t i = 0; i < length; i++)
|
||||||
name.addChar(rnd_char());
|
name.addChar(rnd_char());
|
||||||
return name;
|
return name;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@ namespace dragon
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static ostd::String genRandomName(uint8_t length);
|
static String genRandomName(uint8_t length);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue