Added basic fixed clock
This commit is contained in:
parent
c9014b99b0
commit
f40ae0a036
5 changed files with 23 additions and 121 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"C_Cpp.errorSquiggles": "enabled",
|
||||
"files.associations": {
|
||||
"*.dss": "python",
|
||||
"functional": "cpp",
|
||||
"thread": "cpp",
|
||||
"cctype": "cpp",
|
||||
|
|
@ -97,7 +98,7 @@
|
|||
"*.ipp": "cpp",
|
||||
"format": "cpp",
|
||||
"stdfloat": "cpp",
|
||||
"*.dss": "python"
|
||||
"*.inc": "cpp"
|
||||
},
|
||||
"workbench.editorAssociations": {
|
||||
"*.bin": "hexEditor.hexedit"
|
||||
|
|
|
|||
|
|
@ -6,55 +6,4 @@ Add possibility to specify required instruction sets in dasm
|
|||
|
||||
#***Add "Extended mov" instruction set
|
||||
#***Remove old offset mov
|
||||
#***Implelemnt extmov mnemonics in dasm:
|
||||
|
||||
## Offset on first operand
|
||||
## omov *R1, 0xFAAB, word 4 ## Move word immediate into (deref reg + immediate offset word)
|
||||
## omov *R1, 0xFAAB, R10 ## Move word immediate into (deref reg + reg offset)
|
||||
## omov *R1, 0xFAAB, 4 ## Move word immediate into (deref reg + immediate offset byte)
|
||||
|
||||
## omovb *R1, 0xFA, word 4 ## Move byte immediate into (deref reg + immediate offset word)
|
||||
## omovb *R1, 0xFA, R10 ## Move byte immediate into (deref reg + reg offset)
|
||||
## omovb *R1, 0xFA, 4 ## Move byte immediate into (deref reg + immediate offset byte)
|
||||
|
||||
## omov *R1, *R2, word 4 ## Move word deref reg into (deref reg + immediate offset word)
|
||||
## omov *R1, *R2, R10 ## Move word deref reg into (deref reg + reg offset)
|
||||
## omov *R1, *R2, 4 ## Move word deref reg into (deref reg + immediate offset byte)
|
||||
|
||||
## omovb *R1, *R2, word 4 ## Move byte deref reg into (deref reg + immediate offset word)
|
||||
## omovb *R1, *R2, R10 ## Move byte deref reg into (deref reg + reg offset)
|
||||
## omovb *R1, *R2, 4 ## Move byte deref reg into (deref reg + immediate offset byte)
|
||||
|
||||
## omov [0x1800], 0xACAB, word 4 ## Move word immediate into (Memory + immediate offset word)
|
||||
## omov [0x1800], 0xACAB, R10 ## Move word immediate into (Memory + reg offset)
|
||||
## omov [0x1800], 0xACAB, 4 ## Move word immediate into (Memory + immediate offset byte)
|
||||
|
||||
## omovb [0x1800], 0xAC, word 4 ## Move byte immediate into (Memory + immediate offset word)
|
||||
## omovb [0x1800], 0xAC, R10 ## Move byte immediate into (Memory + reg offset)
|
||||
## omovb [0x1800], 0xAC, 4 ## Move byte immediate into (Memory + immediate offset byte)
|
||||
|
||||
|
||||
## Offset on second operand
|
||||
## movo *R1, *R2, word 4 ## Move word (deref reg + immediate offset word) into deref reg
|
||||
## movo *R1, *R2, R10 ## Move word (deref reg + reg offset) into deref reg
|
||||
## movo *R1, *R2, 4 ## Move word (deref reg + immediate offset byte) into deref reg
|
||||
|
||||
## movbo *R1, *R2, word 4 ## Move byte (deref reg + immediate offset word) into deref reg
|
||||
## movbo *R1, *R2, R10 ## Move byte (deref reg + reg offset) into deref reg
|
||||
## movbo *R1, *R2, 4 ## Move byte (deref reg + immediate offset byte) into deref reg
|
||||
|
||||
## movo R1, [0xFAAB], word 4 ## Move word (Memory + immediate offset word) into reg
|
||||
## movo R1, [0xFAAB], R10 ## Move word (Memory + reg offset) into reg
|
||||
## movo R1, [0xFAAB], 4 ## Move word (Memory + immediate offset byte) into reg
|
||||
|
||||
## movbo R1, [0xFAAB], word 4 ## Move byte (Memory + immediate offset word) into reg
|
||||
## movbo R1, [0xFAAB], R10 ## Move byte (Memory + reg offset) into reg
|
||||
## movbo R1, [0xFAAB], 4 ## Move byte (Memory + immediate offset byte) into reg
|
||||
|
||||
## movo R1, *R2, word 4 ## Move word (deref reg + immediate offset word) into reg
|
||||
## movo R1, *R2, R10 ## Move word (deref reg + reg offset) into reg
|
||||
## movo R1, *R2, 4 ## Move word (deref reg + immediate offset byte) into reg
|
||||
|
||||
## movbo R1, *R2, word 4 ## Move byte (deref reg + immediate offset word) into reg
|
||||
## movbo R1, *R2, R10 ## Move byte (deref reg + reg offset) into reg
|
||||
## movbo R1, *R2, 4 ## Move byte (deref reg + immediate offset byte) into reg
|
||||
#***Implelemnt extmov mnemonics in dasm:
|
||||
|
|
@ -102,22 +102,8 @@ namespace dragon
|
|||
for (int32_t i = 2; i < argc; i++)
|
||||
{
|
||||
ostd::String edit(argv[i]);
|
||||
if (edit == "--debug")
|
||||
args.basic_debug = true;
|
||||
else if (edit == "--step")
|
||||
args.step_exec = true;
|
||||
else if (edit == "--verbose-load")
|
||||
if (edit == "--verbose-load")
|
||||
args.verbose_load = true;
|
||||
else if (edit == "--limit-cycles")
|
||||
{
|
||||
if (i == argc - 1)
|
||||
return RETURN_VAL_MISSING_PARAM;
|
||||
i++;
|
||||
edit = argv[i];
|
||||
if (!edit.isNumeric())
|
||||
return RETURN_VAL_PARAMETER_NOT_NUMERIC;
|
||||
args.cycle_limit = (int32_t)edit.toInt();
|
||||
}
|
||||
else if (edit == "--force-load")
|
||||
{
|
||||
if ((argc - 1) - i < 2)
|
||||
|
|
@ -339,57 +325,35 @@ namespace dragon
|
|||
machine_config.destroy();
|
||||
}
|
||||
|
||||
void DragonRuntime::runMachine(int32_t cycleLimit, bool basic_debug, bool step_exec)
|
||||
void DragonRuntime::runMachine(void)
|
||||
{
|
||||
int32_t cycleCounter = 0;
|
||||
double clock_speed_us = 2000;
|
||||
double acc = 0;
|
||||
ostd::Timer clock_timer;
|
||||
bool running = true;
|
||||
uint8_t currentInst = 0x00;
|
||||
uint32_t instSize = 0;
|
||||
ostd::ByteStream& ramData = *ram.getByteStream();
|
||||
// while ((running || vDiskInterface.isBusy()) && cycleCounter++ < 2048)
|
||||
while (running || vDiskInterface.isBusy())
|
||||
{
|
||||
if (basic_debug)
|
||||
out.clear();
|
||||
clock_timer.startCount(ostd::eTimeUnits::Microseconds);
|
||||
ostd::SignalHandler::refresh();
|
||||
uint16_t addr = cpu.readRegister(dragon::data::Registers::IP);
|
||||
uint16_t spAddr = cpu.readRegister(dragon::data::Registers::SP);
|
||||
running = cpu.execute() && vDisplay.isRunning();
|
||||
vDisplay.update();
|
||||
currentInst = cpu.getCurrentInstruction();
|
||||
cpu.getCurrentInstruction();
|
||||
vDiskInterface.cycleStep();
|
||||
ostd::ConsoleOutputHandler newOut; //TODO: This workaround is not good, this whole file needs to be updated to not use the legacy ConsoleOutputHandler
|
||||
if ((cpu.isInDebugBreakPoint() || step_exec) && basic_debug)
|
||||
if (dragon::data::ErrorHandler::hasError())
|
||||
{
|
||||
instSize = dragon::data::OpCodes::getInstructionSIze(currentInst);
|
||||
ostd::Utils::printByteStream(ramData, dragon::data::MemoryMapAddresses::Memory_Start, 16, 10, newOut, addr, instSize, " MEMORY");
|
||||
printRegisters(cpu);
|
||||
out.nl().fg("yellow").p("Current Instruction: ").fg("white").p(ostd::Utils::getHexStr(currentInst, true, 1).cpp_str());
|
||||
out.nl();
|
||||
out.fg(ostd::ConsoleColors::Magenta).p("######### Reached Break Point at ");
|
||||
out.p(ostd::Utils::getHexStr(addr, true, 2).cpp_str());
|
||||
out.nl().reset();
|
||||
std::cin.get();
|
||||
continue;
|
||||
}
|
||||
else if (dragon::data::ErrorHandler::hasError())
|
||||
{
|
||||
if (!basic_debug)
|
||||
{
|
||||
processErrors();
|
||||
continue;
|
||||
}
|
||||
instSize = dragon::data::OpCodes::getInstructionSIze(currentInst);
|
||||
ostd::Utils::printByteStream(ramData, dragon::data::MemoryMapAddresses::Memory_Start, 16, 10, newOut, addr, instSize, " MEMORY");
|
||||
printRegisters(cpu);
|
||||
out.nl().fg("yellow").p("Current Instruction: ").fg("white").p(ostd::Utils::getHexStr(currentInst, true, 1).cpp_str());
|
||||
out.nl();
|
||||
out.fg(ostd::ConsoleColors::Red).p("######### Error occurred at ");
|
||||
out.p(ostd::Utils::getHexStr(addr, true, 2).cpp_str());
|
||||
out.nl().reset();
|
||||
processErrors();
|
||||
std::cin.get();
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
uint64_t _time = clock_timer.endCount();
|
||||
if (_time < clock_speed_us)
|
||||
ostd::Utils::sleep(clock_speed_us - _time, ostd::eTimeUnits::Microseconds);
|
||||
acc++;
|
||||
if (acc == 500)
|
||||
{
|
||||
std::cout << _time << "\n";
|
||||
acc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -552,15 +516,6 @@ namespace dragon
|
|||
ostd::String tmpCommand = "--verbose-load";
|
||||
tmpCommand.addRightPadding(commandLength);
|
||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Used to show more information while loading the virtual machine.").reset().nl();
|
||||
tmpCommand = "--step";
|
||||
tmpCommand.addRightPadding(commandLength);
|
||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Launches the runtime in basic step-esecution mode.").reset().nl();
|
||||
tmpCommand = "--debug";
|
||||
tmpCommand.addRightPadding(commandLength);
|
||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Launches the runtime in basic debug mode.").reset().nl();
|
||||
tmpCommand = "--limit-cycles <cycles>";
|
||||
tmpCommand.addRightPadding(commandLength);
|
||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Sets the maximum amount of clock cycles the runtime can run.").reset().nl();
|
||||
tmpCommand = "--force-load <binary-file> <ram-offset>";
|
||||
tmpCommand.addRightPadding(commandLength);
|
||||
out.fg(ostd::ConsoleColors::Blue).p(tmpCommand).fg(ostd::ConsoleColors::Green).p("Injects the specified binary into RAM at the specified offset.").reset().nl();
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ namespace dragon
|
|||
public: struct tCommandLineArgs
|
||||
{
|
||||
ostd::String machine_config_path = "";
|
||||
bool basic_debug = false;
|
||||
bool step_exec = false;
|
||||
bool verbose_load = false;
|
||||
int32_t cycle_limit = 0;
|
||||
bool force_load = false;
|
||||
ostd::String force_load_file = "";
|
||||
uint16_t force_load_mem_offset = 0x00;
|
||||
|
|
@ -97,7 +94,7 @@ namespace dragon
|
|||
bool rackCallStack = false,
|
||||
bool debugModeEnabled = false);
|
||||
static void shutdownMachine(void);
|
||||
static void runMachine(int32_t cycleLimit, bool basic_debug, bool step_exec);
|
||||
static void runMachine(void);
|
||||
static bool runStep(std::vector<uint16_t> trackedAddresses = { });
|
||||
static void forceLoad(const ostd::String& filePath, uint16_t loadAddress);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ int main(int argc, char** argv)
|
|||
//Executing the runtime
|
||||
if (args.force_load)
|
||||
dragon::DragonRuntime::forceLoad(args.force_load_file, args.force_load_mem_offset);
|
||||
dragon::DragonRuntime::runMachine(args.cycle_limit, args.basic_debug, args.step_exec);
|
||||
dragon::DragonRuntime::runMachine();
|
||||
return dragon::DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue