Ajout du PRIC
This commit is contained in:
parent
9e9dd66c3a
commit
084df49373
4 changed files with 10 additions and 6 deletions
|
|
@ -34,6 +34,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; }
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
%token tAFC tCPY
|
%token tAFC tCPY
|
||||||
%token tLOAD tSTORE tLOADI tSTOREI tSTOREA
|
%token tLOAD tSTORE tLOADI tSTOREI tSTOREA
|
||||||
%token tJMP tJMZ
|
%token tJMP tJMZ
|
||||||
%token tGET tPRI
|
%token tGET tPRI tPRIC
|
||||||
%token tCALL tRET
|
%token tCALL tRET
|
||||||
%token tSTOP
|
%token tSTOP
|
||||||
%token<nombre> tNB
|
%token<nombre> tNB
|
||||||
|
|
@ -59,6 +59,8 @@ Instruction : tJMZ tNB {add_instruction(JMZ, $2, 0, 0);};
|
||||||
Instruction : tGET tNB {add_instruction(GET, $2, 0, 0);};
|
Instruction : tGET tNB {add_instruction(GET, $2, 0, 0);};
|
||||||
// PRI @
|
// PRI @
|
||||||
Instruction : tPRI tNB {add_instruction(PRI, $2, 0, 0);};
|
Instruction : tPRI tNB {add_instruction(PRI, $2, 0, 0);};
|
||||||
|
// PRIC @
|
||||||
|
Instruction : tPRIC tNB {add_instruction(PRIC, $2, 0, 0);};
|
||||||
|
|
||||||
// CALL Ins Val
|
// CALL Ins Val
|
||||||
Instruction : tCALL tNB tNB {add_instruction(CALL, $2, $3, 0);};
|
Instruction : tCALL tNB tNB {add_instruction(CALL, $2, $3, 0);};
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define TAILLE_BUFFER_INSTRUCTIONS (1024)
|
#define TAILLE_BUFFER_INSTRUCTIONS (1024)
|
||||||
#define TAILLE_MEMOIRE (32)
|
#define TAILLE_MEMOIRE (64)
|
||||||
#define TAILLE_PILE_APPELS (16)
|
#define TAILLE_PILE_APPELS (4)
|
||||||
#define TAILLE_BANC_REGISTRES (16)
|
#define TAILLE_BANC_REGISTRES (16)
|
||||||
|
|
||||||
#define SECURISED (1)
|
#define SECURISED (1)
|
||||||
|
|
@ -220,10 +220,11 @@ void execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (programme[eip].instruction == GET) {
|
} else if (programme[eip].instruction == GET) {
|
||||||
printf("Veuillez saisir un nombre : \n");
|
|
||||||
scanf("%d", &(registres[check_registre(programme[eip].param1)]));
|
scanf("%d", &(registres[check_registre(programme[eip].param1)]));
|
||||||
} else if (programme[eip].instruction == PRI) {
|
} else if (programme[eip].instruction == PRI) {
|
||||||
printf("%d@%d\n", registres[check_registre(programme[eip].param1)], programme[eip].param1);
|
printf("%d", registres[check_registre(programme[eip].param1)]);
|
||||||
|
} else if (programme[eip].instruction == PRIC) {
|
||||||
|
printf("%c", registres[check_registre(programme[eip].param1)]);
|
||||||
|
|
||||||
} else if (programme[eip].instruction == CALL) {
|
} else if (programme[eip].instruction == CALL) {
|
||||||
if (SECURISED) {
|
if (SECURISED) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
// Enum of the instruction
|
// Enum of the instruction
|
||||||
enum instruction_t {ADD, MUL, SUB, DIV, INF, SUP, EQU, CPY, AFC, LOAD, STORE, LOADI, STOREI, STOREA, JMP, JMZ, PRI, GET, CALL, RET, STOP};
|
enum instruction_t {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 instruction
|
// Add a new 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