Added debug_profiler instructions

This commit is contained in:
OmniaX 2024-09-05 00:40:36 +02:00
parent 58c7d9e0b9
commit e0059c8520
23 changed files with 209 additions and 41 deletions

26
.vscode/settings.json vendored
View file

@ -106,22 +106,23 @@
}, },
"workbench.colorCustomizations": { "workbench.colorCustomizations": {
"editor.background": "#131313", // "editor.background": "#131313",
"tab.hoverBackground": "#111", "tab.hoverBackground": "#022809",
"tab.inactiveBackground": "#000", "tab.inactiveBackground": "#000",
"tab.activeBackground": "#1b1b1b", "tab.activeBackground": "#001804",
"tab.activeBorder": "#bb5400", "editor.foldBackground": "#20070bcc",
"tab.activeBorder": "#15ff00",
"editorIndentGuide.background1": "#252525", "editorIndentGuide.background1": "#252525",
"editorWhitespace.foreground": "#683700", "editorWhitespace.foreground": "#683700",
"editor.lineHighlightBorder": "#1a1a1a", "editor.lineHighlightBorder": "#1a1a1a",
"editor.lineHighlightBackground": "#490050", "editor.lineHighlightBackground": "#0a200a",
"editorBracketMatch.background": "#444", "editorBracketMatch.background": "#444",
"editorBracketMatch.border": "#b80318", "editorBracketMatch.border": "#b80318",
"editor.selectionBackground": "#3b3b3b", "editor.selectionBackground": "#0e3616",
"editor.selectionHighlightBackground": "#702900e8", "editor.selectionHighlightBackground": "#9c3e08c5",
"statusBar.background": "#2e2850", // "statusBar.background": "#2e2850",
"minimap.background" : "#1b1b1b", "minimap.background" : "#0f0f0f",
"sideBar.background": "#1b1b1b" "sideBar.background": "#0b0b0b"
}, },
"workbench.editor.wrapTabs": true, "workbench.editor.wrapTabs": true,
@ -166,5 +167,8 @@
"python.languageServer": "None", "python.languageServer": "None",
"files.eol": "\r\n" "files.eol": "\r\n",
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Aramok's GLX Black"
} }

View file

@ -1 +1 @@
1603 1610

View file

@ -3,7 +3,7 @@ Bios = dragon/bios.bin
CMOS = dragon/cmos.dr CMOS = dragon/cmos.dr
cpuext = extmov, extalu cpuext = extmov, extalu
fixed_clock = true fixed_clock = false
clock_rate_sec = 644 clock_rate_sec = 644
memory_extension_pages = 16 memory_extension_pages = 16

Binary file not shown.

View file

@ -172,6 +172,18 @@
@end @end
@raw_export_end @raw_export_end
@export_comment BIOS_API " --\n" @export_comment BIOS_API " --\n"
@export_comment BIOS_API " Debugger Profiler time units."
@raw_export_start BIOS_API
@group DBGProfilerTime
MILLIS 0x00
SECS 0x01
MICROS 0x02
NANOS 0x03
@end
@raw_export_end
@export_comment BIOS_API " --\n"
## =============================================================================================== ## ===============================================================================================
.data .data

View file

@ -1,5 +1,5 @@
## -- ## --
## -- This file is automatically generated by the DragonAssembler (version 0.4.1602) ## -- This file is automatically generated by the DragonAssembler (version 0.4.1608)
## -- Please do not modify this file in any way. ## -- Please do not modify this file in any way.
## -- ## --
@ -109,3 +109,12 @@
@end @end
## -- ## --
## Debugger Profiler time units.
@group DBGProfilerTime
MILLIS 0x00
SECS 0x01
MICROS 0x02
NANOS 0x03
@end
## --

View file

