12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef TABLE_H
- #define TABLE_H
-
- #include <stdint.h>
- #include <stdio.h>
-
-
- // Initialise all : the addresses-registers association table, the registers priority table, the instructions buffer, the instruction address association table
- void init(void);
-
-
-
-
- /**************************************************/
- /**************************************************/
- /************** Registers Management **************/
- /**************************************************/
- /**************************************************/
-
- // Print the addresses-registers association table
- void print();
-
- // Increment the input instruction counter
- void increment_time();
-
- /* Ask for a register to read the value
-
- @param :
- - adresse : The address of value wanted
- - added_instruction : Address of an int storing the number of added_instructions
- @return : The number of the register corresponding to the given address
- */
- int get_reg_read(int adresse, int * added_instruction);
-
- /* Ask for a register to write the value
-
- @param :
- - adresse : The address of value (if -1 return a free register without associating it to any address)
- - added_instruction : Address of an int storing the number of added_instructions
- @return : The number of the register corresponding to the given address
-
- WARNING : The value of the address will not be LOADED in the register
- Always ask READ registers before the WRITE register
- */
- int get_reg_write(int adresse, int * added_instruction);
-
- // Broke the association between adresse and its corresponding register
- void unlink(int adresse);
-
- // Store used register, init the association table between addresses and registers
- int flush_and_init();
-
-
-
-
-
- /**************************************************/
- /**************************************************/
- /************** Instructions Writing **************/
- /**************************************************/
- /**************************************************/
-
-
- // Enum of the register oriented instruction (warning order correspond to the binary code)
- 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};
-
- // Add a new Registers oriented instruction
- void add_instruction(enum instruction_t inst, int param1, int param2, int param3);
-
- // Specifie the number of Register oriented instructions corresponding to the memory oriented instruction
- void new_instruction(int nb_inst);
-
- // Write the new assembly in the given file
- void write_asm(FILE * file);
-
- // Write the binary code in the given file
- void write_code_machine(FILE * file, char compact);
-
- #endif
|