Accomodated refactor of ostd::Utils in OmniaFramework

This commit is contained in:
OmniaX-Dev 2026-03-20 23:23:28 +01:00
parent 16b706175d
commit d1362c0218
27 changed files with 272 additions and 248 deletions

Binary file not shown.

View file

@ -3,10 +3,10 @@
.entry _kernel0_main .entry _kernel0_main
.header KERNEL0_BOOT .header KERNEL0_BOOT
@include <sdk/bios_api.dss> @include <memory.dss>
@include <../drivers/display_driver.dss> @include <../drivers/display_driver.dss>
@include <../drivers/keyboard_driver.dss> @include <../drivers/keyboard_driver.dss>
@include <memory.dss> @include <sdk/bios_api.dss>
## ========================================================================================================================= ## =========================================================================================================================

View file

@ -1,5 +1,5 @@
## -- ## --
## -- This file is automatically generated by the DragonAssembler (version 0.4.1642) ## -- This file is automatically generated by the DragonAssembler (version 0.4.1645)
## -- Please do not modify this file in any way. ## -- Please do not modify this file in any way.
## -- ## --

View file

@ -1 +1 @@
1643 1646

View file

@ -2,9 +2,10 @@
#include <ostd/io/File.hpp> #include <ostd/io/File.hpp>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <ostd/utils/Utils.hpp>
#include <ostd/io/Serial.hpp> #include <ostd/io/Serial.hpp>
#include <ostd/io/IOHandlers.hpp> #include <ostd/io/IOHandlers.hpp>
#include <ostd/io/Memory.hpp>
#include <ostd/math/MathUtils.hpp>
#include "../tools/GlobalData.hpp" #include "../tools/GlobalData.hpp"
#include "../hardware/VirtualHardDrive.hpp" #include "../hardware/VirtualHardDrive.hpp"
@ -50,6 +51,8 @@ namespace dragon
replaceLabelRefs(); replaceLabelRefs();
combineDataAndCode(); combineDataAndCode();
createExportFiles(); createExportFiles();
if (Application::args.disassembly_file_path.trim() != "")
saveCurrentStageToFile();
m_programSize = m_code.size(); m_programSize = m_code.size();
if (m_fixedSize > 0 && m_code.size() > m_fixedSize) if (m_fixedSize > 0 && m_code.size() > m_fixedSize)
std::cout << "Warning: Fixed size specified but exceeded: (" << (int)m_code.size() << "/" << (int)m_fixedSize << " bytes)\n"; std::cout << "Warning: Fixed size specified but exceeded: (" << (int)m_code.size() << "/" << (int)m_fixedSize << " bytes)\n";
@ -66,7 +69,7 @@ namespace dragon
{ {
assembleFromFile(sourceFileName); assembleFromFile(sourceFileName);
if (m_code.size() == 0) return { }; if (m_code.size() == 0) return { };
ostd::Utils::saveByteStreamToFile(m_code, binaryFileName); ostd::Memory::saveByteStreamToFile(m_code, binaryFileName);
return m_code; return m_code;
} }
@ -118,11 +121,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::Utils::getHexStr(symbol.second.address, true, 2)); out.fg(ostd::ConsoleColors::Red).p(ostd::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::Utils::getHexStr(b, false, 1)).p("."); out.p(ostd::String::getHexStr(b, false, 1)).p(".");
out.nl(); out.nl();
} }
if (m_symbolTable.size() > 0) if (m_symbolTable.size() > 0)
@ -133,7 +136,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::Utils::getHexStr(label.second.address, true, 2)).nl(); out.fg(ostd::ConsoleColors::Red).p(ostd::String::getHexStr(label.second.address, true, 2)).nl();
} }
if (m_labelTable.size() > 0) if (m_labelTable.size() > 0)
out.nl(); out.nl();
@ -155,9 +158,9 @@ namespace dragon
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(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(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(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(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(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(ostd::String("Fixed Fill: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(ostd::Utils::getHexStr(m_fixedFillValue, true, 1)).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(ostd::String("Load Address:").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(ostd::Utils::getHexStr(m_loadAddress, true, 2)).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(ostd::String("Entry Point: ").new_fixedLength(symbol_len)).fg(ostd::ConsoleColors::BrightRed).p(ostd::Utils::getHexStr(m_dataSize + m_loadAddress + 3, 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.nl(); out.nl();
@ -426,7 +429,7 @@ namespace dragon
m_structDefs.push_back(struct_def); m_structDefs.push_back(struct_def);
ostd::String size_def = "@define "; ostd::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::Utils::getHexStr(struct_def.size, true, 2)); size_def.add(ostd::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;
@ -526,7 +529,7 @@ namespace dragon
// { // {
// std::cout << " " << d.first << " "; // std::cout << " " << d.first << " ";
// for (auto& b : d.second) // for (auto& b : d.second)
// std::cout << ostd::Utils::getHexStr(b) << " "; // std::cout << ostd::String::getHexStr(b) << " ";
// } // }
// std::cout << "\n"; // std::cout << "\n";
// } // }
@ -614,9 +617,9 @@ namespace dragon
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::Utils::getHexStr(init_data[data_index], true, 2)); newLine.add(ostd::String::getHexStr(init_data[data_index], true, 2));
else else
newLine.add(ostd::Utils::getHexStr(member.data[i], true, 2)); newLine.add(ostd::String::getHexStr(member.data[i], true, 2));
newLine.add(","); newLine.add(",");
} }
newLine.substr(0, newLine.len() - 1); newLine.substr(0, newLine.len() - 1);
@ -769,6 +772,11 @@ namespace dragon
} }
} }
void Assembler::saveCurrentStageToFile(void)
{
}
void Assembler::parseSections(void) void Assembler::parseSections(void)
@ -1292,7 +1300,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::Utils::getHexStr(word, true, 2) << "\n"; // std::cout << ostd::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));
@ -2512,7 +2520,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::Utils::getHexStr(entryAddr, true, 2)) }); m_disassembly.insert(m_disassembly.begin(), { m_loadAddress, ostd::String("jmp ").add(ostd::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,7 +2560,7 @@ namespace dragon
// 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::Utils::getHexStr(symbol.second.address, true, 2), false); lineEdit.regexReplace(regex, ostd::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;
@ -2630,15 +2638,15 @@ 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::Utils::getHexStr(labelAddr, true, 2) << "\n"; // std::cout << " : " << ostd::String::getHexStr(labelAddr, true, 2) << "\n";
// std::cout << " : " << ostd::Utils::getHexStr(outOp, true, 2) << "\n"; // std::cout << " : " << ostd::String::getHexStr(outOp, true, 2) << "\n";
return eOperandType::Label; return eOperandType::Label;
} }
if (opEdit.startsWith("{") && opEdit.endsWith("}")) if (opEdit.startsWith("{") && opEdit.endsWith("}"))
{ {
opEdit = opEdit.substr(1, opEdit.len() - 1); opEdit = opEdit.substr(1, opEdit.len() - 1);
opEdit.trim(); opEdit.trim();
outOp = (int16_t)ostd::Utils::solveIntegerExpression(opEdit); outOp = (int16_t)ostd::MathUtils::solveIntegerExpression(opEdit);
return eOperandType::Immediate; return eOperandType::Immediate;
} }
if (opEdit.startsWith("[") && opEdit.endsWith("]")) if (opEdit.startsWith("[") && opEdit.endsWith("]"))
@ -2649,7 +2657,7 @@ namespace dragon
{ {
opEdit = opEdit.substr(1, opEdit.len() - 1); opEdit = opEdit.substr(1, opEdit.len() - 1);
opEdit.trim(); opEdit.trim();
outOp = (int16_t)ostd::Utils::solveIntegerExpression(opEdit); outOp = (int16_t)ostd::MathUtils::solveIntegerExpression(opEdit);
return eOperandType::DerefMemory; return eOperandType::DerefMemory;
} }
if (!opEdit.isNumeric()) if (!opEdit.isNumeric())

View file

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <ostd/utils/Utils.hpp>
#include <ostd/io/IOHandlers.hpp> #include <ostd/io/IOHandlers.hpp>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
@ -96,6 +95,7 @@ namespace dragon
bool debug_mode { false }; bool debug_mode { false };
bool save_exports { true }; bool save_exports { true };
ostd::String disassembly_file_path { "" }; ostd::String disassembly_file_path { "" };
ostd::String final_stage_path { "" };
std::vector<ostd::String> cpu_extensions; std::vector<ostd::String> cpu_extensions;
std::vector<ostd::String> include_directories; std::vector<ostd::String> include_directories;
}; };
@ -133,6 +133,7 @@ namespace dragon
static void createExports(void); static void createExports(void);
static void replaceExportBuiltinVars(void); static void replaceExportBuiltinVars(void);
static void createExportFiles(void); static void createExportFiles(void);
static void saveCurrentStageToFile(void);
static void parseSections(void); static void parseSections(void);
static void parseDataSection(void); static void parseDataSection(void);

