2017-05-13 18:36:46 +01:00
|
|
|
#include "debug.h"
|
2017-05-14 13:06:17 +01:00
|
|
|
#include "vm.h"
|
|
|
|
#include <fstream>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2017-05-13 18:36:46 +01:00
|
|
|
|
2017-05-15 11:49:11 +01:00
|
|
|
int main(int argc, char *argv[]) {
|
2017-05-15 12:24:30 +01:00
|
|
|
std::ifstream bytecode_if;
|
|
|
|
std::streamsize bytecode_size;
|
2017-05-17 17:58:00 +01:00
|
|
|
uint8_t *bytecode;
|
2017-05-15 11:49:11 +01:00
|
|
|
|
2017-05-17 10:21:40 +01:00
|
|
|
if (argc < 3) {
|
|
|
|
printf("Usage: %s <opcodes_key> <program>\n", argv[0]);
|
2017-05-15 11:49:11 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
reading bytecode
|
|
|
|
*/
|
2017-05-17 10:21:40 +01:00
|
|
|
bytecode_if.open(argv[2], std::ios::binary | std::ios::ate);
|
2017-05-15 12:24:30 +01:00
|
|
|
bytecode_size = bytecode_if.tellg();
|
|
|
|
bytecode_if.seekg(0, std::ios::beg);
|
2017-05-15 11:49:11 +01:00
|
|
|
|
2017-05-15 12:24:30 +01:00
|
|
|
bytecode = new uint8_t[bytecode_size];
|
2017-05-17 17:58:00 +01:00
|
|
|
bytecode_if.read((char *)bytecode, bytecode_size);
|
2017-05-25 17:46:23 +01:00
|
|
|
printf("SIZE READ: %d\n", bytecode_size);
|
2017-05-17 17:58:00 +01:00
|
|
|
VM vm((uint8_t *)argv[1], bytecode, bytecode_size);
|
2017-05-14 21:10:58 +01:00
|
|
|
vm.run();
|
2017-05-14 13:06:17 +01:00
|
|
|
return 0;
|
2017-05-13 18:36:46 +01:00
|
|
|
}
|