/* ---------------------------------------- | Adresse | Registre | Modifié | ---------------------------------------- | | | | | | | | | | | | | i | 0x777756b8 | int | | size | 0x777756b8 | int | ---------------------------------------- */ #include "tables.h" #define NB_REG 4 #define MEM_SIZE 16 #define NB_INSTRUCTIONS 128 #define MEM_INST_SIZE 128 #define NB_BITS_INSTRUCTION 5 #define NB_BITS 8 int traduction_JMP[NB_INSTRUCTIONS]; struct str_instruction { enum instruction_t instruction; int param1; int param2; int param3; }; int last_instruction = 0; struct str_instruction buffer[3*NB_INSTRUCTIONS]; void add_instruction(enum instruction_t inst, int param1, int param2, int param3) { struct str_instruction my_instruction = {inst, param1, param2, param3}; buffer[last_instruction] = my_instruction; last_instruction++; } void write_asm(FILE * file) { int i = 0; while (i=0; i--) { buff[N-1-i] = tampon[i]; } buff[N] = '\0'; } void write_instruction_binary(FILE * file, struct str_instruction instr) { char buff1[33]; char buff2[33]; char buff3[33]; char buff4[33]; convert_to_binary_on_N(instr.instruction, NB_BITS_INSTRUCTION, buff1); if (instr.instruction == JMP || instr.instruction == JMZ || instr.instruction == CALL) { convert_to_binary_on_N(traduction_JMP[instr.param1], NB_BITS, buff2); } else { convert_to_binary_on_N(instr.param1, NB_BITS, buff2); } convert_to_binary_on_N(instr.param2, NB_BITS, buff3); convert_to_binary_on_N(instr.param3, NB_BITS, buff4); fprintf(file, "\"%s%s%s%s\" & ", buff1, buff2, buff3, buff4); } void write_code_machine(FILE * file) { int i = MEM_INST_SIZE - 1; while (i>=0) { write_instruction_binary(file, buffer[i]); i--; } } struct case_adresse { int adresse; int registre; char modifie; }; struct case_adresse tableau[MEM_SIZE]; int registres[NB_REG]; void init (void) { int i; struct case_adresse case_courante = {0, -1, 0}; for (i=0; i