summaryrefslogtreecommitdiff
path: root/lib/simulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/simulator.c')
-rw-r--r--lib/simulator.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/simulator.c b/lib/simulator.c
index 16cc2ef..61c96d5 100644
--- a/lib/simulator.c
+++ b/lib/simulator.c
@@ -57,7 +57,7 @@ static Uint32 readword(FILE * f)
Uint32 Adresse(Uint32 u, Uint32 instruction)
{
Uint32 tmp;
-
+
switch (champ(u, 4)) {
case 0:
exception(1, _("Adresse: Call With Invalid r/m Field State ( r/m=00 )"));
@@ -82,12 +82,12 @@ Uint32 Adresse(Uint32 u, Uint32 instruction)
void Initialisation(void)
{
int i;
-
+
InitMemoire();
for (i = 0; i < TAILLE_MEMOIRE; i++)
Reset(&memoire_principale[i]);
-
+
EcrireRegistre(0, 0);
EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */
@@ -98,8 +98,8 @@ void DecodeExec(Uint32 instruction)
Uint32 champ_registre_resultat, val1, val2, resultat;
int test1, test2;
Uint32 val; /* valeur qui va etre stockée */
-
-
+
+
if (Opcode(instruction) & 0x80) {
fpu(Opcode(instruction));
} else {
@@ -238,7 +238,7 @@ void DecodeExec(Uint32 instruction)
IncrementeCompteurOrdinal();
}
}
- } else { /* mov arg2, arg1 */
+ } else { /* mov arg2, arg1 */
if (ValeurBit(Extension(instruction), 0) == 0) { /* arg2 = reg */
if (champ(Champ1(instruction), 2) == 0) { /* r/m de arg1 = 0 */
EcrireRegistre(Champ2(instruction), LireRegistre(Champ3(instruction)));
@@ -389,20 +389,22 @@ void AfficheReg(void) // affiche reg
fprintf(stderr, "\n");
}
fprintf(stderr, "Rg: %08lX | Rd: %08lX | Flag: %08lX | PC: %08lX\n", LireRegistreRG(), LireRegistreRD(),
- LireRegistreFLAG(), LireRegistrePC());
+ LireRegistreFLAG(), LireRegistrePC());
}
void Debogueur(void)
{
int out = 0;
-
+
Uint32 instruction = LireInstruction();
while (!out) {
AfficheReg();
- fprintf(stderr, "Opcode: %02X, extension: %02X, champ1: %02X, champ2: %02X, champ3: %02X\n", Opcode(instruction), Extension(instruction), Champ1(instruction), Champ2(instruction), Champ3(instruction));
+ fprintf(stderr, "Opcode: %02X, extension: %02X, champ1: %02X, champ2: %02X, champ3: %02X\n",
+ Opcode(instruction), Extension(instruction), Champ1(instruction), Champ2(instruction),
+ Champ3(instruction));
fprintf(stderr, "%08lX:%08lX > ", LireRegistrePC(), instruction);
-
+
switch (fgetc(input)) {
case 'G':
case 'g':
@@ -431,8 +433,6 @@ void Debogueur(void)
void Traitement(Uint32 entrypoint)
{ /* ******************** FIXMI ************************* */
Uint32 instruction;
-
- fprintf(stderr, "Entrypoint: %08lX\n", entrypoint);
while (HasToRun) {
EcrireRegistrePC(entrypoint);
@@ -462,14 +462,13 @@ void ChargeBinaire(char *filename)
if (readword(file) != 0x58454e4e) { /* verification de la signature */
exception(1, _("Invalid Signature"));
}
-
+
sprintf(message, _("Loading file %s"), filename);
pushcontext(message);
-
+
readword(file);
- entrypoint = readword(file); /* point d'entrée */
- fprintf(stderr, "Loaded entrypoint: %08lX", entrypoint);
+ 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 */
@@ -491,7 +490,7 @@ void ChargeBinaire(char *filename)
free(relocation_table);
entrypoint += base_addr;
-
+
EcrireRegistre(28, base_addr + nb);
EcrireRegistre(30, base_addr + nb + ns + nbss);
@@ -504,4 +503,3 @@ void ChargeBinaire(char *filename)
popcontext();
base_addr -= nb + ns + nbss;
}
-