gipu/vm/emulator.cpp
2017-05-25 17:53:49 +02:00

30 lines
674 B
C++

#include "debug.h"
#include "vm.h"
#include <fstream>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
std::ifstream bytecode_if;
std::streamsize bytecode_size;
uint8_t *bytecode;
if (argc < 3) {
printf("Usage: %s <opcodes_key> <program>\n", argv[0]);
return 1;
}
/*
reading bytecode
*/
bytecode_if.open(argv[2], std::ios::binary | std::ios::ate);
bytecode_size = bytecode_if.tellg();
bytecode_if.seekg(0, std::ios::beg);
bytecode = new uint8_t[bytecode_size];
bytecode_if.read((char *)bytecode, bytecode_size);
VM vm((uint8_t *)argv[1], bytecode, bytecode_size);
vm.run();
return 0;
}