From ba6d5b2571acd4010c929901b490bcd836c4ca3c Mon Sep 17 00:00:00 2001 From: Pixel <> Date: Sun, 15 Apr 2001 02:21:56 +0000 Subject: Inclusion du simulateur. --- lib/Makefile.am | 6 +++-- lib/assembler.c | 71 ++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/lib/Makefile.am b/lib/Makefile.am index b463138..f6172b3 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,10 +2,12 @@ localedir = $(datadir)/locale DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ AM_CFLAGS = -O3 -Wall -Wstrict-prototypes $(CFLAGS) INCLUDES = -I. -I.. -I$(includedir) -I../include -lib_LTLIBRARIES = libCompilo.la +lib_LTLIBRARIES = libCompilo.la libSimul.la libCompilo_la_SOURCES = assembler.c parser.c meta.c numbers.c hash.c exceptions.c +libSimul_la_SOURCES = alu.c archi.c exceptions.c fpu.c interne.c memoire.c registre.c libCompilo_la_LDFLAGS = -version-info $(ProjetArchi_VERSION_INFO) +libSimul_la_LFDLAGS = -version-info $(ProjetArchi_VERSION_INFO) -EXTRA_DIST = instructions.txt \ No newline at end of file +EXTRA_DIST = instructions.txt diff --git a/lib/assembler.c b/lib/assembler.c index e727ce2..513a6be 100644 --- a/lib/assembler.c +++ b/lib/assembler.c @@ -1289,10 +1289,13 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) { metaexpr_t *m, *n; expression_t *t; + int tv; if (!e->pattern) { exception(1, _("Pattern not matching...")); } + + fprintf(stderr, "Evaluation de la pattern %s, index %i\n", e->pattern->name, e->index); m = e->pattern->expr[e->index]; @@ -1309,7 +1312,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) } } else { if (m->string) { - if (m->string != 'P') { + if (m->string[0] != 'P') { exception(1, _ ("Error in the metalanguage (pattern should be here if not a constant type)")); @@ -1319,8 +1322,8 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) t->e_type = t->e_subtype = E_VALUE; t->avalue = e->index; t->symbol = NULL; - InsererVarDansTab(it, CreerElement(m->name, t)) - free(t); + InsererVarDansTab(it, CreerElement(m->name, t)); + free(t); } } } @@ -1330,17 +1333,28 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) m = m->left; if (m->string) { if (m->type) { - if (!strcmp(m->name, "I")) { + if (strcmp(m->name, "I") || strcmp(m->string, "O")) { exception(1, _("Unknow constant type in the meta language")); } - if (e->child->e_subtype == E_VALUE) { - pushdword(e->avalue, NULL); - } else { - pushdword(0, e); + tv = 0; + if (e->child->next->e_subtype == E_VALUE) { + tv = e->child->next->avalue; + } + if ((e->child->next->e_subtype == E_OPERATION) + && (e->child->next->child->e_subtype == E_VALUE)) { + tv = e->child->next->child->avalue; } + pushdword(tv, e->child); + } else { + } + } + m = n; + m = m->right; + if (m->string) { + if (m->type) { } else { if (m->string) { - if (m->string != 'P') { + if (m->string[0] != 'P') { exception(1, _ ("Error in the metalanguage (pattern should be here if not a constant type)")); @@ -1348,28 +1362,27 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) t = (expression_t *) Emalloc(sizeof(expression_t)); t->next = t->child = t->prev = t->father = NULL; t->e_type = t->e_subtype = E_VALUE; - t->avalue = e->index; + if (e->child->next->e_subtype == E_PATTERN) { + t->avalue = e->child->next->index; + } else { + t->avalue = e->child->next->child->next->index; + } t->symbol = NULL; - InsererVarDansTab(it, CreerElement(m->name, t)) - free(t); + InsererVarDansTab(it, CreerElement(m->name, t)); + free(t); + } else { + exception(1, _("Logical error in meta language")); } } } - } else { + } else { /* Unaire */ m = m->right; if (m->string) { if (m->type) { - if (!strcmp(m->name, "I")) { - exception(1, _("Unknow constant type in the meta language")); - } - if (e->e_subtype == E_VALUE) { - pushdword(e->avalue, NULL); - } else { - pushdword(0, e); - } + exception(1, _("Logical error in meta language")); } else { if (m->string) { - if (m->string != 'P') { + if (m->string[0] != 'P') { exception(1, _ ("Error in the metalanguage (pattern should be here if not a constant type)")); @@ -1377,10 +1390,10 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) t = (expression_t *) Emalloc(sizeof(expression_t)); t->next = t->child = t->prev = t->father = NULL; t->e_type = t->e_subtype = E_VALUE; - t->avalue = e->index; + t->avalue = e->child->index; t->symbol = NULL; - InsererVarDansTab(it, CreerElement(m->name, t)) - free(t); + InsererVarDansTab(it, CreerElement(m->name, t)); + free(t); } } } @@ -1523,9 +1536,6 @@ void asm_eol(void) InsererVarDansTab(&it, CreerElement(instr->names[i], t)); free(t); evaluate_pattern(&it, e_current); - - - break; default: exception(1, _("Unknow constant type in the meta language")); @@ -1537,6 +1547,11 @@ void asm_eol(void) free_expr(e_current); e_current = e_line; } + + fprintf(stderr, "Variables explicites:\n"); + AfficheTableau(it); + + DetruitTab(&it); -- cgit v1.2.3