View file

@ -1,6 +1,7 @@
#include "Assembler.hpp" #include "Assembler.hpp"
#include <ostd/math/Random.hpp> #include <ostd/math/Random.hpp>
#include <ostd/io/FileSystem.hpp> #include <ostd/io/FileSystem.hpp>
#include <ostd/utils/Hash.hpp>
namespace dragon namespace dragon
{ {
@ -57,6 +58,16 @@ namespace dragon
args.disassembly_file_path = argv[i]; args.disassembly_file_path = argv[i];
args.save_disassembly = true; args.save_disassembly = true;
} }
else if (edit == "--save-final-stage")
{
if (i == argc - 1)
return RETURN_VAL_MISSING_PARAM;
i++;
ostd::String final_path = argv[i];
if (!ostd::FileSystem::ensureFile(final_path))
return RETURN_VAL_INVALID_PARAM;
args.final_stage_path = final_path;
}
else if (edit == "--help") else if (edit == "--help")
{ {
print_application_help(); print_application_help();
@ -88,7 +99,7 @@ namespace dragon
if (!disable_extmov) if (!disable_extmov)
args.cpu_extensions.push_back("extmov"); args.cpu_extensions.push_back("extmov");
if (args.save_disassembly && args.disassembly_file_path == "") if (args.save_disassembly && args.disassembly_file_path == "")
args.disassembly_file_path = "disassembly/" + ostd::Utils::md5(args.dest_file_path) + ".dds"; args.disassembly_file_path = "disassembly/" + ostd::Hash::md5(args.dest_file_path) + ".dds";
} }
return RETURN_VAL_EXIT_SUCCESS; return RETURN_VAL_EXIT_SUCCESS;
} }
@ -101,6 +112,9 @@ namespace dragon
ostd::String tmpCommand = "--save-disassembly <destination-directory>"; ostd::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.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Saves the final full stripped code to the specified file.").reset().nl();
tmpCommand = "--verbose"; tmpCommand = "--verbose";
tmpCommand.addRightPadding(commandLength); tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Shows more information about the assembled program.").reset().nl(); out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Shows more information about the assembled program.").reset().nl();

View file

