summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPixel <>2001-04-16 19:48:46 +0000
committerPixel <>2001-04-16 19:48:46 +0000
commit23531b1004c816827bdb48bf4f7f996fd9d351b5 (patch)
tree43ff6caf9e684c713e971a3d773251f6bae3da96 /lib
parentec9c43fb3ffdfc7331f457b93b7f76e96b555e50 (diff)
Simulator
Diffstat (limited to 'lib')
-rw-r--r--lib/simulator.c60
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);
}