From 7a31dae61cabad2e6e237948b7b88e4d795dbb1a Mon Sep 17 00:00:00 2001 From: biouman <> Date: Mon, 16 Apr 2001 19:25:40 +0000 Subject: *** empty log message *** --- lib/simulator.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/simulator.c b/lib/simulator.c index 7dde434..633085f 100644 --- a/lib/simulator.c +++ b/lib/simulator.c @@ -13,7 +13,7 @@ #include "memoire.h" #include "fpu.h" #include "exceptions.h" - +#include "linker.h" /* initialisation de la MP avec un malloc @@ -24,6 +24,9 @@ int HasToRun = 1, HasToReset; +Uint32 base_addr = 0; + + Uint32 LireInstruction(void) { return (LD(LireRegistrePC())); @@ -65,7 +68,8 @@ void Initialisation(void) for (i = 0; i < TAILLE_MEMOIRE; i++) Reset(&memoire_principale[i]); - EcrireRegistreSP(ADD_SP); + InitRegistres(); /* initialisation des registres */ + EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */ } void DecodeExec(Uint32 instruction, Uint32 entrypoint) @@ -384,3 +388,57 @@ void Debogueur(void) { AfficheReg(); } + +void ChargeBinaire(char * filename) +{ +FILE * file; +char message[BUFSIZ]; +Uint32 entrypoint, nb, ns, nbss, nr; +Uint32 * relocation_table; +i int; + +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