Ajout chaines de caractère au CA
This commit is contained in:
parent
712e317901
commit
475fb8dbba
5 changed files with 31 additions and 21 deletions
|
@ -12,8 +12,8 @@ yyerror (char const *s)
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
"ADD" { return tADD ;}
|
"ADD" { return tADD; }
|
||||||
"SOU" { return tSUB;}
|
"SOU" { return tSUB; }
|
||||||
"MUL" { return tMUL; }
|
"MUL" { return tMUL; }
|
||||||
"DIV" { return tDIV; }
|
"DIV" { return tDIV; }
|
||||||
"INF" { return tINF; }
|
"INF" { return tINF; }
|
||||||
|
@ -33,6 +33,7 @@ yyerror (char const *s)
|
||||||
|
|
||||||
"GET" { return tGET; }
|
"GET" { return tGET; }
|
||||||
"PRI" { return tPRI; }
|
"PRI" { return tPRI; }
|
||||||
|
"PRIC" { return tPRIC; }
|
||||||
|
|
||||||
"CALL" { return tCALL; }
|
"CALL" { return tCALL; }
|
||||||
"RET" { return tRET; }
|
"RET" { return tRET; }
|
||||||
|
|
|
@ -14,7 +14,7 @@ FILE * file2;
|
||||||
%token tAFC tCPY tAFCA
|
%token tAFC tCPY tAFCA
|
||||||
%token tREAD tWR
|
%token tREAD tWR
|
||||||
%token tJMP tJMF
|
%token tJMP tJMF
|
||||||
%token tGET tPRI
|
%token tGET tPRI tPRIC
|
||||||
%token tCALL tRET
|
%token tCALL tRET
|
||||||
%token tSTOP
|
%token tSTOP
|
||||||
%token<nombre> tNB
|
%token<nombre> tNB
|
||||||
|
@ -184,6 +184,13 @@ Instruction : tPRI tNB {increment_time();
|
||||||
add_instruction(PRI, reg_src, 0, 0); // On traduit le PRI
|
add_instruction(PRI, reg_src, 0, 0); // On traduit le PRI
|
||||||
new_instruction(added_instruction + 1);}; // On déclare le nombre d'instruction ajoutées
|
new_instruction(added_instruction + 1);}; // On déclare le nombre d'instruction ajoutées
|
||||||
|
|
||||||
|
// PRIC @ -> PRIC Ri
|
||||||
|
Instruction : tPRIC tNB {increment_time(); // On incrémente le temps, c'est a dire, une instruction de plus a été traduite (pour la politique LRU)
|
||||||
|
int added_instruction = 0; // On initialise le compteur d'instruction ajoutées (pour la traduction des sauts
|
||||||
|
int reg_src = get_reg_read($2, &added_instruction); // On demande un registre en lecture pour sortir la valeur à afficher
|
||||||
|
add_instruction(PRIC, reg_src, 0, 0); // On traduit le PRIC
|
||||||
|
new_instruction(added_instruction + 1);}; // On déclare le nombre d'instruction ajoutées
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -29,7 +29,7 @@ clean_Outputs:
|
||||||
### COMPILATION ###
|
### COMPILATION ###
|
||||||
###########################
|
###########################
|
||||||
build : clean build_Tables build_Lex_Yacc
|
build : clean build_Tables build_Lex_Yacc
|
||||||
gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/tables.o -ll -o rondoudou_cross_assembleur
|
gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/tables.o -ly -o rondoudou_cross_assembleur
|
||||||
|
|
||||||
build_Tables: clean_Tables
|
build_Tables: clean_Tables
|
||||||
gcc -c Tables/tables.c -o Tables/tables.o
|
gcc -c Tables/tables.c -o Tables/tables.o
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "tables.h"
|
#include "tables.h"
|
||||||
#define NB_REG 16 // Nombre de registre dans le processeur
|
#define NB_REG 16 // Nombre de registre dans le processeur
|
||||||
#define MEM_SIZE 64 // Taille de la mémoire de données
|
#define MEM_SIZE 64 // Taille de la mémoire de données
|
||||||
#define MEM_INST_SIZE 256 // Taille de la mémoire d'instruction
|
#define MEM_INST_SIZE 512 // Taille de la mémoire d'instruction
|
||||||
#define NB_BITS_INSTRUCTION 5 // Nombres de bits codant une instruction
|
#define NB_BITS_INSTRUCTION 5 // Nombres de bits codant une instruction
|
||||||
#define NB_BITS 8 // Taille d'un mot du processeur
|
#define NB_BITS 16 // Taille d'un mot du processeur
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,6 +317,8 @@ void write_asm(FILE * file) {
|
||||||
fprintf(file, "GET %d\n", buffer[i].param1);
|
fprintf(file, "GET %d\n", buffer[i].param1);
|
||||||
} else if (buffer[i].instruction == PRI) {
|
} else if (buffer[i].instruction == PRI) {
|
||||||
fprintf(file, "PRI %d\n", buffer[i].param1);
|
fprintf(file, "PRI %d\n", buffer[i].param1);
|
||||||
|
} else if (buffer[i].instruction == PRIC) {
|
||||||
|
fprintf(file, "PRIC %d\n", buffer[i].param1);
|
||||||
|
|
||||||
} else if (buffer[i].instruction == CALL) {
|
} else if (buffer[i].instruction == CALL) {
|
||||||
fprintf(file, "CALL %d %d\n", traduction_JMP[buffer[i].param1], buffer[i].param2);
|
fprintf(file, "CALL %d %d\n", traduction_JMP[buffer[i].param1], buffer[i].param2);
|
||||||
|
|
|
@ -62,7 +62,7 @@ int flush_and_init();
|
||||||
|
|
||||||
|
|
||||||
// Enum of the register oriented instruction (warning order correspond to the binary code)
|
// 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, GET, CALL, RET, STOP};
|
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
|
// Add a new Registers oriented instruction
|
||||||
void add_instruction(enum instruction_t inst, int param1, int param2, int param3);
|
void add_instruction(enum instruction_t inst, int param1, int param2, int param3);
|
||||||
|
|
Loading…
Reference in a new issue