gipu/cpp/emulator.cpp

32 lines
577 B
C++
Raw Normal View History

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[]) {
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);
2017-05-13 18:36:46 +01:00
2017-05-14 22:01:11 +01:00
VM vm(bytecode, sizeof(bytecode));
2017-05-14 21:10:58 +01:00
vm.run();
2017-05-14 13:06:17 +01:00
vm.status();
return 0;
2017-05-13 18:36:46 +01:00
}