@ -2,6 +2,9 @@
#include "../runtime/DragonRuntime.hpp" #include "../runtime/DragonRuntime.hpp"
#include "DisassemblyLoader.hpp" #include "DisassemblyLoader.hpp"
#include <ostd/io/Console.hpp> #include <ostd/io/Console.hpp>
#include <ostd/io/Memory.hpp>
#include <ostd/string/String.hpp>
#include <ostd/utils/Time.hpp>
namespace dragon namespace dragon
{ {
@ -84,11 +87,11 @@ namespace dragon
void Debugger::Utils::clearConsoleLine(void) void Debugger::Utils::clearConsoleLine(void)
{ {
for (int32_t i = 0; i < ostd::Utils::getConsoleWidth(); i++) for (int32_t i = 0; i < ostd::BasicConsole::getConsoleWidth(); i++)
out.p("\b"); out.p("\b");
for (int32_t i = 0; i < ostd::Utils::getConsoleWidth(); i++) for (int32_t i = 0; i < ostd::BasicConsole::getConsoleWidth(); i++)
out.p(" "); out.p(" ");
for (int32_t i = 0; i < ostd::Utils::getConsoleWidth(); i++) for (int32_t i = 0; i < ostd::BasicConsole::getConsoleWidth(); i++)
out.p("\b"); out.p("\b");
} }
@ -102,7 +105,7 @@ namespace dragon
ostd::eKeys key = ostd::eKeys::NoKeyPressed; ostd::eKeys key = ostd::eKeys::NoKeyPressed;
while ((key = kbc.waitForKeyPress()) != ostd::eKeys::Escape) while ((key = kbc.waitForKeyPress()) != ostd::eKeys::Escape)
{ {
ostd::Utils::sleep(120); ostd::Time::sleep(120);
} }
return true; return true;
} }
@ -111,16 +114,16 @@ 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::Utils::getConsoleWidth(); int32_t cw = ostd::BasicConsole::getConsoleWidth();
ostd::String str = ostd::Utils::duplicateChar(c, cw); ostd::String str = ostd::String::duplicateChar(c, cw);
out.fg(foreground).p(str).reset().nl(); out.fg(foreground).p(str).reset().nl();
return out; return out;
} }
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::Utils::getConsoleWidth(); int32_t cw = ostd::BasicConsole::getConsoleWidth();
ostd::String str = ostd::Utils::duplicateChar(c, cw); ostd::String str = ostd::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;
} }
@ -176,7 +179,7 @@ namespace dragon
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; ostd::String instStr = instEdit;
instStr.cpp_str_ref().replace(index, labelEdit.len(), labelEdit.cpp_str() + "[@@ style foreground:brightgray](" + ostd::Utils::getHexStr(label.addr, true, 2).cpp_str() + ")[@@/]"); 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; instEdit = instStr;
} }
} }
@ -238,7 +241,7 @@ namespace dragon
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::Utils::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();; out.fg(ostd::ConsoleColors::Black).bg(ostd::ConsoleColors::Yellow).p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();;
} }
else else
{ {
@ -248,7 +251,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::Utils::getHexStr(_da.addr, true, 2).cpp_str()).p(" "); out.p(ostd::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();
@ -328,14 +331,14 @@ namespace dragon
//Instruction Address //Instruction Address
{ {
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionAddress, true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionAddress, true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionAddress, true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionAddress, true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -351,7 +354,7 @@ namespace dragon
ostd::String prevCode = " ("; ostd::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::Utils::getHexStr(minfo.previousInstructionFootprint[i], false, 1)).add(" "); prevCode.add(ostd::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, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
tmpStyle = "[@@style foreground:Blue]"; tmpStyle = "[@@style foreground:Blue]";
@ -362,7 +365,7 @@ namespace dragon
// ostd::String currCode = " ("; // ostd::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::Utils::getHexStr(minfo.currentInstructionFootprint[i], false, 1)).add(" "); // currCode.add(ostd::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, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
// // if (currCode != prevCode) // // if (currCode != prevCode)
@ -376,14 +379,14 @@ namespace dragon
//Stack Frame //Stack Frame
{ {
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionStackFrameSize, true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionStackFrameSize, true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionStackFrameSize, true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionStackFrameSize, true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -479,14 +482,14 @@ namespace dragon
//System Registers //System Registers
{ {
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::IP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::IP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::IP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::IP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -499,14 +502,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::SP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::SP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::SP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::SP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -519,14 +522,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -539,14 +542,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::RV], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::RV], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::RV], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::RV], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -559,14 +562,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::PP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::PP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::PP], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::PP], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -579,14 +582,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FL], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::FL], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FL], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::FL], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -599,14 +602,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::ACC], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::ACC], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::ACC], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::ACC], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -620,14 +623,14 @@ namespace dragon
//General Registers //General Registers
{ {
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R1], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R1], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R1], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R1], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -640,14 +643,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R2], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R2], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R2], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R2], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -660,14 +663,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R3], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R3], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R3], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R3], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -680,14 +683,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R4], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R4], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R4], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R4], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -700,14 +703,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R5], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R5], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R5], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R5], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -720,14 +723,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R6], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R6], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R6], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R6], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -740,14 +743,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R7], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R7], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R7], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R7], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -760,14 +763,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R8], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R8], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R8], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R8], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -780,14 +783,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R9], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R9], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R9], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R9], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -800,14 +803,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R10], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::R10], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R10], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::R10], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -820,14 +823,14 @@ namespace dragon
//Special Registers //Special Registers
{ {
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S1], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S1], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S1], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S1], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -840,14 +843,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S2], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S2], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S2], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S2], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -860,14 +863,14 @@ namespace dragon
tmp = " ", tmpStyle = ""; tmp = " ", tmpStyle = "";
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET], true, 2)); tmp.add(ostd::String::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET], true, 2)); tmp.add(ostd::String::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); tmp.addPadding(item_len, ' ', ostd::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]";
@ -901,7 +904,7 @@ namespace dragon
const int32_t prev_len = 35; const int32_t prev_len = 35;
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::Utils::getConsoleWidth(); int32_t cw = ostd::BasicConsole::getConsoleWidth();
ostd::String header = "|Symbol"; ostd::String header = "|Symbol";
header.addRightPadding(symbol_len); header.addRightPadding(symbol_len);
header.add("|Bytes"); header.add("|Bytes");
@ -915,13 +918,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::Utils::duplicateChar('=', cw); ostd::String border = ostd::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::Utils::duplicateChar('=', cw); ostd::String h_sep = ostd::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, '|');
@ -958,7 +961,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::Utils::getHexStr(addr, true, 2)); tmp.add(ostd::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();
@ -974,9 +977,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::Utils::getHexStr(minfo.previousInstructionTrackedValues[i], false, 1)); tmp.add(ostd::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::Utils::getHexStr(minfo.previousInstructionTrackedValues[i + j], false, 1)); tmp.add(".").add(ostd::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();
@ -984,10 +987,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::Utils::getHexStr(minfo.currentInstructionTrackedValues[i], false, 1)); tmp.add(ostd::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::Utils::getHexStr(minfo.currentInstructionTrackedValues[i + 1], false, 1)); tmp.add(".").add(ostd::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++)
@ -1048,7 +1051,7 @@ namespace dragon
out.fg(ostd::ConsoleColors::Yellow).p("Stack view: ").reset().nl(); out.fg(ostd::ConsoleColors::Yellow).p("Stack view: ").reset().nl();
uint16_t stack_ptr = DragonRuntime::cpu.readRegister(data::Registers::SP); uint16_t stack_ptr = DragonRuntime::cpu.readRegister(data::Registers::SP);
ostd::Utils::printByteStream(*DragonRuntime::ram.getByteStream(), startAddr, ncols, nrows, out, stack_ptr, 2, "Stack"); ostd::Memory::printByteStream(*DragonRuntime::ram.getByteStream(), startAddr, ncols, nrows, out, stack_ptr, 2, "Stack");
out.nl().nl().fg(ostd::ConsoleColors::Yellow).p("Pres <Escape> to go back...").nl().reset(); out.nl().nl().fg(ostd::ConsoleColors::Yellow).p("Pres <Escape> to go back...").nl().reset();
Utils::isEscapeKeyPressed(true); Utils::isEscapeKeyPressed(true);
@ -1075,18 +1078,18 @@ namespace dragon
for (auto& call : callStack) for (auto& call : callStack)
{ {
ostd::String call_info = call.info.new_trim().toLower(); ostd::String call_info = call.info.new_trim().toLower();
ostd::String subroutine_addr = ostd::Utils::getHexStr(call.addr, true, 2); ostd::String subroutine_addr = ostd::String::getHexStr(call.addr, true, 2);
ostd::String subroutine_name = Utils::findSymbol(debugger.labels, call.addr); ostd::String subroutine_name = Utils::findSymbol(debugger.labels, call.addr);
ostd::String call_str = ""; ostd::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::Utils::getHexStr(call.addr, true, 1); call_str = ch_ang_u + "int " + ostd::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::Utils::getHexStr(call.addr, true, 1) + " (" + data::InterruptCodes::getInterruptName(call.addr) + ")"; call_str = ch_ang_u + "hwi " + ostd::String::getHexStr(call.addr, true, 1) + " (" + data::InterruptCodes::getInterruptName(call.addr) + ")";
level++; level++;
} }
else if (call_info == "ret") else if (call_info == "ret")
@ -1129,7 +1132,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::Utils::getHexStr(call.inst_addr, true, 2)); out.p(ostd::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();
@ -1246,7 +1249,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::Utils::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl(); 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; debugger.args.step_exec = true;
} }
@ -1483,14 +1486,14 @@ namespace dragon
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 = ""; ostd::String tmp = "";
tmp.add("*(").add(ostd::Utils::getHexStr(addr, true, 2)); tmp.add("*(").add(ostd::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::Utils::getHexStr(end_addr, true, 2)); tmp.add("-").add(ostd::String::getHexStr(end_addr, true, 2));
} }
tmp.add(")"); tmp.add(")");
ostd::RegexRichString rgx(tmp); ostd::RegexRichString rgx(tmp);
@ -1503,7 +1506,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::Utils::getHexStr(value, true, 1)); output().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
if (a < end_addr) if (a < end_addr)
output().p(" "); output().p(" ");
} }
@ -1521,9 +1524,9 @@ namespace dragon
else else
{ {
ostd::String tmp = ""; ostd::String tmp = "";
tmp.add("*(").add(ostd::Utils::getHexStr(addr, true, 2)); tmp.add("*(").add(ostd::String::getHexStr(addr, true, 2));
if (size > 1) if (size > 1)
tmp.add("-").add(ostd::Utils::getHexStr((uint16_t)(addr + size - 1), true, 2)); tmp.add("-").add(ostd::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");
@ -1542,7 +1545,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::Utils::getHexStr(value, true, 1)); output().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
if (a < addr + size - 1) if (a < addr + size - 1)
output().p(" "); output().p(" ");
} }
@ -1586,12 +1589,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::Utils::getHexStr(addr, true, 2)).reset().nl(); output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::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::Utils::getHexStr(addr, true, 2)).reset().nl(); output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
} }
} }
Display::printPrompt(); Display::printPrompt();

