diff options
author | Roland Reichwein <mail@reichwein.it> | 2024-08-31 18:29:58 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2024-08-31 18:29:58 +0200 |
commit | 02153da4d5954261f6649e2980bc88f6d29e45a6 (patch) | |
tree | 4cc1ce6d1124edf791e48fcdb28b33a614d1a358 /asm/arm/main.cpp | |
parent | f8c4fe1614cc79df9f97c8a7754cf2a5aaf5063d (diff) |
ARM assembler (WIP)
Diffstat (limited to 'asm/arm/main.cpp')
-rw-r--r-- | asm/arm/main.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/asm/arm/main.cpp b/asm/arm/main.cpp new file mode 100644 index 0000000..20e67ab --- /dev/null +++ b/asm/arm/main.cpp @@ -0,0 +1,41 @@ +#include <iostream> +#include <stdexcept> + +#include <fmt/format.h> + +#include <libreichwein/file.h> + +#include "assembler.h" +#include "instruction.h" + +void dump(const code_sequence& c) +{ + for (size_t i = 0; i < c.size(); ++i) { + if ((i % 16) == 0) { + if (i > 0) + std::cout << std::endl; + } else { + std::cout << " "; + } + std::cout << fmt::format("{:02x}", c[i]); + } + std::cout << std::endl; +} + +int main(int argc, char* argv[]) +{ + try { + if (argc == 2) { + Assembler assembler; + std::string source {Reichwein::File::getFile(argv[1])}; + code_sequence result {assembler.encode(source)}; + dump(result); + } + return 0; + } catch (const std::exception& ex) { + std::cerr << "Error: " << ex.what() << std::endl; + return 1; + } + return 2; +} + |