vm read_vm(int task_id) { unsigned i, top, func_id, max; int vector; char c; vm the_vm; if (dbio_scanf("%u %d %u%c", &top, &vector, &func_id, &c) != 4 || (c == ' ' ? dbio_scanf("%u%c", &max, &c) != 2 || c != '\n' : (max = DEFAULT_MAX_STACK_DEPTH, c != '\n'))) { errlog("READ_VM: Bad vm header\n"); return 0; } the_vm = new_vm(task_id, top + 1); the_vm->max_stack_size = max; the_vm->top_activ_stack = top; the_vm->root_activ_vector = vector; the_vm->func_id = func_id; for (i = 0; i <= top; i++) if (!read_activ(&the_vm->activ_stack[i], i == 0 ? vector : MAIN_VECTOR)) { errlog("READ_VM: Bad activ number %d\n", i); return 0; } return the_vm; }
int main(int ac, char **av) { unsigned char board[MEM_SIZE]; t_vm *vm; t_dlist *list; t_dlist *list_s; if (ac < 2) return (0); list = NULL; list_s = NULL; list = new_list(list); list_s = new_list(list_s); init_board(board); vm = NULL; vm = new_vm(vm); fill_list(list, av); check_debug(list, vm); syntax(list); find_dump(list, vm); find_champ(list, vm, board, 0); id_champ(vm); champ_id_reg(vm); init_alive(vm); start_vm(vm, board); winning(vm); return (0); }
int main() { unsigned int initial_values[4] = { 0, 0, 500, 600 }; URMVM *vm = new_vm(); URMProgram *program = preconfigure_program_loop((unsigned int*)&initial_values, 4, 1); unsigned int results = 0; unsigned int *result_registers = NULL; FILE *file = fopen("misc/program.txt", "r"); if(file == NULL) { printf("Unable to open file!\n"); } parse(program, file); #if 0 unsigned int i = 0; for(; i < program->instructions; ++i) { printf("instruction %u: %d\n", i, program->instruction_list[i]->instruction); unsigned int j = 0; for(; j < program->instruction_list[i]->args; ++j) { printf("arg %u: %d\n", j, program->instruction_list[i]->arg_list[j]); } } for(i = 0; i < program->errors; ++i) { printf("error: %s\n", program->error_list[i]); } #endif if(start_program(vm, program, &result_registers, &results)) { printf("Results:\n"); int i = 0; for(; i < results; ++i) { printf ("Register %u, result %u\n", i, result_registers[i]); } } else { printf("Error in execution!\n"); } fclose(file); free(result_registers); free_program(program); free(program); free_vm(vm); free(vm); return 0; }
int main(int argc, char *argv[]) { FILE *file; if (argc < 2) { fprintf(stderr, "Feed me something."); return 1; } file = fopen(argv[1], "r"); if(!file) { fprintf(stderr, "Feed me something GOOD."); return 1; } rewind(file); new_vm(file); return 0; }
void test_create() { Thread* thr = Thread::create(state, new_vm(), G(thread), 0); TS_ASSERT_DIFFERS(thr, Thread::current(state)); }