Ajout du PRIC

This commit is contained in:
Faure Paul 2021-07-16 16:04:28 +02:00
parent 9e9dd66c3a
commit 084df49373
4 changed files with 10 additions and 6 deletions

View file

@ -34,6 +34,7 @@ yyerror (char const *s)
"GET" { return tGET; }
"PRI" { return tPRI; }
"PRIC" { return tPRIC; }
"CALL" { return tCALL; }
"RET" { return tRET; }

View file

@ -11,7 +11,7 @@
%token tAFC tCPY
%token tLOAD tSTORE tLOADI tSTOREI tSTOREA
%token tJMP tJMZ
%token tGET tPRI
%token tGET tPRI tPRIC
%token tCALL tRET
%token tSTOP
%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);};
// PRI @
Instruction : tPRI tNB {add_instruction(PRI, $2, 0, 0);};
// PRIC @
Instruction : tPRIC tNB {add_instruction(PRIC, $2, 0, 0);};
// CALL Ins Val
Instruction : tCALL tNB tNB {add_instruction(CALL, $2, $3, 0);};

View file

@ -3,8 +3,8 @@
#include <stdlib.h>
#define TAILLE_BUFFER_INSTRUCTIONS (1024)
#define TAILLE_MEMOIRE (32)
#define TAILLE_PILE_APPELS (16)
#define TAILLE_MEMOIRE (64)
#define TAILLE_PILE_APPELS (4)
#define TAILLE_BANC_REGISTRES (16)
#define SECURISED (1)
@ -220,10 +220,11 @@ void execute() {
}
} else if (programme[eip].instruction == GET) {
printf("Veuillez saisir un nombre : \n");
scanf("%d", &(registres[check_registre(programme[eip].param1)]));
} 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) {
if (SECURISED) {

View file

@ -3,7 +3,7 @@
// 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
void add_instruction(enum instruction_t inst, int param1, int param2, int param3);