View file

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <ostd/utils/Utils.hpp>
#include <ostd/io/IOHandlers.hpp> #include <ostd/io/IOHandlers.hpp>
#include "../assembler/Assembler.hpp" #include "../assembler/Assembler.hpp"

View file

@ -3,11 +3,11 @@
#include <cstdint> #include <cstdint>
#include <ogfx/BasicRenderer.hpp> #include <ogfx/BasicRenderer.hpp>
#include <ogfx/WindowBase.hpp> #include <ogfx/WindowBase.hpp>
#include <ostd/io/Memory.hpp>
#include <ostd/math/Geometry.hpp> #include <ostd/math/Geometry.hpp>
#include <ostd/io/IOHandlers.hpp> #include <ostd/io/IOHandlers.hpp>
#include <ostd/math/Random.hpp> #include <ostd/math/Random.hpp>
#include <ostd/string/String.hpp> #include <ostd/string/String.hpp>
#include <ostd/utils/Utils.hpp>
#include "DisassemblyLoader.hpp" #include "DisassemblyLoader.hpp"
#include "../runtime/DragonRuntime.hpp" #include "../runtime/DragonRuntime.hpp"
@ -256,7 +256,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::Utils::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl(); 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; debugger.args.step_exec = true;
} }
@ -428,14 +428,14 @@ namespace dragon
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 = ""; ostd::String tmp = "";
tmp.add("*(").add(ostd::Utils::getHexStr(addr, true, 2)); tmp.add("*(").add(ostd::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::Utils::getHexStr(end_addr, true, 2)); tmp.add("-").add(ostd::String::getHexStr(end_addr, true, 2));
} }
tmp.add(")"); tmp.add(")");
ostd::RegexRichString rgx(tmp); ostd::RegexRichString rgx(tmp);
@ -448,7 +448,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::Utils::getHexStr(value, true, 1)); output().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
if (a < end_addr) if (a < end_addr)
output().p(" "); output().p(" ");
} }
@ -466,9 +466,9 @@ namespace dragon
else else
{ {
ostd::String tmp = ""; ostd::String tmp = "";
tmp.add("*(").add(ostd::Utils::getHexStr(addr, true, 2)); tmp.add("*(").add(ostd::String::getHexStr(addr, true, 2));
if (size > 1) if (size > 1)
tmp.add("-").add(ostd::Utils::getHexStr((uint16_t)(addr + size - 1), true, 2)); tmp.add("-").add(ostd::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");
@ -487,7 +487,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::Utils::getHexStr(value, true, 1)); output().fg(ostd::ConsoleColors::BrightRed).p(ostd::String::getHexStr(value, true, 1));
if (a < addr + size - 1) if (a < addr + size - 1)
output().p(" "); output().p(" ");
} }
@ -531,12 +531,12 @@ namespace dragon
if (isBreakPoint(addr)) if (isBreakPoint(addr))
{ {
removeBreakPoint(addr); removeBreakPoint(addr);
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::Utils::getHexStr(addr, true, 2)).reset().nl(); output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
} }
else else
{ {
addBreakPoint(addr); addBreakPoint(addr);
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::Utils::getHexStr(addr, true, 2)).reset().nl(); output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl();
} }
} }
// Display::printPrompt(); // Display::printPrompt();
@ -587,7 +587,7 @@ namespace dragon
if (index + labelEdit.len() < instEdit.len() && isValidLabelNameChar(instEdit.at(index + labelEdit.len()))) if (index + labelEdit.len() < instEdit.len() && isValidLabelNameChar(instEdit.at(index + labelEdit.len())))
continue; continue;
ostd::String instStr = instEdit; ostd::String instStr = instEdit;
instStr.cpp_str_ref().replace(index, labelEdit.len(), labelEdit.cpp_str() + "[@@ style foreground:brightgray](" + ostd::Utils::getHexStr(label.addr, true, 2).cpp_str() + ")[@@/]"); 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; instEdit = instStr;
} }
} }
@ -644,7 +644,7 @@ namespace dragon
m_wout.fg(ostd::ConsoleColors::Gray).p(label.cpp_str()).p(" "); m_wout.fg(ostd::ConsoleColors::Gray).p(label.cpp_str()).p(" ");
if (currentLine) if (currentLine)
{ {
m_wout.fg(ostd::ConsoleColors::Black).bg(ostd::ConsoleColors::Yellow).p(ostd::Utils::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();; m_wout.fg(ostd::ConsoleColors::Black).bg(ostd::ConsoleColors::Yellow).p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ").reset();;
} }
else else
{ {
@ -654,7 +654,7 @@ namespace dragon
m_wout.fg(ostd::ConsoleColors::Red); m_wout.fg(ostd::ConsoleColors::Red);
else else
m_wout.fg(ostd::ConsoleColors::BrightGray); m_wout.fg(ostd::ConsoleColors::BrightGray);
m_wout.p(ostd::Utils::getHexStr(_da.addr, true, 2).cpp_str()).p(" "); m_wout.p(ostd::String::getHexStr(_da.addr, true, 2).cpp_str()).p(" ");
} }
if (specialSection) if (specialSection)
m_wout.fg(ostd::ConsoleColors::Cyan).p(_da.code.cpp_str()).nl(); m_wout.fg(ostd::ConsoleColors::Cyan).p(_da.code.cpp_str()).nl();
@ -700,7 +700,7 @@ namespace dragon
m_wout.setWrapMode(ogfx::WindowBaseOutputHandler::eWrapMode::TripleDots); m_wout.setWrapMode(ogfx::WindowBaseOutputHandler::eWrapMode::TripleDots);
m_wout.setDefaultForegroundColor({ 180, 180, 180, 255 }); m_wout.setDefaultForegroundColor({ 180, 180, 180, 255 });
std::cout << STR_BOOL(ostd::Utils::loadByteStreamFromFile("./bios.bin", m_test)) << "\n"; std::cout << STR_BOOL(ostd::Memory::loadByteStreamFromFile("./bios.bin", m_test)) << "\n";
} }
void DebuggerNew::handleSignal(ostd::tSignal& signal) void DebuggerNew::handleSignal(ostd::tSignal& signal)
@ -746,7 +746,7 @@ namespace dragon
m_gfx.outlinedRect(m_wout.getConsoleBounds(), { 0, 0, 20, 255 }, { 255, 255, 255, 200 }, 2); m_gfx.outlinedRect(m_wout.getConsoleBounds(), { 0, 0, 20, 255 }, { 255, 255, 255, 200 }, 2);
m_wout.beginFrame(); m_wout.beginFrame();
ostd::Utils::printByteStream(m_test, 0, 16, 16, m_wout, 8, 4, "HELLO"); ostd::Memory::printByteStream(m_test, 0, 16, 16, m_wout, 8, 4, "HELLO");
// printStep(); // printStep();
m_textInput.render(m_gfx); m_textInput.render(m_gfx);

