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.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef COMPILATOR_2000_ASM_INSTRUCTIONS_H
  2. #define COMPILATOR_2000_ASM_INSTRUCTIONS_H
  3. #include <stdio.h>
  4. #define INSTRUCTION_TABLE_SIZE 100
  5. typedef enum Instruction {
  6. ADD,
  7. MUL,
  8. SUO,
  9. DIV,
  10. COP,
  11. AFC,
  12. JMP,
  13. JMF,
  14. INF,
  15. SUP,
  16. EQU,
  17. PRI
  18. } Instruction;
  19. char* instructions_labels[12] = {
  20. "ADD",
  21. "MUL",
  22. "SUO",
  23. "DIV",
  24. "COP",
  25. "AFC",
  26. "JMP",
  27. "JMF",
  28. "INF",
  29. "SUP",
  30. "EQU",
  31. "PRI"
  32. };
  33. typedef struct InstructionItem {
  34. Instruction instruction;
  35. int arg1;
  36. int arg2;
  37. int arg3;
  38. } InstructionItem;
  39. typedef struct InstructionTable {
  40. InstructionItem table[INSTRUCTION_TABLE_SIZE];
  41. int index;
  42. } InstructionTable;
  43. void init_instruction_table(InstructionTable *table);
  44. int add_instruction(InstructionTable *table, Instruction instruction, int arg1, int arg2, int arg3);
  45. void write_instruction_table(InstructionTable *table, FILE *file);
  46. void write_instruction(InstructionItem *item, FILE *file);
  47. #endif //COMPILATOR_2000_ASM_INSTRUCTIONS_H