@ -63,7 +63,9 @@ _disk_load_from_ddd_blocking:
and FL, 0b1111111111111110 ## Disable interrupts and FL, 0b1111111111111110 ## Disable interrupts
mov FL, ACC mov FL, ACC
_disk_load_from_ddd_blocking_wait_loop: _disk_load_from_ddd_blocking_wait_loop:
debug_profile_start 0xE0, DBGProfilerTime.MILLIS
mov ACC, [{DISK_INTERFACE_ADDR + DiskRegisters.RO_STATUS}] mov ACC, [{DISK_INTERFACE_ADDR + DiskRegisters.RO_STATUS}]
debug_profile_stop
jne $_disk_load_from_ddd_blocking_wait_loop, DiskStatus.FREE jne $_disk_load_from_ddd_blocking_wait_loop, DiskStatus.FREE
or FL, 0b0000000000000001 ## Enable interrupts or FL, 0b0000000000000001 ## Enable interrupts
mov FL, ACC mov FL, ACC

View file

@ -236,4 +236,4 @@
boot-ssector 5 kb 5120 bytes (0x1400) 0x0000.0400 -> 0x0000.17FF boot-ssector 5 kb 5120 bytes (0x1400) 0x0000.0400 -> 0x0000.17FF
Unallocated 90 kb 92160 bytes (0x16800) 0x0000.1800 -> 0x0001.7FFF Unallocated 90 kb 92160 bytes (0x16800) 0x0000.1800 -> 0x0001.7FFF
DragonOS 2000 kb 2048000 bytes (0x1F4000) 0x0001.8000 -> 0x0020.BFFF DragonOS 2000 kb 2048000 bytes (0x1F4000) 0x0001.8000 -> 0x0020.BFFF
Test Partition 2000 kb 2048000 bytes ( 0x1F4000) 0x0020.C000 -> 0x0040.0000 Test Partition 2000 kb 2048000 bytes (0x1F4000) 0x0020.C000 -> 0x0040.0000

View file

