diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/simulator.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/simulator.c b/lib/simulator.c index 86fe1b4..1495687 100644 --- a/lib/simulator.c +++ b/lib/simulator.c @@ -68,7 +68,9 @@ void Initialisation(void) for (i = 0; i < TAILLE_MEMOIRE; i++) Reset(&memoire_principale[i]); - InitRegistres(); /* initialisation des registres */ + + EcrireRegistre(0, 0); + EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */ } @@ -393,17 +395,18 @@ void ChargeBinaire(char *filename) { FILE *file; char message[BUFSIZ]; - Uint32 entrypoint, nb, ns, nbss, nr; - Uint32 *relocation_table; + Uint32 entrypoint, nb, ns, nbss, nr, *relocation_table, entrypoint; int i; file = openfilereading(filename); if (readword(file) != 0x58454e4e) { /* verification de la signature */ exception(1, _("Signature invalid")); } - - sprintf(message, _("Total Size Of The Binary File: %d"), readword(file)); + + sprintf(message, _("Loading file %s"), filename); pushcontext(message); + + entrypoint = readword(file); /* point d'entrée */ nb = readword(file); /* taille du segment text */ ns = readword(file); /* taille des donnes statiques */ nbss = readword(file); /* taille des donnees non init */ @@ -424,11 +427,17 @@ void ChargeBinaire(char *filename) free(relocation_table); - InitRegistres(); /* initialisation des registres */ - EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */ - - EcrireRegistrePC(LireRegistrePC() + base_addr); /* maj de PC */ + entrypoint += base_addr; + + EcrireRegistre(28, base_addr + nb); + EcrireRegistre(30, base_addr + nb + ns + nbss); base_addr += nb + ns + nbss; fclose(file); + popcontext(); + sprintf(message, _("Executing file %s"), filename); + pushcontext(message); + Traitement(entrypoint); + popcontext(); + base_addr -= nb + ns + nbss; } |