For "msbu", subtract unsigned product from ACC,
[deliverable/binutils-gdb.git] / sim / d10v / interp.c
index 5eed2346d5190b0da6511d176f72fe59faa8a7df..76bb438a95098f41fa27d2b7749810f007886b07 100644 (file)
@@ -14,7 +14,6 @@ enum _leftright { LEFT_FIRST, RIGHT_FIRST };
 
 static char *myname;
 static SIM_OPEN_KIND sim_kind;
-static bfd_vma start_address;
 int d10v_debug;
 host_callback *d10v_callback;
 unsigned long ins_type_counters[ (int)INS_MAX ];
@@ -36,7 +35,6 @@ static void do_long PARAMS ((uint32 ins));
 static void do_2_short PARAMS ((uint16 ins1, uint16 ins2, enum _leftright leftright));
 static void do_parallel PARAMS ((uint16 ins1, uint16 ins2));
 static char *add_commas PARAMS ((char *buf, int sizeof_buf, unsigned long value));
-extern void sim_size PARAMS ((int power));
 static void init_system PARAMS ((void));
 extern void sim_set_profile PARAMS ((int n));
 extern void sim_set_profile_size PARAMS ((int n));
@@ -434,6 +432,16 @@ xfer_mem (addr, buffer, size, write)
 }
 
 
+static int
+sim_write_phys (sd, addr, buffer, size)
+     SIM_DESC sd;
+     SIM_ADDR addr;
+     unsigned char *buffer;
+     int size;
+{
+  return xfer_mem( addr, buffer, size, 1);
+}
+
 int
 sim_write (sd, addr, buffer, size)
      SIM_DESC sd;
@@ -441,6 +449,7 @@ sim_write (sd, addr, buffer, size)
      unsigned char *buffer;
      int size;
 {
+  /* FIXME: this should be performing a virtual transfer */
   return xfer_mem( addr, buffer, size, 1);
 }
 
@@ -451,13 +460,16 @@ sim_read (sd, addr, buffer, size)
      unsigned char *buffer;
      int size;
 {
+  /* FIXME: this should be performing a virtual transfer */
   return xfer_mem( addr, buffer, size, 0);
 }
 
 
 SIM_DESC
-sim_open (kind, argv)
+sim_open (kind, callback, abfd, argv)
      SIM_OPEN_KIND kind;
+     host_callback *callback;
+     struct _bfd *abfd;
      char **argv;
 {
   struct simops *s;
@@ -466,14 +478,11 @@ sim_open (kind, argv)
   char **p;
 
   sim_kind = kind;
+  d10v_callback = callback;
   myname = argv[0];
 
   for (p = argv + 1; *p; ++p)
     {
-      /* Ignore endian specification.  */
-      if (strcmp (*p, "-E") == 0)
-       ++p;
-      else
 #ifdef DEBUG
       if (strcmp (*p, "-t") == 0)
        d10v_debug = DEBUG;
@@ -603,6 +612,9 @@ pc_addr()
       return 0;
     }
 
+  /* Discard upper bit(s) of PC in case IMAP1 selects unified memory. */
+  pc &= (1 << UMEM_SIZE) - 1;
+
   return State.umem[imap & 0xff] + pc;
 }
 
@@ -667,7 +679,10 @@ sim_resume (sd, step, siggnal)
        {
          RPT_C -= 1;
          if (RPT_C == 0)
-           State.RP = 0;
+           {
+             State.RP = 0;
+             PC++;
+           }
          else
            PC = RPT_S;
        }
@@ -799,20 +814,26 @@ sim_info (sd, verbose)
 }
 
 SIM_RC
-sim_create_inferior (sd, argv, env)
+sim_create_inferior (sd, abfd, argv, env)
      SIM_DESC sd;
+     struct _bfd *abfd;
      char **argv;
      char **env;
 {
-#ifdef DEBUG
-  if (d10v_debug)
-    (*d10v_callback->printf_filtered) (d10v_callback, "sim_create_inferior:  PC=0x%x\n", start_address);
-#endif
+  bfd_vma start_address;
 
   /* reset all state information */
   memset (&State.regs, 0, (int)&State.imem - (int)&State.regs[0]);
 
   /* set PC */
+  if (abfd != NULL)
+    start_address = bfd_get_start_address (prog_bfd);
+  else
+    start_address = 0xffc0 << 2;
+#ifdef DEBUG
+  if (d10v_debug)
+    (*d10v_callback->printf_filtered) (d10v_callback, "sim_create_inferior:  PC=0x%lx\n", (long) start_address);
+#endif
   PC = start_address >> 2;
 
   /* cpu resets imap0 to 0 and imap1 to 0x7f, but D10V-EVA board */
@@ -827,15 +848,7 @@ sim_create_inferior (sd, argv, env)
 
 
 void
-sim_kill (sd)
-     SIM_DESC sd;
-{
-  /* nothing to do */
-}
-
-void
-sim_set_callbacks (sd, p)
-     SIM_DESC sd;
+sim_set_callbacks (p)
      host_callback *p;
 {
   d10v_callback = p;
@@ -931,10 +944,10 @@ sim_load (sd, prog, abfd, from_tty)
   if (prog_bfd != NULL && prog_bfd_was_opened_p)
     bfd_close (prog_bfd);
   prog_bfd = sim_load_file (sd, myname, d10v_callback, prog, abfd,
-                           sim_kind == SIM_OPEN_DEBUG);
+                           sim_kind == SIM_OPEN_DEBUG,
+                           0, sim_write_phys);
   if (prog_bfd == NULL)
     return SIM_RC_FAIL;
-  start_address = bfd_get_start_address (prog_bfd);
   prog_bfd_was_opened_p = abfd == NULL;
   return SIM_RC_OK;
 } 
This page took 0.025295 seconds and 4 git commands to generate.