summaryrefslogtreecommitdiff
path: root/lib/simulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/simulator.c')
-rw-r--r--lib/simulator.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/lib/simulator.c b/lib/simulator.c
index 247a8c4..d542a07 100644
--- a/lib/simulator.c
+++ b/lib/simulator.c
@@ -14,19 +14,12 @@
#include "fpu.h"
#include "exceptions.h"
#include "linker.h"
+#include "terminal.h"
-/*
- initialisation de la MP avec un malloc
- fermeture du prog et free
- catch du ctrl-c
- */
-
-
-int HasToRun = 1, HasToReset;
+int HasToRun = 1, HasToReset = 0, debug = 0;
Uint32 base_addr = 0;
-
Uint32 LireInstruction(void)
{
return (LD(LireRegistrePC()));
@@ -373,22 +366,45 @@ void AfficheReg(void) // affiche reg
for (i = 0; i <= 3; i++) {
for (j = 1; j <= 8; j++) {
- printf(" R%02d ", (i * 8 + j));
+ fprintf(stderr, " R%02d ", (i * 8 + j));
}
- printf("\n");
+ fprintf(stderr, "\n");
for (j = 1; j <= 8; j++) {
- printf("%08lX ", (registre[i * 8 + j - 1]));
+ fprintf(stderr, "%08lX ", (registre[i * 8 + j - 1]));
}
- printf("\n");
+ fprintf(stderr, "\n");
}
- printf("Rg: %08lX | Rd: %08lX | Flag: %08lX | PC: %08lX\n", LireRegistreRG(), LireRegistreRD(),
+ fprintf(stderr, "Rg: %08lX | Rd: %08lX | Flag: %08lX | PC: %08lX\n\n", LireRegistreRG(), LireRegistreRD(),
LireRegistreFLAG(), registre[REG_PC]);
- printf("\n");
}
void Debogueur(void)
{
- AfficheReg();
+ int out = 0;
+
+ while (!out) {
+ AfficheReg();
+ printf("%08lX:%08lX > ", LireRegistrePC(), LD(LireRegistrePC()));
+
+ switch (fgetc(input)) {
+ case 'G':
+ case 'g':
+ fprintf(stderr, "Go\n")
+ debug = 0;
+ out = 1;
+ break;
+ case 'p':
+ case 'P':
+ fprintf(stderr, "Proceed\n");
+ out = 1;
+ break;
+ case 'R':
+ case 'r':
+ break;
+ default:
+ fprintf(stderr, _("Help:\nG: go\nP: Proceed\nR: display registers\n\n");
+ }
+ }
}
void ChargeBinaire(char *filename)