No Description
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.

tables.h 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef TABLE_H
  2. #define TABLE_H
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. // Initialise all : the addresses-registers association table, the registers priority table, the instructions buffer, the instruction address association table
  6. void init(void);
  7. /**************************************************/
  8. /**************************************************/
  9. /************** Registers Management **************/
  10. /**************************************************/
  11. /**************************************************/
  12. // Print the addresses-registers association table
  13. void print();
  14. // Increment the input instruction counter
  15. void increment_time();
  16. /* Ask for a register to read the value
  17. @param :
  18. - adresse : The address of value wanted
  19. - added_instruction : Address of an int storing the number of added_instructions
  20. @return : The number of the register corresponding to the given address
  21. */
  22. int get_reg_read(int adresse, int * added_instruction);
  23. /* Ask for a register to write the value
  24. @param :
  25. - adresse : The address of value (if -1 return a free register without associating it to any address)
  26. - added_instruction : Address of an int storing the number of added_instructions
  27. @return : The number of the register corresponding to the given address
  28. WARNING : The value of the address will not be LOADED in the register
  29. Always ask READ registers before the WRITE register
  30. */
  31. int get_reg_write(int adresse, int * added_instruction);
  32. // Broke the association between adresse and its corresponding register
  33. void unlink(int adresse);
  34. // Store used register, init the association table between addresses and registers
  35. int flush_and_init();
  36. /**************************************************/
  37. /**************************************************/
  38. /************** Instructions Writing **************/
  39. /**************************************************/
  40. /**************************************************/
  41. // Enum of the register oriented instruction (warning order correspond to the binary code)
  42. enum instruction_t {NOP, ADD, MUL, SUB, DIV, INF, SUP, EQU, CPY, AFC, LOAD, STORE, LOADI, STOREI, STOREA, JMP, JMZ, PRI, PRIC, GET, CALL, RET, STOP};
  43. // Add a new Registers oriented instruction
  44. void add_instruction(enum instruction_t inst, int param1, int param2, int param3);
  45. // Specifie the number of Register oriented instructions corresponding to the memory oriented instruction
  46. void new_instruction(int nb_inst);
  47. // Write the new assembly in the given file
  48. void write_asm(FILE * file);
  49. // Write the binary code in the given file
  50. void write_code_machine(FILE * file, char compact);
  51. #endif