le compilateur super performant
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

asm_instructions.c 855B

123456789101112131415161718192021222324252627282930
  1. #include "asm_instructions.h"
  2. void init_instruction_table(InstructionTable *table) {
  3. table->index = 0;
  4. }
  5. int add_instruction(InstructionTable *table, Instruction instruction, int arg1, int arg2, int arg3) {
  6. if (table->index >= INSTRUCTION_TABLE_SIZE) {
  7. return -1;
  8. }
  9. InstructionItem newItem;
  10. newItem.instruction = instruction;
  11. newItem.arg1 = arg1;
  12. newItem.arg2 = arg2;
  13. newItem.arg3 = arg3;
  14. table->table[table->index] = newItem;
  15. table->index++;
  16. return 0;
  17. }
  18. void write_instruction_table(InstructionTable *table, FILE *file) {
  19. for (int i = 0; i < table->index; i++) {
  20. write_instruction(&table->table[i], file);
  21. }
  22. }
  23. void write_instruction(InstructionItem *item, FILE *file) {
  24. fprintf(file, "%s %d %d %d", instructions_labels[item->instruction], item->arg1, item->arg2, item->arg3);
  25. }