gipu/cpp/emulator.cpp
2017-05-15 12:49:11 +02:00

32 lines
577 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 f;
std::streamsize fsize;
uint8_t * bytecode;
if (argc < 2) {
printf("Usage: %s <program>\n", argv[0]);
return 1;
}
/*
reading bytecode
*/
f.open(argv[1], std::ios::binary | std::ios::ate);
fsize = f.tellg();
f.seekg(0, std::ios::beg);
bytecode = new uint8_t[fsize];
f.read((char*)bytecode, fsize);
VM vm(bytecode, sizeof(bytecode));
vm.run();
vm.status();
return 0;
}