add reversing
This commit is contained in:
33
src/main.cpp
33
src/main.cpp
@@ -8,9 +8,7 @@ int main(int argc, char** argv) {
|
||||
argparse::ArgumentParser program("Assembleur");
|
||||
|
||||
std::string inputFileName;
|
||||
program.add_argument("file")
|
||||
.help("The assembly file to compile")
|
||||
.store_into(inputFileName);
|
||||
program.add_argument("file").help("The assembly file to compile").store_into(inputFileName);
|
||||
|
||||
std::string outputFileName;
|
||||
program.add_argument("-o", "--output")
|
||||
@@ -21,12 +19,25 @@ int main(int argc, char** argv) {
|
||||
|
||||
std::string formatType;
|
||||
program.add_argument("-f", "--format")
|
||||
.help("Type of the output. [bin|int|binint]")
|
||||
.help("Type of the output. [logisim|bin|int|binint]")
|
||||
.metavar("type")
|
||||
.default_value(std::string("binint"))
|
||||
.choices("bin", "int", "binint")
|
||||
.default_value(std::string("logisim"))
|
||||
.choices("logisim", "bin", "int", "binint")
|
||||
.store_into(formatType);
|
||||
|
||||
std::string header;
|
||||
program.add_argument("-h", "--header")
|
||||
.help("Header of the file")
|
||||
.metavar("header")
|
||||
.default_value(std::string("v3.0 hex words addressed"))
|
||||
.store_into(header);
|
||||
|
||||
bool reverse;
|
||||
program.add_argument("-r", "--reversed")
|
||||
.help("inverse bit orders")
|
||||
.flag()
|
||||
.store_into(reverse);
|
||||
|
||||
try {
|
||||
program.parse_args(argc, argv);
|
||||
} catch (const std::exception& err) {
|
||||
@@ -38,12 +49,14 @@ int main(int argc, char** argv) {
|
||||
try {
|
||||
auto output = ParseFile(inputFileName);
|
||||
|
||||
if (formatType == "bin") {
|
||||
OutputFileBinary(output, outputFileName);
|
||||
if (formatType == "logisim") {
|
||||
OutputFileLogisim(output, outputFileName, header, reverse);
|
||||
} else if (formatType == "bin") {
|
||||
OutputFileBinary(output, outputFileName, reverse);
|
||||
} else if (formatType == "int") {
|
||||
OutputFileIntegers(output, outputFileName);
|
||||
OutputFileIntegers(output, outputFileName, reverse);
|
||||
} else {
|
||||
OutputFileBinIntegers(output, outputFileName);
|
||||
OutputFileBinIntegers(output, outputFileName, reverse);
|
||||
}
|
||||
|
||||
} catch (std::runtime_error& e) {
|
||||
|
||||
Reference in New Issue
Block a user