Website Summary Files Commits Branches @commit @diff @stats
path: root / src / main.cpp
diff options
context:
space:
mode:
Commit6e19bb560d474736d45f5be011ff0830c7019991 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-11-05 23:34:00 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-11-05 23:34:00 +0200
Files42d29cf1c4e6a535ba526f434debaac3a70df2c6 /src/main.cpp
IPL-6e19bb560d474736d45f5be011ff0830c7019991.tar
IPL-6e19bb560d474736d45f5be011ff0830c7019991.tar.gz
IPL-6e19bb560d474736d45f5be011ff0830c7019991.zip
Squashed 'spasm/' content from commit 08ee95d
git-subtree-dir: spasm git-subtree-split: 08ee95d89054ba0d33697d613799a0a013aedf89
1 files changed, 33 insertions, 0 deletions
-rw-r--r--src/main.cpp33
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..17bb322
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,33 @@
+#include <fstream>
+#include <iostream>
+
+#include <memory>
+#include "spasm.hpp"
+
+int main(int argc, const char* argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ std::ifstream input(argv[1], std::ios_base::in | std::ios_base::binary);
+
+ size_t len;
+
+ input.read((char*)&len, sizeof(len));
+
+ std::unique_ptr<Spasm::byte[]> bytecode(new Spasm::byte[len]);
+
+ input.read((char*)bytecode.get(), len);
+
+ for (size_t i = 0; i < len; ++i)
+ std::cout << std::hex << (int)bytecode[i] << ' ';
+ std::cout << std::endl;
+
+ Spasm::Spasm vm(len, bytecode.get());
+
+ vm.run();
+
+ std::cout << std::endl;
+
+ return 0;
+}