static void treat_asm(t_cmd *line, char *header[2], t_cmd *asms[3], int *pos) { int i; if (line->cmd_code == T_LABEL) { list_replace_node(asms, &asms[2], line); line->bin_size = *pos; } else if (line->cmd_code == T_NAME || line->cmd_code == T_COMMENT) header[line->cmd_code + 3] = line->arg.argv[0]; else { line->bin_size = -1; line->bin[++(line->bin_size)] = line->cmd_code; if (line->cmd_code != T_REG && line->cmd_code != 9 && line->cmd_code != 12 && line->cmd_code != 15) fill_arg_type(line, &(line->bin_size)); i = -1; while (++i < MAX_ARGS_NUMBER && line->arg.type[i] != 0) fill_arg(line, &(line->bin_size), my_getnbr(line->arg.argv[i]), get_arg_size(line->cmd_code, i, line->arg.type[i])); *pos += line->bin_size + 1; } }
int get_inst_size(char **args, t_instruct *current) { int i; int size; t_op *tab; if (args == NULL) return (0); size = 1; if ((tab = return_op_tab(current->instruction))) size += tab->o_cod; i = 0; while (args[i]) { size += get_arg_size(args[i], tab); i++; } return (size); }
static void labels_loop(t_cmd *line, t_cmd *lbls, int i[3], int *lsize) { t_cmd *it; while (++i[0] < 4 && line->arg.type[*i] != 0) { i[1] = get_arg_size(line->cmd_code, *i, line->arg.type[*i]); if (line->arg.type[*i] == T_LAB || line->arg.argv[*i][0] == LABEL_CHAR) { it = lbls; while (it && my_strcmp(line->arg.argv[*i] + 1, it->arg.argv[0])) it = it->next; if (it) fill_arg(line, lsize, it->bin_size - i[2], i[1]); else syntax_prompt("Label undifined", line->line, *i, TRUE); } else *lsize += i[1]; } }