-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
47 lines (41 loc) · 1.13 KB
/
Main.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "lib/BasicIInterpreter.hpp"
int main()
{
using namespace hsd::string_view_literals;
hasm::basic_iinterpreter interpreter = "TestInter.hasm"_sv;
interpreter.add_extern_func(
"malloc"_sv, [](hsd::vector<hsd::u64>& args)
{
hasm::call(
[&](hsd::u64 arg)
{
args.push_back(reinterpret_cast<hsd::u64>(malloc(arg)));
}, args
);
}
);
interpreter.add_extern_func(
"free"_sv, [](hsd::vector<hsd::u64>& args)
{
hasm::call(
[](hsd::u64 arg)
{
free(reinterpret_cast<void*>(arg));
}, args
);
}
);
interpreter.add_extern_func(
"printlnf"_sv, [](hsd::vector<hsd::u64>& args)
{
hasm::call([](hsd::f64 arg) { hsd_println("{}", arg); }, args);
}
);
interpreter.add_extern_func(
"printlni"_sv, [](hsd::vector<hsd::u64>& args)
{
hasm::call([](hsd::u64 arg) { printf("%#0x\n", arg); }, args);
}
);
interpreter.run();
}