From 95409eb5bff39457f161a6b93c2024d2fe8a90d1 Mon Sep 17 00:00:00 2001 From: pfaure Date: Fri, 18 Jun 2021 14:05:19 +0200 Subject: [PATCH] =?UTF-8?q?Interpreteur=20non=20s=C3=A9curis=C3=A9=20termi?= =?UTF-8?q?n=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lex_Yacc/as.y | 9 ++++++++- Tables/tables.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Lex_Yacc/as.y b/Lex_Yacc/as.y index 6f9f51c..290fb93 100644 --- a/Lex_Yacc/as.y +++ b/Lex_Yacc/as.y @@ -4,6 +4,7 @@ %{ #include "../Tables/tables.h" +#include %} %token tMUL tDIV tADD tSUB tINF tSUP tEQU @@ -65,7 +66,13 @@ Instruction : tSTOP tNB {add_instruction(STOP, $2, 0, 0);}; %% -int main(void) { +int main(int argc, char * argv[]) { + if (argc != 2) { + printf("Specifiez le fichier à interpreter"); + exit(2); + } + extern FILE * yyin; + yyin = fopen(argv[1], "r"); yyparse(); execute(); return 0; diff --git a/Tables/tables.c b/Tables/tables.c index a5cf97d..6a6c98a 100644 --- a/Tables/tables.c +++ b/Tables/tables.c @@ -181,8 +181,10 @@ void execute() { eip = programme[eip].param1 - 1; } else if (programme[eip].instruction == RET) { + int lastebp = ebp; eip = mem[check_adresse(ebp - 1)] - 1; ebp = mem[check_adresse(ebp - 2)]; + mem[check_adresse(lastebp - 2)] = mem[check_adresse(lastebp)]; } else if (programme[eip].instruction == STOP) { if (programme[eip].param1 == 0) {