From 23531b1004c816827bdb48bf4f7f996fd9d351b5 Mon Sep 17 00:00:00 2001 From: Pixel <> Date: Mon, 16 Apr 2001 19:48:46 +0000 Subject: Simulator --- lib/simulator.c | 60 ++++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 35 deletions(-) (limited to 'lib') 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); } -- cgit v1.2.3