From 6e19bb560d474736d45f5be011ff0830c7019991 Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Mon, 5 Nov 2018 23:34:00 +0200 Subject: Squashed 'spasm/' content from commit 08ee95d git-subtree-dir: spasm git-subtree-split: 08ee95d89054ba0d33697d613799a0a013aedf89 --- src/asm/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/asm/main.cpp (limited to 'src/asm/main.cpp') diff --git a/src/asm/main.cpp b/src/asm/main.cpp new file mode 100644 index 0000000..da8fcf6 --- /dev/null +++ b/src/asm/main.cpp @@ -0,0 +1,21 @@ +#include +#include +#include "assembler.hpp" + +int main(int argc, const char* argv[]) +{ + if (argc != 2) + return 1; + SpasmImpl::ASM::Bytecode_Memory bytecode; + SpasmImpl::ASM::compile(std::cin, bytecode); + + std::ofstream output(argv[1], std::ios_base::out | std::ios_base::binary); + + // output.write ("SPASM", 5); + auto& bc = bytecode.bytecode(); + auto size = bc.size(); + output.write(reinterpret_cast(&size), sizeof(size)); + output.write(reinterpret_cast(bc.data()), size); + + return 0; +} -- cgit v1.3.1-23-gd82d