Browse Source

Ajout chaines de caractère au CA

Faure Paul 2 years ago
parent
commit
475fb8dbba
5 changed files with 32 additions and 22 deletions
  1. 18
    17
      Lex_Yacc/al.lex
  2. 8
    1
      Lex_Yacc/as.y
  3. 1
    1
      Makefile
  4. 4
    2
      Tables/tables.c
  5. 1
    1
      Tables/tables.h

+ 18
- 17
Lex_Yacc/al.lex View File

@@ -12,32 +12,33 @@ yyerror (char const *s)
12 12
 
13 13
 %%
14 14
 
15
-"ADD"     { return tADD ;} 
16
-"SOU"     { return tSUB;}
17
-"MUL"     { return tMUL; }
18
-"DIV"			{ return tDIV; }
19
-"INF"			{ return tINF; }
20
-"SUP"     { return tSUP; }
21
-"EQU"     { return tEQU; }
22
-
23
-"AFC"    	{ return tAFC; }
24
-"COP"     { return tCPY; }
15
+"ADD"     { return tADD;  } 
16
+"SOU"     { return tSUB;  }
17
+"MUL"     { return tMUL;  }
18
+"DIV"			{ return tDIV;  }
19
+"INF"			{ return tINF;  }
20
+"SUP"     { return tSUP;  }
21
+"EQU"     { return tEQU;  }
22
+
23
+"AFC"    	{ return tAFC;  }
24
+"COP"     { return tCPY;  }
25 25
 "AFCA"    { return tAFCA; }
26 26
 
27 27
 
28 28
 "READ"    { return tREAD; }
29
-"WR"    { return tWR; }
29
+"WR"      { return tWR;   }
30 30
 
31
-"JMP"     { return tJMP; }
32
-"JMF"     { return tJMF; }
31
+"JMP"     { return tJMP;  }
32
+"JMF"     { return tJMF;  }
33 33
 
34
-"GET"     { return tGET; }
35
-"PRI"     { return tPRI; }
34
+"GET"     { return tGET;  }
35
+"PRI"     { return tPRI;  }
36
+"PRIC"    { return tPRIC; }
36 37
 
37 38
 "CALL"    { return tCALL; }
38
-"RET"     { return tRET; }
39
+"RET"     { return tRET;  }
39 40
 
40
-"STOP"     { return tSTOP; }
41
+"STOP"    { return tSTOP; }
41 42
 
42 43
 [0-9]+	  { yylval.nombre = atoi(yytext); return tNB; }
43 44
 

+ 8
- 1
Lex_Yacc/as.y View File

@@ -14,7 +14,7 @@ FILE * file2;
14 14
 %token tAFC tCPY tAFCA
15 15
 %token tREAD tWR
16 16
 %token tJMP tJMF
17
-%token tGET tPRI
17
+%token tGET tPRI tPRIC
18 18
 %token tCALL tRET
19 19
 %token tSTOP
20 20
 %token<nombre> tNB
@@ -184,6 +184,13 @@ Instruction : tPRI tNB         {increment_time();
184 184
 																add_instruction(PRI, reg_src, 0, 0);                  // On traduit le PRI
185 185
 																new_instruction(added_instruction + 1);};             // On déclare le nombre d'instruction ajoutées
186 186
 
187
+// PRIC @ -> PRIC Ri
188
+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)
189
+																int added_instruction = 0;                            // On initialise le compteur d'instruction ajoutées (pour la traduction des sauts
190
+																int reg_src = get_reg_read($2, &added_instruction);   // On demande un registre en lecture pour sortir la valeur à afficher
191
+																add_instruction(PRIC, reg_src, 0, 0);                 // On traduit le PRIC
192
+																new_instruction(added_instruction + 1);};             // On déclare le nombre d'instruction ajoutées
193
+
187 194
 
188 195
 
189 196
 

+ 1
- 1
Makefile View File

@@ -29,7 +29,7 @@ clean_Outputs:
29 29
 ###     COMPILATION     ###
30 30
 ###########################
31 31
 build : clean build_Tables build_Lex_Yacc
32
-	gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/tables.o -ll -o rondoudou_cross_assembleur
32
+	gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/tables.o -ly -o rondoudou_cross_assembleur
33 33
 
34 34
 build_Tables: clean_Tables
35 35
 	gcc -c Tables/tables.c -o Tables/tables.o

+ 4
- 2
Tables/tables.c View File

@@ -1,9 +1,9 @@
1 1
 #include "tables.h"
2 2
 #define NB_REG 16                // Nombre de registre dans le processeur
3 3
 #define MEM_SIZE 64             // Taille de la mémoire de données
4
-#define MEM_INST_SIZE 256       // Taille de la mémoire d'instruction
4
+#define MEM_INST_SIZE 512       // Taille de la mémoire d'instruction
5 5
 #define NB_BITS_INSTRUCTION 5   // Nombres de bits codant une instruction
6
-#define NB_BITS 8               // Taille d'un mot du processeur
6
+#define NB_BITS 16               // Taille d'un mot du processeur
7 7
 
8 8
 
9 9
 
@@ -317,6 +317,8 @@ void write_asm(FILE * file) {
317 317
 			fprintf(file, "GET %d\n", buffer[i].param1);
318 318
 		} else if (buffer[i].instruction == PRI) {
319 319
 			fprintf(file, "PRI %d\n", buffer[i].param1);
320
+    } else if (buffer[i].instruction == PRIC) {
321
+			fprintf(file, "PRIC %d\n", buffer[i].param1);
320 322
 
321 323
 		} else if (buffer[i].instruction == CALL) {
322 324
 			fprintf(file, "CALL %d %d\n", traduction_JMP[buffer[i].param1], buffer[i].param2);

+ 1
- 1
Tables/tables.h View File

@@ -62,7 +62,7 @@ int flush_and_init();
62 62
 
63 63
 
64 64
 // Enum of the register oriented instruction (warning order correspond to the binary code)
65
-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};
65
+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};
66 66
 
67 67
 // Add a new Registers oriented instruction
68 68
 void add_instruction(enum instruction_t inst, int param1, int param2, int param3);

Loading…
Cancel
Save