Implement 32 bit MIPS16 instructions listed in m16.igen.
[deliverable/binutils-gdb.git] / sim / tic80 / interp.c
index 5845e068d12d0bd6e54d89df669caf560b31bfbc..17f06d486c2b11d579a11c3999950200de1870fc 100644 (file)
 #include "sim-main.h"
 
 #include "idecode.h"
+#include "itable.h"
 
-#include <signal.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
 
-void
-engine_init (SIM_DESC sd)
-{
-  memset (&STATE_CPU (sd, 0)->reg, 0, sizeof STATE_CPU (sd, 0)->reg);
-  memset (&STATE_CPU (sd, 0)->cia, 0, sizeof STATE_CPU (sd, 0)->cia);
-  CPU_STATE (STATE_CPU (sd, 0)) = sd;
-}
 
-
-/* Mechanisms for stopping/restarting the simulation */
+#if 0
 
 void
 engine_error (SIM_DESC sd,
+             sim_cpu *cpu,
              instruction_address cia,
              const char *fmt,
              ...)
@@ -49,17 +49,12 @@ engine_error (SIM_DESC sd,
   sim_io_evprintf (sd, fmt, ap);
   va_end (ap);
 
-  if (sd->halt_ok)
-    {
-      sim_io_printf (sd, "\n");
-      engine_halt (sd, cia, sim_signalled, SIGABRT);
-    }
-  else
-    sim_io_error (sd, " - aborting simulation");
+  sim_halt (sd, cpu, NULL, cia, sim_stopped, SIGABRT);
 }
 
 void
 engine_halt (SIM_DESC sd,
+            sim_cpu *cpu,
             instruction_address cia,
             enum sim_stop reason,
             int siggnal)
@@ -70,18 +65,20 @@ engine_halt (SIM_DESC sd,
   sd->siggnal = siggnal;
   sd->halt_ok = 0;
   sd->restart_ok = 0;
-  sd->cpu.cia = cia;
+  if (cpu != NULL)
+    cpu->cia = cia;
   longjmp (sd->path_to_halt, 1);
 }
 
 void
 engine_restart (SIM_DESC sd,
+               sim_cpu *cpu,
                instruction_address cia)
 {
   if (!sd->restart_ok)
     sim_io_error (sd, "engine_restart - bad longjmp");
   sd->restart_ok = 0;
-  sd->cpu.cia = cia;
+  cpu->cia = cia;
   longjmp(sd->path_to_restart, 1);
 }
 
@@ -93,25 +90,38 @@ engine_run_until_stop (SIM_DESC sd,
   if (!setjmp (sd->path_to_halt))
     {
       instruction_address cia;
+      sim_cpu *cpu = STATE_CPU (sd, 0);
       sd->halt_ok = 1;
       setjmp (sd->path_to_restart);
       sd->restart_ok = 1;
-      cia = STATE_CPU (sd, 0)->cia;
+      cia = cpu->cia;
       do
        {
-         if (cia.ip == -1)
-           {
-             /* anulled instruction */
-             cia.ip = cia.dp;
-             cia.dp = cia.dp + sizeof (instruction_word);
-           }
-         else
-           {
-             instruction_word insn = IMEM (cia.ip);
-             cia = idecode_issue (sd, insn, cia);
-           }
+         instruction_word insn = IMEM (cia);
+         cia = idecode_issue (sd, insn, cia);
        }
       while (*keep_running);
-      engine_halt (sd, cia, sim_stopped, SIGINT);
+      engine_halt (sd, cpu, cia, sim_stopped, SIM_SIGINT);
     }
 }
+
+
+void
+engine_step (SIM_DESC sd)
+{
+  if (!setjmp (sd->path_to_halt))
+    {
+      instruction_address cia;
+      instruction_word insn;
+      sim_cpu *cpu = STATE_CPU (sd, 0);
+      sd->halt_ok = 1;
+      setjmp (sd->path_to_restart);
+      sd->restart_ok = 1;
+      cia = cpu->cia;
+      insn = IMEM (cia);
+      cia = idecode_issue (sd, insn, cia);
+      engine_halt (sd, cpu, cia, sim_stopped, SIM_SIGTRAP);
+    }
+}
+
+#endif
This page took 0.023788 seconds and 4 git commands to generate.