Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / main.cpp
blob: 7c423cb78029340d1c2754d20fca3e81536d6890 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#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;
    vm.Initialize(len, bytecode.get());

    vm.run();

    std::cout << std::endl;

    return 0;
}