gipu/cpp/emulator.cpp

31 lines
688 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 bytecode_if;
std::streamsize bytecode_size;
2017-05-15 11:49:11 +01:00
uint8_t * bytecode;
if (argc < 3) {
printf("Usage: %s <opcodes_key> <program>\n", argv[0]);
2017-05-15 11:49:11 +01:00
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);
2017-05-15 11:49:11 +01:00
bytecode = new uint8_t[bytecode_size];
bytecode_if.read((char*)bytecode, bytecode_size);
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
vm.status();
return 0;
2017-05-13 18:36:46 +01:00
}