#include "asm_instructions.h" void init_instruction_table(InstructionTable *table) { table->index = 0; } int add_instruction(InstructionTable *table, Instruction instruction, int arg1, int arg2, int arg3) { if (table->index >= INSTRUCTION_TABLE_SIZE) { return -1; } InstructionItem newItem; newItem.instruction = instruction; newItem.arg1 = arg1; newItem.arg2 = arg2; newItem.arg3 = arg3; table->table[table->index] = newItem; table->index++; return 0; } void write_instruction_table(InstructionTable *table, FILE *file) { for (int i = 0; i < table->index; i++) { write_instruction(&table->table[i], file); } } void write_instruction(InstructionItem *item, FILE *file) { fprintf(file, "%s %d %d %d", instructions_labels[item->instruction], item->arg1, item->arg2, item->arg3); }