summaryrefslogtreecommitdiffstats
path: root/sdmaasm/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sdmaasm/main.cpp')
-rwxr-xr-xsdmaasm/main.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/sdmaasm/main.cpp b/sdmaasm/main.cpp
new file mode 100755
index 0000000..57fe9d5
--- /dev/null
+++ b/sdmaasm/main.cpp
@@ -0,0 +1,94 @@
+/*
+* main.cpp
+*
+* main
+*
+* Copyright 2010 Tobias Wirtl, HBM <tobias.wirtl@hbm.com>
+*
+* The code contained herein is licensed under the GNU General Public
+* License. You may obtain a copy of the GNU General Public License
+* Version 2 or later at the following locations:
+*
+* http://www.opensource.org/licenses/gpl-license.html
+* http://www.gnu.org/copyleft/gpl.html
+*/
+
+
+#include "instructionlist.h"
+#include "instruction.h"
+#include "instructionparser.h"
+#include <iostream>
+#include "helpers.h"
+
+//#define DEBUG
+
+
+int main(int argc, char *argv[])
+{
+
+ string mode;
+ string source;
+ string target;
+ string inlPath;
+
+#ifndef DEBUG
+ if (argc >= 4)
+ {
+ mode = argv[1];
+ source = argv[2];
+ target = argv[3];
+ inlPath = argv[4];
+#else
+
+ mode
+ asmPath = "../SDMA_ASM/asm.txt";
+ blobPath = "../SDMA_ASM/firmware.blob";
+ inlPath = "../SDMA_ASM/sdma.inst";
+ outFile = "../SDMA_ASM/out.hex";
+
+#endif
+ InstructionList* il = new InstructionList(inlPath);
+ InstructionParser parser(il);
+
+ cout <<"\nPath to source file: "<<source<<'\n'
+ <<"Path to instructions file: "<<inlPath<<'\n'
+ <<"Path to output file: "<<target<<"\n\n";
+
+
+ if (mode == "-a")
+ {
+ parser.readProgramLines(source);
+ parser.binaryOutputToFile(target);
+ }
+ else if (mode == "-d")
+ {
+ parser.readTextBlob(source);
+ parser.instructionOutputToFile(target);
+ cout<<"\ndone!\n";
+ }
+ else
+ cout<<"Unknown mode: "<<mode<<'\n';
+
+#ifndef DEBUG
+ }
+ else
+ cout <<"Assembler for the i.MX356 SDMA controller\n"
+ <<"Copyright HBM 2010\n\n"
+
+ <<"This program is licensed under the GNU General Public\n"
+ <<"License. You may obtain a copy of the GNU General Public License\n"
+ <<"Version 2 or later at the following locations:\n"
+ <<"http://www.opensource.org/licenses/gpl-license.html\n"
+ <<"http://www.gnu.org/copyleft/gpl.html\n\n"
+
+ <<"Usage: SDMA_ASM [mode] [source] [target] [instruction file]\n"
+ <<"possible modes \n"
+ <<"\t-d disassemble\thex blob --> code file \n"
+ <<"\t-a assemble\t\tcode file --> hexfile\n";
+#endif
+
+
+
+ return 0;
+}
+