@ -6,5 +6,6 @@ clear='\033[0m'
printf "${green}Reloading BIOS...\n${clear}" printf "${green}Reloading BIOS...\n${clear}"
cd .. cd ..
cp ../extra/dss/bios/* ./dss/bios/ cp ../extra/dss/bios/* ./dss/bios/
./dasm dss/bios/entry.dss -o dragon/bios.bin --extalu --save-disassembly disassembly/bios.dds --verbose --save-exports ./dasm dss/bios/entry.dss -o dragon/bios.bin -D
# ./dasm dss/bios/entry.dss -o dragon/bios.bin --extalu --save-disassembly disassembly/bios.dds --verbose --save-exports
cp dragon/bios.bin ../extra/dragon/bios.bin cp dragon/bios.bin ../extra/dragon/bios.bin

View file

@ -8,11 +8,13 @@ cd ..
cp ../extra/dss/drake/* ./dss/drake/ cp ../extra/dss/drake/* ./dss/drake/
printf "\n${green}1) loader.dss\n${clear}" printf "\n${green}1) loader.dss\n${clear}"
./dasm dss/drake/loader.dss -o dragon/drake_loader.bin --extalu --save-disassembly disassembly/drake_loader.dds --verbose ./dasm dss/drake/loader.dss -o dragon/drake_loader.bin -D
# ./dasm dss/drake/loader.dss -o dragon/drake_loader.bin --extalu --save-disassembly disassembly/drake_loader.dds --verbose
./dtools load-binary dragon/disk1.dr dragon/drake_loader.bin 0x00000000 ./dtools load-binary dragon/disk1.dr dragon/drake_loader.bin 0x00000000
printf "\n${green}2) bootsector.dss\n${clear}" printf "\n${green}2) bootsector.dss\n${clear}"
./dasm dss/drake/bootsector.dss -o dragon/drake_bootsector.bin --extalu --save-disassembly disassembly/drake_bootsector.dds --verbose ./dasm dss/drake/bootsector.dss -o dragon/drake_bootsector.bin -D
# ./dasm dss/drake/bootsector.dss -o dragon/drake_bootsector.bin --extalu --save-disassembly disassembly/drake_bootsector.dds --verbose
./dtools load-binary dragon/disk1.dr dragon/drake_bootsector.bin 0x00000400 ./dtools load-binary dragon/disk1.dr dragon/drake_bootsector.bin 0x00000400
printf "\n" printf "\n"

View file

@ -994,6 +994,10 @@ namespace dragon
{ {
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3; _disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
lineEdit = replaceSymbols(lineEdit); lineEdit = replaceSymbols(lineEdit);
ostd::String _tmp_edit(lineEdit);
if (_tmp_edit.toLower().trim().startsWith("debug_"))
parseDebugOperands(lineEdit);
else
parse1Operand(lineEdit); parse1Operand(lineEdit);
_disassembly_line.code = lineEdit; _disassembly_line.code = lineEdit;
m_disassembly.push_back(_disassembly_line); m_disassembly.push_back(_disassembly_line);
@ -1003,6 +1007,10 @@ namespace dragon
{ {
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3; _disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
lineEdit = replaceSymbols(lineEdit); lineEdit = replaceSymbols(lineEdit);
ostd::String _tmp_edit(lineEdit);
if (_tmp_edit.toLower().trim().startsWith("debug_"))
parseDebugOperands(lineEdit);
else
parse2Operand(lineEdit); parse2Operand(lineEdit);
_disassembly_line.code = lineEdit; _disassembly_line.code = lineEdit;
m_disassembly.push_back(_disassembly_line); m_disassembly.push_back(_disassembly_line);
@ -1012,6 +1020,10 @@ namespace dragon
{ {
_disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3; _disassembly_line.addr = m_dataSize + m_loadAddress + m_code.size() + 3;
lineEdit = replaceSymbols(lineEdit); lineEdit = replaceSymbols(lineEdit);
ostd::String _tmp_edit(lineEdit);
if (_tmp_edit.toLower().trim().startsWith("debug_"))
parseDebugOperands(lineEdit);
else
parse3Operand(lineEdit); parse3Operand(lineEdit);
_disassembly_line.code = lineEdit; _disassembly_line.code = lineEdit;
m_disassembly.push_back(_disassembly_line); m_disassembly.push_back(_disassembly_line);
@ -1029,11 +1041,53 @@ namespace dragon
void Assembler::parseDebugOperands(ostd::String line) void Assembler::parseDebugOperands(ostd::String line)
{ {
if (!debugMode)
return;
if (ostd::String(line).toLower().startsWith("debug_break")) if (ostd::String(line).toLower().startsWith("debug_break"))
{ {
m_code.push_back(data::OpCodes::DEBUG_Break); m_code.push_back(data::OpCodes::DEBUG_Break);
return; return;
} }
else if (ostd::String(line).toLower().startsWith("debug_profile_stop"))
{
m_code.push_back(data::OpCodes::DEBUG_StopProfile);
return;
}
else if (ostd::String(line).toLower().startsWith("debug_profile_start"))
{
ostd::String lineEdit(line);
ostd::String instEdit(lineEdit.new_substr(0, lineEdit.indexOf(" ")));
instEdit.trim().toLower();
ostd::String opEdit(lineEdit.new_substr(lineEdit.indexOf(" ") + 1));
opEdit.trim();
int16_t word1 = 0x0000;
int16_t word2 = 0x0000;
auto st = opEdit.tokenize(",");
eOperandType opType1 = parseOperand(st.next(), word1);
if (opType1 == eOperandType::Immediate)
{
eOperandType opType2 = parseOperand(st.next(), word2);
switch (opType2)
{
case eOperandType::Immediate:
m_code.push_back(data::OpCodes::DEBUG_StartProfile);
m_code.push_back(static_cast<uint8_t>(word1));
m_code.push_back(static_cast<uint8_t>(word2));
break;
default:
std::cout << "Invalid operand2 type; " << line << " (" << opEdit << ")\n";
exit(0);
break;
}
}
else
{
std::cout << "Invalid operand1 type; " << line << " (" << opEdit << ")\n";
exit(0);
}
return;
}
} }
void Assembler::parse0Operand(ostd::String line) void Assembler::parse0Operand(ostd::String line)

View file

@ -92,7 +92,8 @@ namespace dragon
ostd::String dest_file_path { "" }; ostd::String dest_file_path { "" };
bool save_disassembly { false }; bool save_disassembly { false };
bool verbose { false }; bool verbose { false };
bool save_exports { false }; bool debug_mode { false };
bool save_exports { true };
ostd::String disassembly_file_path { "" }; ostd::String disassembly_file_path { "" };
std::vector<ostd::String> cpu_extensions; std::vector<ostd::String> cpu_extensions;
}; };
@ -171,6 +172,7 @@ namespace dragon
public: public:
inline static bool saveExports { false }; inline static bool saveExports { false };
inline static bool debugMode { false };
inline static std::vector<ostd::String> cpuExtensions; inline static std::vector<ostd::String> cpuExtensions;
}; };
} }

View file

@ -1,4 +1,6 @@
#include "Assembler.hpp" #include "Assembler.hpp"
#include "../tools/Utils.hpp"
#include <ostd/Random.hpp>
namespace dragon namespace dragon
{ {
@ -20,6 +22,9 @@ namespace dragon
print_application_help(); print_application_help();
return RETURN_VAL_CLOSE_PROGRAM; return RETURN_VAL_CLOSE_PROGRAM;
} }
args.disassembly_file_path = "";
bool disable_extmov = false;
bool disable_extalu = false;
for (int32_t i = 2; i < argc; i++) for (int32_t i = 2; i < argc; i++)
{ {
ostd::String edit(argv[i]); ostd::String edit(argv[i]);
@ -43,15 +48,28 @@ namespace dragon
print_application_help(); print_application_help();
return RETURN_VAL_CLOSE_PROGRAM; return RETURN_VAL_CLOSE_PROGRAM;
} }
else if (edit == "--extmov") else if (edit == "-D" || edit == "--debug")
args.cpu_extensions.push_back("extmov"); args.debug_mode = true;
else if (edit == "--extalu") else if (edit == "--disable-extmov")
args.cpu_extensions.push_back("extalu"); disable_extmov = true;
else if (edit == "--disable-extalu")
disable_extalu = true;
else if (edit == "--verbose") else if (edit == "--verbose")
args.verbose = true; args.verbose = true;
else if (edit == "--save-exports") else if (edit == "--disable-exports")
args.save_exports = true; args.save_exports = false;
} }
if (args.debug_mode)
{
// args.verbose = true;
args.save_disassembly = true;
}
if (!disable_extalu)
args.cpu_extensions.push_back("extalu");
if (!disable_extmov)
args.cpu_extensions.push_back("extmov");
if (args.save_disassembly && args.disassembly_file_path == "")
args.disassembly_file_path = "disassembly/" + ostd::Utils::md5(args.dest_file_path) + ".dds";
} }
return RETURN_VAL_EXIT_SUCCESS; return RETURN_VAL_EXIT_SUCCESS;
} }
@ -63,22 +81,25 @@ namespace dragon
out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl(); out.nl().fg(ostd::ConsoleColors::Yellow).p("List of available parameters:").reset().nl();
ostd::String tmpCommand = "--save-disassembly <destination-directory>"; 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.").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 = "--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();
tmpCommand = "-o <destination-binary-file>"; tmpCommand = "-o <destination-binary-file>";
tmpCommand.addRightPadding(commandLength); tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to specify the output binary file.").reset().nl(); out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to specify the output binary file.").reset().nl();
tmpCommand = "--save-exports"; tmpCommand = "--disable-exports";
tmpCommand.addRightPadding(commandLength); tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to save any specified exports in the code.").reset().nl(); out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to disable any specified exports in the code.").reset().nl();
tmpCommand = "--extmov"; tmpCommand = "--disable-extmov";
tmpCommand.addRightPadding(commandLength); tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Enables mnemonics for the <extmov> CPU extension.").reset().nl(); out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Disables mnemonics for the <extmov> CPU extension.").reset().nl();
tmpCommand = "--extalu"; tmpCommand = "--disable-extalu";
tmpCommand.addRightPadding(commandLength); tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Enables mnemonics for the <extalu> CPU extension.").reset().nl(); out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Disables mnemonics for the <extalu> CPU extension.").reset().nl();
tmpCommand = "--debug, -D";
tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to enable debug mode.").reset().nl();
tmpCommand = "--help"; tmpCommand = "--help";
tmpCommand.addRightPadding(commandLength); tmpCommand.addRightPadding(commandLength);
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Displays this help message.").reset().nl(); out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Displays this help message.").reset().nl();

View file

@ -9,6 +9,7 @@ int main(int argc, char** argv)
return rValue; return rValue;
auto& args = dragon::code::Assembler::Application::args; auto& args = dragon::code::Assembler::Application::args;
dragon::code::Assembler::saveExports = args.save_exports; dragon::code::Assembler::saveExports = args.save_exports;
dragon::code::Assembler::debugMode = args.debug_mode;
dragon::code::Assembler::cpuExtensions = args.cpu_extensions; dragon::code::Assembler::cpuExtensions = args.cpu_extensions;
dragon::code::Assembler::assembleToFile(args.source_file_path, args.dest_file_path); dragon::code::Assembler::assembleToFile(args.source_file_path, args.dest_file_path);
if (args.verbose) if (args.verbose)

View file

@ -234,6 +234,28 @@ namespace dragon
m_biosMode = value != 0; m_biosMode = value != 0;
} }
break; break;
case data::OpCodes::DEBUG_StartProfile:
{
int8_t id = fetch8();
int8_t timeUnit = fetch8();
ostd::eTimeUnits tu = ostd::eTimeUnits::Milliseconds;
if (static_cast<eDebugProfilerTimeUnits>(timeUnit) == eDebugProfilerTimeUnits::Micros)
tu = ostd::eTimeUnits::Microseconds;
else if (static_cast<eDebugProfilerTimeUnits>(timeUnit) == eDebugProfilerTimeUnits::Nanos)
tu = ostd::eTimeUnits::Nanoseconds;
else if (static_cast<eDebugProfilerTimeUnits>(timeUnit) == eDebugProfilerTimeUnits::Secs)
tu = ostd::eTimeUnits::Seconds;
m_profilerTimer.start(true, ostd::String("DebugProfiler [").add(ostd::Utils::getHexStr(id, true, 1)).add("]"), tu);
m_debugProfilerStarted = true;
}
break;
case data::OpCodes::DEBUG_StopProfile:
{
if (m_debugProfilerStarted)
m_profilerTimer.end(true);
m_debugProfilerStarted = false;
}
break;
case data::OpCodes::MovImmReg: case data::OpCodes::MovImmReg:
{ {
uint8_t regAddr = fetch8(); uint8_t regAddr = fetch8();

View file

@ -15,6 +15,7 @@ namespace dragon
{ {
class VirtualCPU class VirtualCPU
{ {
public: enum class eDebugProfilerTimeUnits { Millis = 0, Secs = 1, Micros = 2, Nanos = 3 };
public: public:
VirtualCPU(IMemoryDevice& memory); VirtualCPU(IMemoryDevice& memory);
int16_t readRegister(uint8_t reg); int16_t readRegister(uint8_t reg);
@ -66,6 +67,7 @@ namespace dragon
bool m_isDebugBreakPoint { false }; bool m_isDebugBreakPoint { false };
bool m_debugModeEnabled { false }; bool m_debugModeEnabled { false };
int32_t m_subroutineCounter { 0 }; int32_t m_subroutineCounter { 0 };
bool m_debugProfilerStarted { false };
bool m_isOffsetAddressingEnabled { false }; bool m_isOffsetAddressingEnabled { false };
uint16_t m_currentOffset { 0x0000 }; uint16_t m_currentOffset { 0x0000 };
@ -76,6 +78,8 @@ namespace dragon
std::vector<ostd::String> m_debug_stackFrameStrings; std::vector<ostd::String> m_debug_stackFrameStrings;
ostd::Timer m_profilerTimer;
friend class dragon::DragonRuntime; friend class dragon::DragonRuntime;
friend class dragon::Debugger::Display; friend class dragon::Debugger::Display;
friend class dragon::Debugger; friend class dragon::Debugger;

View file

@ -74,6 +74,8 @@ namespace dragon
m_renderer.displayBuffer(); m_renderer.displayBuffer();
} }
static char c = 'A';
void VirtualDisplay::onUpdate(void) void VirtualDisplay::onUpdate(void)
{ {
auto& mem = DragonRuntime::memMap; auto& mem = DragonRuntime::memMap;
@ -143,7 +145,16 @@ namespace dragon
int16_t x = mem.read16(vga_addr + tRegisters::MemControllerX); int16_t x = mem.read16(vga_addr + tRegisters::MemControllerX);
int16_t y = mem.read16(vga_addr + tRegisters::MemControllerY); int16_t y = mem.read16(vga_addr + tRegisters::MemControllerY);
DragonRuntime::vGraphicsInterface.writeVRAM_16Colors(static_cast<uint8_t>(x), static_cast<uint8_t>(y), textCell.character, textCell.backgroundColor, textCell.foregroundColor); //TODO: Remove this override used for testing purposes
for (int32_t i = 0; i < RawTextRenderer::CONSOLE_CHARS_V * RawTextRenderer::CONSOLE_CHARS_H; i++)
{
auto xy = CONVERT_1D_2D(i, RawTextRenderer::CONSOLE_CHARS_H);
DragonRuntime::vGraphicsInterface.writeVRAM_16Colors(static_cast<uint8_t>(xy.x), static_cast<uint8_t>(xy.y), c++, 0, 15);
if (c > 'Z')
c = 'A';
}
// DragonRuntime::vGraphicsInterface.writeVRAM_16Colors(static_cast<uint8_t>(x), static_cast<uint8_t>(y), textCell.character, textCell.backgroundColor, textCell.foregroundColor);
} }
} }
else return; else return;

View file

@ -352,15 +352,17 @@ namespace dragon
ostd::Timer clock_timer; ostd::Timer clock_timer;
bool running = true; bool running = true;
bool fixed_clock = machine_config.fixed_clock; bool fixed_clock = machine_config.fixed_clock;
// ostd::Timer _timer;
while (running || vDiskInterface.isBusy()) while (running || vDiskInterface.isBusy())
{ {
clock_timer.startCount(ostd::eTimeUnits::Microseconds); clock_timer.startCount(ostd::eTimeUnits::Microseconds);
ostd::SignalHandler::refresh(); ostd::SignalHandler::refresh();
uint16_t addr = cpu.readRegister(dragon::data::Registers::IP); uint16_t addr = cpu.readRegister(dragon::data::Registers::IP);
uint16_t spAddr = cpu.readRegister(dragon::data::Registers::SP); uint16_t spAddr = cpu.readRegister(dragon::data::Registers::SP);
// _timer.start(true, "Profiling", ostd::eTimeUnits::Microseconds, &out);
running = cpu.execute() && vDisplay.isRunning(); running = cpu.execute() && vDisplay.isRunning();
// _timer.end(true);
vDisplay.update(); vDisplay.update();
cpu.getCurrentInstruction();
vDiskInterface.cycleStep(); vDiskInterface.cycleStep();
if (dragon::data::ErrorHandler::hasError()) if (dragon::data::ErrorHandler::hasError())
{ {

View file

@ -15,6 +15,8 @@ namespace dragon
case data::OpCodes::NoOp: return "NoOp"; case data::OpCodes::NoOp: return "NoOp";
case data::OpCodes::DEBUG_Break: return "debug_break"; case data::OpCodes::DEBUG_Break: return "debug_break";
case data::OpCodes::BIOSModeImm: return "BIOSModeImm"; case data::OpCodes::BIOSModeImm: return "BIOSModeImm";
case data::OpCodes::DEBUG_StartProfile: return "debug_start_profile";
case data::OpCodes::DEBUG_StopProfile: return "debug_stop_profile";
case data::OpCodes::MovImmReg: return "MovImmReg"; case data::OpCodes::MovImmReg: return "MovImmReg";
case data::OpCodes::MovImmMem: return "MovImmMem"; case data::OpCodes::MovImmMem: return "MovImmMem";
case data::OpCodes::MovRegReg: return "MovRegReg"; case data::OpCodes::MovRegReg: return "MovRegReg";
@ -113,6 +115,8 @@ namespace dragon
case data::OpCodes::NoOp: return 1; case data::OpCodes::NoOp: return 1;
case data::OpCodes::DEBUG_Break: return 1; case data::OpCodes::DEBUG_Break: return 1;
case data::OpCodes::BIOSModeImm: return 2; case data::OpCodes::BIOSModeImm: return 2;
case data::OpCodes::DEBUG_StartProfile: return 1;
case data::OpCodes::DEBUG_StopProfile: return 1;
case data::OpCodes::MovImmReg: return 4; case data::OpCodes::MovImmReg: return 4;
case data::OpCodes::MovImmMem: return 5; case data::OpCodes::MovImmMem: return 5;
case data::OpCodes::MovRegReg: return 3; case data::OpCodes::MovRegReg: return 3;

View file

@ -279,6 +279,8 @@ namespace dragon
inline static constexpr uint8_t NoOp = 0x00; inline static constexpr uint8_t NoOp = 0x00;
inline static constexpr uint8_t DEBUG_Break = 0x01; inline static constexpr uint8_t DEBUG_Break = 0x01;
inline static constexpr uint8_t BIOSModeImm = 0x02; inline static constexpr uint8_t BIOSModeImm = 0x02;
inline static constexpr uint8_t DEBUG_StartProfile = 0x03;
inline static constexpr uint8_t DEBUG_StopProfile = 0x04;
inline static constexpr uint8_t MovImmReg = 0x10; inline static constexpr uint8_t MovImmReg = 0x10;
inline static constexpr uint8_t MovRegReg = 0x11; inline static constexpr uint8_t MovRegReg = 0x11;

View file

@ -1,7 +1,20 @@
#include "Utils.hpp" #include "Utils.hpp"
#include <ostd/Serial.hpp> #include <ostd/Serial.hpp>
#include <ostd/Utils.hpp> #include <ostd/Utils.hpp>
#include <ostd/Random.hpp>
namespace dragon namespace dragon
{ {
static const std::vector<char> g_symbols = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
ostd::String Utils::genRandomName(uint8_t length)
{
auto rnd_char = []() -> char {
return g_symbols[ostd::Random::getui8(0, g_symbols.size())];
};
ostd::String name = "";
for (int32_t i = 0; i < length; i++)
name.addChar(rnd_char());
return name;
}
} }

View file

@ -1,11 +1,13 @@
#pragma once #pragma once
#include <ostd/Types.hpp> #include <ostd/Types.hpp>
#include <ostd/String.hpp>
namespace dragon namespace dragon
{ {
class Utils class Utils
{ {
public: public:
static ostd::String genRandomName(uint8_t length);
}; };
} }