-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the code that calls the emulation to the IOHelper.
- Loading branch information
Showing
5 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,54 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
|
||
#include"CComputer.h" | ||
#include"args.hxx" | ||
#include"CIOHelper.h" | ||
|
||
int main() | ||
int main(int argc, char **argv) | ||
{ | ||
Neander::CComputer neanderComputer; | ||
// Main return value | ||
int retValue(0); | ||
|
||
std::array<uint8_t, Neander::CComputer::ms_cMemorySize> exampleProgram; | ||
// CLI arguments | ||
args::ArgumentParser parser("Neander Emulator", "Made by: Arthur Zachow Coelho"); | ||
args::HelpFlag help(parser, "help", "Display this help menu", { 'h', "help" }); | ||
args::ValueFlag<std::string> inputPath(parser, "input_program_file", "Input program file (.mem)", { 'i' }); | ||
args::ValueFlag<std::string> outputPath(parser, "output_program_file", "Output memory file (.mem)", { 'o' }); | ||
|
||
Neander::CIOHelper::EIOCode loadStatus = | ||
Neander::CIOHelper::LoadProgramFromFile("/home/lain/projects/Emuander/teste.mem", exampleProgram); | ||
|
||
if (loadStatus == Neander::CIOHelper::EIOCode::SUCCESS) | ||
try | ||
{ | ||
neanderComputer.setMemory(exampleProgram); | ||
|
||
neanderComputer.runProgram(); | ||
|
||
Neander::SRegisters registersRead(neanderComputer.getRegisters()); | ||
|
||
Neander::CIOHelper::PrintRegisters(registersRead); | ||
parser.ParseCLI(argc, argv); | ||
} | ||
catch (args::Help& e) | ||
{ | ||
std::cout << parser; | ||
retValue = 0; | ||
} | ||
catch (args::ParseError& e) | ||
{ | ||
std::cerr << e.what() << std::endl; | ||
std::cerr << parser; | ||
retValue = 1; | ||
} | ||
catch (args::ValidationError& e) | ||
{ | ||
std::cerr << e.what() << std::endl; | ||
std::cerr << parser; | ||
retValue = 1; | ||
} | ||
|
||
Neander::CIOHelper::SaveProgramToFile( | ||
neanderComputer.getMemory(), | ||
"/home/lain/projects/Emuander/testeOut2.mem"); | ||
if (inputPath && outputPath) | ||
{ | ||
std::cout << "Running Neander..." << std::endl; | ||
Neander::CIOHelper::RunNeander(args::get(inputPath), args::get(outputPath)); | ||
retValue = 0; | ||
} | ||
else | ||
{ | ||
std::cout << "Neander usage:" << std::endl; | ||
std::cout << parser; | ||
retValue = 0; | ||
} | ||
|
||
return 0; | ||
return retValue; | ||
} |