View file

@ -1,9 +1,8 @@
#pragma once #pragma once
#include <ostd/data_types/Color.hpp> #include <ostd/data/Color.hpp>
#include <ostd/math/Geometry.hpp> #include <ostd/math/Geometry.hpp>
#include <ostd/data_types/Types.hpp> #include <ostd/data/Types.hpp>
#include <ostd/utils/Utils.hpp>
#include <ostd/io/IOHandlers.hpp> #include <ostd/io/IOHandlers.hpp>
#include <ogfx/WindowBase.hpp> #include <ogfx/WindowBase.hpp>
#include <ogfx/BasicRenderer.hpp> #include <ogfx/BasicRenderer.hpp>

View file

@ -2,9 +2,11 @@
#include <ostd/io/File.hpp> #include <ostd/io/File.hpp>
#include <ostd/io/FileSystem.hpp> #include <ostd/io/FileSystem.hpp>
#include <ostd/io/Memory.hpp>
#include <ostd/io/Serial.hpp> #include <ostd/io/Serial.hpp>
#include <algorithm> #include <algorithm>
#include <ostd/string/String.hpp>
namespace dragon namespace dragon
{ {
@ -13,7 +15,7 @@ namespace dragon
void DisassemblyTable::init(const ostd::String& filePath) void DisassemblyTable::init(const ostd::String& filePath)
{ {
ostd::ByteStream stream; ostd::ByteStream stream;
if (!ostd::Utils::loadByteStreamFromFile(filePath, stream)) if (!ostd::Memory::loadByteStreamFromFile(filePath, stream))
{ {
m_initialized = false; m_initialized = false;
return; return;
@ -75,7 +77,7 @@ namespace dragon
int32_t opCodeLen = 10; int32_t opCodeLen = 10;
if (part1.len() < opCodeLen) if (part1.len() < opCodeLen)
{ {
codeEdit = part1 + ostd::Utils::duplicateChar(' ', opCodeLen - part1.len()) + part2; codeEdit = part1 + ostd::String::duplicateChar(' ', opCodeLen - part1.len()) + part2;
line.code = codeEdit; line.code = codeEdit;
} }
} }

View file

@ -2,7 +2,7 @@
#include "../assembler/Assembler.hpp" #include "../assembler/Assembler.hpp"
#include <ostd/data_types/Types.hpp> #include <ostd/data/Types.hpp>
namespace dragon namespace dragon
{ {

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <ostd/data_types/BaseObject.hpp> #include <ostd/data/BaseObject.hpp>
namespace dragon namespace dragon
{ {

View file

@ -1,7 +1,6 @@
#include "MemoryMapper.hpp" #include "MemoryMapper.hpp"
#include <ostd/io/Serial.hpp> #include <ostd/io/Serial.hpp>
#include <ostd/data_types/Types.hpp> #include <ostd/data/Types.hpp>
#include <ostd/utils/Utils.hpp>
#include "../tools/GlobalData.hpp" #include "../tools/GlobalData.hpp"
@ -69,7 +68,7 @@ namespace dragon
if (address >= region.startAddress && address <= region.endAddress) if (address >= region.startAddress && address <= region.endAddress)
return &region; return &region;
} }
data::ErrorHandler::pushError(data::ErrorCodes::MM_RegionNotFound, ostd::String("Memory device not found for address: ").add(ostd::Utils::getHexStr(address, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::MM_RegionNotFound, ostd::String("Memory device not found for address: ").add(ostd::String::getHexStr(address, true, 2)));
return nullptr; //TODO: Error return nullptr; //TODO: Error
} }
} }

View file

@ -2,7 +2,7 @@
#include "../tools/GlobalData.hpp" #include "../tools/GlobalData.hpp"
#include <iostream> #include <iostream>
#include <ostd/utils/Utils.hpp> #include <ostd/io/Memory.hpp>
#include "../runtime/DragonRuntime.hpp" #include "../runtime/DragonRuntime.hpp"
@ -233,7 +233,7 @@ namespace dragon
break; break;
case data::OpCodes::DEBUG_DumpRAM: case data::OpCodes::DEBUG_DumpRAM:
{ {
ostd::Utils::saveByteStreamToFile(*DragonRuntime::ram.getByteStream(), "ram_dump.bin"); ostd::Memory::saveByteStreamToFile(*DragonRuntime::ram.getByteStream(), "ram_dump.bin");
m_isDebugBreakPoint = true; m_isDebugBreakPoint = true;
m_ramDumped = true; m_ramDumped = true;
} }
@ -259,7 +259,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::Utils::getHexStr(id, true, 1)).add("]"), tu); m_profilerTimer.start(true, ostd::String("DebugProfiler [").add(ostd::String::getHexStr(id, true, 1)).add("]"), tu);
m_debugProfilerStarted = true; m_debugProfilerStarted = true;
} }
break; break;
@ -812,7 +812,7 @@ namespace dragon
writeRegister16(data::Registers::IP, subroutineAddr); writeRegister16(data::Registers::IP, subroutineAddr);
if (test) if (test)
{ {
std::cout << ostd::Utils::getHexStr(subroutineAddr, true, 2) << "\n"; std::cout << ostd::String::getHexStr(subroutineAddr, true, 2) << "\n";
std::cin.get(); std::cin.get();
} }
m_subroutineCounter++; m_subroutineCounter++;
@ -838,7 +838,7 @@ namespace dragon
{ {
if (isInDebugBreakPoint()) if (isInDebugBreakPoint())
{ {
std::cout << ostd::Utils::getHexStr(readRegister(data::Registers::IP)); std::cout << ostd::String::getHexStr(readRegister(data::Registers::IP));
std::cin.get(); std::cin.get();
} }
uint8_t regAddr = fetch8(); uint8_t regAddr = fetch8();
@ -847,7 +847,7 @@ namespace dragon
int16_t arg_data = m_memory.read16(pp_val); int16_t arg_data = m_memory.read16(pp_val);
writeRegister16(data::Registers::PP, pp_val - 2); writeRegister16(data::Registers::PP, pp_val - 2);
writeRegister16(regAddr, arg_data); writeRegister16(regAddr, arg_data);
// std::cout << ostd::Utils::getHexStr(readRegister(data::Registers::IP), true, 2) << "\n"; // std::cout << ostd::String::getHexStr(readRegister(data::Registers::IP), true, 2) << "\n";
} }
break; break;
case data::OpCodes::RetInt: case data::OpCodes::RetInt:
@ -903,14 +903,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::Utils::getHexStr(inst, true, 1))); data::ErrorHandler::pushError(data::ErrorCodes::CPU_UnsupportedExtension, ostd::String("Unsupported Extension: ").add(ostd::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::Utils::getHexStr(inst, true, 1))); data::ErrorHandler::pushError(data::ErrorCodes::CPU_UnknownInstruction, ostd::String("Unknown instruction: ").add(ostd::String::getHexStr(inst, true, 1)));
m_halt = true; m_halt = true;
return false; return false;
} }
@ -931,44 +931,44 @@ namespace dragon
else else
argStartAddr += (argCount * 2); argStartAddr += (argCount * 2);
stackFrameString.add("args: ").add(ostd::Utils::getHexStr(argStartAddr, true, 2)).add(", argc: ").add(argCount).add("\n"); stackFrameString.add("args: ").add(ostd::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::Utils::getHexStr(readRegister(data::Registers::R1), true, 2)); stackFrameString.add("R1: ").add(ostd::String::getHexStr(readRegister(data::Registers::R1), true, 2));
pushToStack(readRegister(data::Registers::R2)); pushToStack(readRegister(data::Registers::R2));
stackFrameString.add(" R2: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R2), true, 2)); stackFrameString.add(" R2: ").add(ostd::String::getHexStr(readRegister(data::Registers::R2), true, 2));
pushToStack(readRegister(data::Registers::R3)); pushToStack(readRegister(data::Registers::R3));
stackFrameString.add(" R3: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R3), true, 2)); stackFrameString.add(" R3: ").add(ostd::String::getHexStr(readRegister(data::Registers::R3), true, 2));
pushToStack(readRegister(data::Registers::R4)); pushToStack(readRegister(data::Registers::R4));
stackFrameString.add(" R4: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R4), true, 2)); stackFrameString.add(" R4: ").add(ostd::String::getHexStr(readRegister(data::Registers::R4), true, 2));
pushToStack(readRegister(data::Registers::R5)); pushToStack(readRegister(data::Registers::R5));
stackFrameString.add(" R5: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R5), true, 2)); stackFrameString.add(" R5: ").add(ostd::String::getHexStr(readRegister(data::Registers::R5), true, 2));
pushToStack(readRegister(data::Registers::R6)); pushToStack(readRegister(data::Registers::R6));
stackFrameString.add(" R6: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R6), true, 2)); stackFrameString.add(" R6: ").add(ostd::String::getHexStr(readRegister(data::Registers::R6), true, 2));
pushToStack(readRegister(data::Registers::R7)); pushToStack(readRegister(data::Registers::R7));
stackFrameString.add(" R7: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R7), true, 2)); stackFrameString.add(" R7: ").add(ostd::String::getHexStr(readRegister(data::Registers::R7), true, 2));
pushToStack(readRegister(data::Registers::R8)); pushToStack(readRegister(data::Registers::R8));
stackFrameString.add(" R8: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R8), true, 2)); stackFrameString.add(" R8: ").add(ostd::String::getHexStr(readRegister(data::Registers::R8), true, 2));
pushToStack(readRegister(data::Registers::R9)); pushToStack(readRegister(data::Registers::R9));
stackFrameString.add(" R9: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R9), true, 2)); stackFrameString.add(" R9: ").add(ostd::String::getHexStr(readRegister(data::Registers::R9), true, 2));
pushToStack(readRegister(data::Registers::R10)); pushToStack(readRegister(data::Registers::R10));
stackFrameString.add(" R10: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::R10), true, 2)); stackFrameString.add(" R10: ").add(ostd::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::Utils::getHexStr(readRegister(data::Registers::PP), true, 2)); stackFrameString.add("PP: ").add(ostd::String::getHexStr(readRegister(data::Registers::PP), true, 2));
pushToStack(readRegister(data::Registers::ACC)); pushToStack(readRegister(data::Registers::ACC));
stackFrameString.add(" ACC: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::ACC), true, 2)); stackFrameString.add(" ACC: ").add(ostd::String::getHexStr(readRegister(data::Registers::ACC), true, 2));
pushToStack(readRegister(data::Registers::IP)); pushToStack(readRegister(data::Registers::IP));
stackFrameString.add(" IP: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::IP), true, 2)); stackFrameString.add(" IP: ").add(ostd::String::getHexStr(readRegister(data::Registers::IP), true, 2));
pushToStack(readRegister(data::Registers::FP)); pushToStack(readRegister(data::Registers::FP));
stackFrameString.add(" FP: ").add(ostd::Utils::getHexStr(readRegister(data::Registers::FP), true, 2)); stackFrameString.add(" FP: ").add(ostd::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::Utils::getHexStr(readRegister(data::Registers::FP), true, 2)); stackFrameString.add("New FP: ").add(ostd::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);

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <ostd/data_types/Types.hpp> #include <ostd/data/Types.hpp>
#include <ostd/utils/Utils.hpp> #include <ostd/data/Bitfields.hpp>
#include <ostd/data_types/Bitfields.hpp> #include <ostd/utils/Time.hpp>
#include "IMemoryDevice.hpp" #include "IMemoryDevice.hpp"
#include "../debugger/Debugger.hpp" #include "../debugger/Debugger.hpp"

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <fstream> #include <fstream>
#include <ostd/utils/Utils.hpp> #include <ostd/string/String.hpp>
namespace dragon namespace dragon
{ {

View file

@ -1,5 +1,4 @@
#include "VirtualIODevices.hpp" #include "VirtualIODevices.hpp"
#include <ostd/utils/Utils.hpp>
#include "VirtualHardDrive.hpp" #include "VirtualHardDrive.hpp"
#include "MemoryMapper.hpp" #include "MemoryMapper.hpp"
@ -7,6 +6,7 @@
#include "../runtime/DragonRuntime.hpp" #include "../runtime/DragonRuntime.hpp"
#include <ogfx/PixelRenderer.hpp> #include <ogfx/PixelRenderer.hpp>
#include <ostd/io/Memory.hpp>
//TODO: Fix all access functions (reads and writes) ensuring the address is not out of bounds. //TODO: Fix all access functions (reads and writes) ensuring the address is not out of bounds.
// Right now the check is done, but just to push an error if out of bounds; the address // Right now the check is done, but just to push an error if out of bounds; the address
@ -19,38 +19,38 @@ namespace dragon
{ {
void VirtualBIOS::init(const ostd::String& biosFilePath) void VirtualBIOS::init(const ostd::String& biosFilePath)
{ {
bool loaded = ostd::Utils::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::Utils::getHexStr(m_bios.size(), true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidSize, ostd::String("Invalid BIOS size: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Byte BIOS location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Word BIOS location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_WriteAttempt, ostd::String("Attempting to write to BIOS memory map: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_WriteAttempt, ostd::String("Attempting to write to BIOS memory map: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Byte IntVector location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Byte KeyboardController location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word KeyboardController location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word KeyboardController location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); 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)));
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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word KeyboardController location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); 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)));
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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Byte MBR location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::BIOS_InvalidAddress, ostd::String("Invalid Word MBR location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::IntVector_InvalidAddress, ostd::String("Invalid Word IntVector location at address: ").add(ostd::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;
@ -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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Byte CMOS location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Word CMOS location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Byte CMOS location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); 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)));
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::Utils::getHexStr(addr, true, 2))); data::ErrorHandler::pushError(data::ErrorCodes::CMOS_InvalidAddress, ostd::String("Invalid Word CMOS location at address: ").add(ostd::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::Utils::getHexStr(addr, true, 2))); 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)));
return 0; return 0;
} }
int8_t b1 = (value >> 8) & 0xFF; int8_t b1 = (value >> 8) & 0xFF;

View file

@ -1,6 +1,5 @@
#include "ConfigLoader.hpp" #include "ConfigLoader.hpp"
#include <ostd/io/File.hpp> #include <ostd/io/File.hpp>
#include <ostd/utils/Utils.hpp>
#include "../hardware/CPUExtensions.hpp" #include "../hardware/CPUExtensions.hpp"
namespace dragon namespace dragon

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <ostd/data_types/Color.hpp> #include <ostd/data/Color.hpp>
#include <map> #include <map>
#include "../tools/GlobalData.hpp" #include "../tools/GlobalData.hpp"

View file

@ -1,5 +1,7 @@
#include "DragonRuntime.hpp" #include "DragonRuntime.hpp"
#include <ogfx/PixelRenderer.hpp> #include <ogfx/PixelRenderer.hpp>
#include <ostd/io/Memory.hpp>
#include <ostd/utils/Time.hpp>
namespace dragon namespace dragon
{ {
@ -25,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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::IP), true, 2).cpp_str()); out.fg("green").p("IP: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R1), true, 2).cpp_str()); out.fg("yellow").p("R1: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R2), true, 2).cpp_str()).nl(); out.fg("yellow").p("R2: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R2), true, 2).cpp_str()).nl();
out.fg("green").p("SP: ").fg("white").p(ostd::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::SP), true, 2).cpp_str()); out.fg("green").p("SP: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R3), true, 2).cpp_str()); out.fg("yellow").p("R3: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R4), true, 2).cpp_str()).nl(); out.fg("yellow").p("R4: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R4), true, 2).cpp_str()).nl();
out.fg("green").p("FP: ").fg("white").p(ostd::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::FP), true, 2).cpp_str()); out.fg("green").p("FP: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R5), true, 2).cpp_str()); out.fg("yellow").p("R5: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R6), true, 2).cpp_str()).nl(); out.fg("yellow").p("R6: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R6), true, 2).cpp_str()).nl();
out.fg("green").p("RV: ").fg("white").p(ostd::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::RV), true, 2).cpp_str()); out.fg("green").p("RV: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R7), true, 2).cpp_str()); out.fg("yellow").p("R7: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R8), true, 2).cpp_str()).nl(); out.fg("yellow").p("R8: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R8), true, 2).cpp_str()).nl();
out.fg("green").p("PP: ").fg("white").p(ostd::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::PP), true, 2).cpp_str()); out.fg("green").p("PP: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R9), true, 2).cpp_str()); out.fg("yellow").p("R9: ").fg("white").p(ostd::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::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::R10), true, 2).cpp_str()).nl(); out.fg("yellow").p("R10: ").fg("white").p(ostd::String::getHexStr(cpu.readRegister(dragon::data::Registers::R10), true, 2).cpp_str()).nl();
out.fg("green").p("ACC: ").fg("white").p(ostd::Utils::getHexStr(cpu.readRegister(dragon::data::Registers::ACC), true, 2).cpp_str()); out.fg("green").p("ACC: ").fg("white").p(ostd::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::Utils::getBinStr(cpu.readRegister(dragon::data::Registers::FL), true, 2).cpp_str()); out.fg("yellow").p("FL: ").fg("white").p(ostd::String::getBinStr(cpu.readRegister(dragon::data::Registers::FL), true, 2).cpp_str());
} }
void DragonRuntime::processErrors(void) void DragonRuntime::processErrors(void)
@ -65,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::Utils::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl(); 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();
} }
} }
@ -183,9 +185,9 @@ namespace dragon
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::BIOS_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::BIOS_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::BIOS_End, true, 2).cpp_str()); out.p(ostd::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");
@ -193,9 +195,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::CMOS_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::CMOS_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::CMOS_End, true, 2).cpp_str()); out.p(ostd::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");
@ -203,9 +205,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::IntVector_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::IntVector_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::IntVector_End, true, 2).cpp_str()); out.p(ostd::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");
@ -213,9 +215,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::Keyboard_End, true, 2).cpp_str()); out.p(ostd::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.");
@ -223,9 +225,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::Mouse_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Mouse_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::Mouse_End, true, 2).cpp_str()); out.p(ostd::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");
@ -233,9 +235,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::MBR_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::MBR_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::MBR_End, true, 2).cpp_str()); out.p(ostd::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");
@ -243,9 +245,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::DiskInterface_End, true, 2).cpp_str()); out.p(ostd::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");
@ -253,9 +255,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::VideoCardInterface_End, true, 2).cpp_str()); out.p(ostd::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");
@ -263,9 +265,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::SerialInterface_End, true, 2).cpp_str()); out.p(ostd::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");
@ -273,9 +275,9 @@ namespace dragon
{ {
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::Utils::getHexStr(dragon::data::MemoryMapAddresses::Memory_Start, true, 2).cpp_str()); out.p(ostd::String::getHexStr(dragon::data::MemoryMapAddresses::Memory_Start, true, 2).cpp_str());
out.p(" to "); out.p(" to ");
out.p(ostd::Utils::getHexStr(dragon::data::MemoryMapAddresses::Memory_End, true, 2).cpp_str()); out.p(ostd::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");
@ -285,7 +287,7 @@ namespace dragon
uint16_t reset_ip_addr = 0x0000; uint16_t reset_ip_addr = 0x0000;
if (verbose) if (verbose)
out.fg(ostd::ConsoleColors::BrightYellow).p(" Reset IP register: ").p(ostd::Utils::getHexStr(reset_ip_addr, true, 2).cpp_str()).nl(); out.fg(ostd::ConsoleColors::BrightYellow).p(" Reset IP register: ").p(ostd::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 (verbose)
@ -394,7 +396,7 @@ namespace dragon
acc++; acc++;
acc2++; acc2++;
if (_time < clock_speed_us && fixed_clock) if (_time < clock_speed_us && fixed_clock)
ostd::Utils::sleep(clock_speed_us - _time, ostd::eTimeUnits::Microseconds); ostd::Time::sleep(clock_speed_us - _time, ostd::eTimeUnits::Microseconds);
} }
} }
@ -425,7 +427,7 @@ namespace dragon
void DragonRuntime::forceLoad(const ostd::String& filePath, uint16_t loadAddress) void DragonRuntime::forceLoad(const ostd::String& filePath, uint16_t loadAddress)
{ {
ostd::ByteStream code; ostd::ByteStream code;
ostd::Utils::loadByteStreamFromFile(filePath, code); ostd::Memory::loadByteStreamFromFile(filePath, code);
int16_t index = 0; int16_t index = 0;
for (auto& b : code) for (auto& b : code)

View file

@ -1,5 +1,4 @@
#include <ostd/utils/Defines.hpp> #include <ostd/utils/Defines.hpp>
#include <ostd/utils/Utils.hpp>
#include "DragonRuntime.hpp" #include "DragonRuntime.hpp"
int main(int argc, char** argv) int main(int argc, char** argv)

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <ostd/data_types/Types.hpp> #include <ostd/data/Types.hpp>
#include <ostd/data_types/Color.hpp> #include <ostd/data/Color.hpp>
namespace dragon namespace dragon
{ {

View file

@ -1,12 +1,12 @@
#include "Tools.hpp" #include "Tools.hpp"
#include <ostd/data_types/Color.hpp> #include <ostd/data/Color.hpp>
#include <ostd/io/IOHandlers.hpp> #include <ostd/io/IOHandlers.hpp>
#include <ostd/utils/Utils.hpp>
#include <fstream> #include <fstream>
#include "../hardware/VirtualHardDrive.hpp" #include "../hardware/VirtualHardDrive.hpp"
#include "GlobalData.hpp" #include "GlobalData.hpp"
#include "debugger/DisassemblyLoader.hpp" #include "debugger/DisassemblyLoader.hpp"
#include <ostd/io/Memory.hpp>
#include <ostd/io/Serial.hpp> #include <ostd/io/Serial.hpp>
namespace dragon namespace dragon
@ -84,12 +84,12 @@ namespace dragon
} }
ostd::String dest = argv[2]; ostd::String dest = argv[2];
ostd::String str_size = argv[3]; ostd::String str_size = argv[3];
if (!ostd::Utils::isInt(str_size)) 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();
return ErrorNewVDiskNonIntSize; return ErrorNewVDiskNonIntSize;
} }
bool result = createVirtualHardDrive(ostd::Utils::strToInt(str_size), dest); bool result = createVirtualHardDrive(str_size.toInt(), dest);
if (!result) if (!result)
{ {
out.fg(ostd::ConsoleColors::Red).p("Error: Unable to create virtual disk.").reset().nl(); out.fg(ostd::ConsoleColors::Red).p("Error: Unable to create virtual disk.").reset().nl();
@ -112,7 +112,7 @@ namespace dragon
ostd::String vdisk_file = argv[2]; ostd::String vdisk_file = argv[2];
ostd::String data_file = argv[3]; ostd::String data_file = argv[3];
ostd::String str_addr = argv[4]; ostd::String str_addr = argv[4];
if (!ostd::Utils::isInt(str_addr)) 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();
return ErrorLoadProgNonIntAddr; return ErrorLoadProgNonIntAddr;
@ -124,13 +124,13 @@ namespace dragon
return ErrorLoadProgUnableToLoadVDisk; return ErrorLoadProgUnableToLoadVDisk;
} }
ostd::ByteStream code; ostd::ByteStream code;
if (!ostd::Utils::loadByteStreamFromFile(data_file, code)) if (!ostd::Memory::loadByteStreamFromFile(data_file, code))
{ {
out.fg(ostd::ConsoleColors::Red).p("Error: Unable to load data file.").reset().nl(); out.fg(ostd::ConsoleColors::Red).p("Error: Unable to load data file.").reset().nl();
return ErrorLoadProgUnableToLoadDataFile; return ErrorLoadProgUnableToLoadDataFile;
} }
int16_t index = 0; int16_t index = 0;
uint32_t addr = (uint32_t)ostd::Utils::strToInt(str_addr); uint32_t addr = (uint32_t)str_addr.toInt();
for (auto& b : code) for (auto& b : code)
{ {
vHDD.write(addr + index, b); vHDD.write(addr + index, b);
@ -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::Utils::getHexStr(addr, true, 4).cpp_str()).nl(); out.p(" Data Address: ").p(ostd::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;
} }
@ -248,8 +248,8 @@ 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::Utils::getHexStr(part.startAddress, true, 4).new_fixedLength(len)); out.p(ostd::String::getHexStr(part.startAddress, true, 4).new_fixedLength(len));
out.p(ostd::Utils::getHexStr(part.startAddress + part.size, true, 4).new_fixedLength(len)); out.p(ostd::String::getHexStr(part.startAddress + part.size, true, 4).new_fixedLength(len));
ostd::String flags_str = ""; ostd::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++)
{ {
@ -365,7 +365,7 @@ 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::Utils::isInt(argv[arg_index + 1])) else if (!ostd::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;
@ -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::Utils::getHexStr(data::DPTStructure::DiskAddress, true, 4).cpp_str()).nl(); out.p(" DPT Block Address: ").p(ostd::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;
} }
@ -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::Utils::getHexStr(line.addr, true, 2)).p("\t\t"); out.fg(ostd::ConsoleColors::BrightGray).p(ostd::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::Utils::getHexStr(line.addr, true, 2)).p("\t\t"); out.fg(ostd::ConsoleColors::BrightGray).p(ostd::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::Utils::getHexStr(line.addr, true, 2)).p("\t\t"); out.fg(ostd::ConsoleColors::BrightGray).p(ostd::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();
} }

View file

@ -1,6 +1,5 @@
#include "Utils.hpp" #include "Utils.hpp"
#include <ostd/io/Serial.hpp> #include <ostd/io/Serial.hpp>
#include <ostd/utils/Utils.hpp>
#include <ostd/math/Random.hpp> #include <ostd/math/Random.hpp>
namespace dragon namespace dragon

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <ostd/data_types/Types.hpp> #include <ostd/data/Types.hpp>
#include <ostd/string/String.hpp> #include <ostd/string/String.hpp>
namespace dragon namespace dragon