diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/simulator.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/lib/simulator.c b/lib/simulator.c index d00a528..4ac415c 100644 --- a/lib/simulator.c +++ b/lib/simulator.c @@ -398,47 +398,37 @@ void ChargeBinaire(char *filename) int i; file = openfilereading(filename); - if (readword(file) == 0x58454e4e) { /*verification de la signature */ - sprintf(message, _("Total Size Of The Binary File: %d"), readword(file)); - pushcontext(message); - nb = readword(file); /* taille du segment text */ - ns = readword(file); /* taille des donnes statiques */ - nbss = readword(file); /* taille des donnees non init */ - nr = readword(file); /* taille de la table de relogement */ - - relocation_table = Emalloc(nr); - for (i = 0; i < nr; i++) { - relocation_table[i] = readword(file); - } - - - for (i = base_addr; i < (base_addr + nb + ns); i++) { /*chargement en ram de .text et .data */ - ST(i, readword(file)); - } - - for (i = 0; i < nr; i++) { /* relogement */ - ST(base_addr + relocation_table[i], LD(base_addr + relocation_table[i]) + base_addr); - } - - free(relocation_table); - - InitRegistres(); /* initialisation des registres */ - EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */ - - EcrireRegistrePC(LireRegistrePC() + base_addr); /* maj de PC */ - - base_addr += nb + ns + nbss; - fclose(file); - - - - + if (readword(file) != 0x58454e4e) { /* verification de la signature */ + exception(1, _("Signature invalid")); + } + sprintf(message, _("Total Size Of The Binary File: %d"), readword(file)); + pushcontext(message); + nb = readword(file); /* taille du segment text */ + ns = readword(file); /* taille des donnes statiques */ + nbss = readword(file); /* taille des donnees non init */ + nr = readword(file); /* taille de la table de relogement */ + + relocation_table = Emalloc(nr); + for (i = 0; i < nr; i++) { + relocation_table[i] = readword(file); + } + for (i = base_addr; i < (base_addr + nb + ns); i++) { /*chargement en ram de .text et .data */ + ST(i, readword(file)); + } + for (i = 0; i < nr; i++) { /* relogement */ + ST(base_addr + relocation_table[i], LD(base_addr + relocation_table[i]) + base_addr); } + free(relocation_table); + InitRegistres(); /* initialisation des registres */ + EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */ + EcrireRegistrePC(LireRegistrePC() + base_addr); /* maj de PC */ + base_addr += nb + ns + nbss; + fclose(file); } |