void ft_instructions_sti(t_dvm *vm, t_instructions inst, t_proc *proc) { int registre; int add; int address; if (ft_check_value_args(proc->args, &inst, vm, proc)) { registre = proc->args[0].value; if (ft_get_args(proc)) { log_inst(proc->player, proc->id, "STI"); if (proc->args[1].type == IND_CODE) proc->args[1].type %= IDX_MOD; add = (proc->args[1].value + proc->args[2].value); address = add % IDX_MOD + proc->pc % MEM_SIZE; ft_log_sti(vm, proc, registre); address = ft_convert_pc(address); address *= 2; ft_put_registre(vm->arene, proc->args[0].value, address % SIZE_CHAR_ARENE); ft_put_color_size(vm->color, vm->code_color[ABS(proc->player)], address / 2, 4); } } if ((proc->pc = (proc->pc_turfu / 2)) >= MEM_SIZE) proc->pc %= MEM_SIZE; }
static void ft_log_live(t_dvm *vm, t_proc *proc) { log_inst(proc->player, proc->id, "LIVE"); if (vm->options.operations) { if (proc->id < 10000) ft_printf("P%5d | live %d\n", proc->id, proc->args[0].value); else if (proc->id < 100000) ft_printf("P%6d | live %d\n", proc->id, proc->args[0].value); else ft_printf("P%7d | live %d\n", proc->id, proc->args[0].value); } }
static void ft_log_lld(t_dvm *vm, t_proc *proc, int registre) { log_inst(proc->player, proc->id, "LLD"); if (vm->options.operations) { if (proc->id < 10000) ft_printf("P%5d | lld %d r%d\n", proc->id, proc->args[0].value, registre); else if (proc->id < 100000) ft_printf("P%6d | lld %d r%d\n", proc->id, proc->args[0].value, registre); else ft_printf("P%7d | lld %d r%d\n", proc->id, proc->args[0].value, registre); } }
static void ft_log_fork(t_dvm *vm, t_proc *proc, int new_pc) { log_inst(proc->player, proc->id, "FORK"); if (vm->options.operations) { if (proc->id < 10000) ft_printf("P%5d | fork %d (%d)\n", proc->id, proc->args[0].value, new_pc); else if (proc->id < 100000) ft_printf("P%6d | fork %d (%d)\n", proc->id, proc->args[0].value, new_pc); else ft_printf("P%7d | fork %d (%d)\n", proc->id, proc->args[0].value, new_pc); } }
/* You should call this function if write_pass_one() or translate_inst() returns -1. INPUT_LINE is which line of the input file that the error occurred in. Note that the first line is line 1 and that empty lines are included in the count. */ static void raise_inst_error(uint32_t input_line, const char* name, char** args, int num_args) { write_to_log("Error - invalid instruction at line %d: ", input_line); log_inst(name, args, num_args); }