Ara pilla el .BAS de la linea de comandos. Arreglada release version de Windows
This commit is contained in:
35
vm.cpp
35
vm.cpp
@@ -48,28 +48,33 @@ static void load_rom() {
|
||||
}
|
||||
|
||||
static void load_program(const char* filename) {
|
||||
FILE *f = fopen(filename, "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET); //same as rewind(f);
|
||||
char *program = (char*)malloc(fsize + 1);
|
||||
fread(program, fsize, 1, f);
|
||||
fclose(f);
|
||||
program[fsize] = 0;
|
||||
if (filename == nullptr) {
|
||||
error_raise("No file specified");
|
||||
} else {
|
||||
FILE *f = fopen(filename, "rb");
|
||||
if (f == nullptr) {
|
||||
error_raise("File not found");
|
||||
} else {
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET); //same as rewind(f);
|
||||
char *program = (char*)malloc(fsize + 1);
|
||||
fread(program, fsize, 1, f);
|
||||
fclose(f);
|
||||
program[fsize] = 0;
|
||||
|
||||
register_constants();
|
||||
register_constants();
|
||||
|
||||
parser_parse(program, mem);
|
||||
free(program);
|
||||
parser_parse(program, mem);
|
||||
free(program);
|
||||
}
|
||||
}
|
||||
|
||||
if (error_raised()) {
|
||||
vm_pc = 0xA000;
|
||||
//error_print(&mem[0xA000]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Compilation complete!\nProgram size: %d bytes\nMemory usage: %d bytes\n", parser_get_codesize(), parser_get_memory_usage());
|
||||
/*FILE *f = fopen("test.bin", "wb");
|
||||
if (f == nullptr) perror("Error");// printf("Error: %d (%s)\n", errno, strerror(errno));
|
||||
fwrite(rawCode, parser_get_codesize(), 1, f);
|
||||
fclose(f);*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user