No longer need to sanitize away h8s stuff.
[deliverable/binutils-gdb.git] / sim / h8300 / compile.c
index 21b9d6587bb16494652d3f48314ac1479edf5be4..7159af2b37dad444dddccacfa2ecedc20888a615 100644 (file)
@@ -84,9 +84,7 @@ int debug;
 static cpu_state_type cpu;
 
 int h8300hmode = 0;
-/* start-sanitize-h8s */
 int h8300smode = 0;
-/* end-sanitize-h8s */
 
 static int memory_size;
 
@@ -823,7 +821,7 @@ mop (code, bsize, sign)
 
 }
 
-#define OSHIFTS(name, how) \
+#define ONOT(name, how) \
 case O(name, SB):                              \
 {                                              \
   int t;                                       \
@@ -849,6 +847,53 @@ case O(name, SL):                          \
   goto shift32;                                        \
 }
 
+#define OSHIFTS(name, how1, how2) \
+case O(name, SB):                              \
+{                                              \
+  int t;                                       \
+  int hm = 0x80;                               \
+  rd = GET_B_REG (code->src.reg);              \
+  if ((GET_MEMORY_B (pc + 1) & 0x40) == 0)     \
+    {                                          \
+      how1;                                    \
+    }                                          \
+  else                                         \
+    {                                          \
+      how2;                                    \
+    }                                          \
+  goto shift8;                                 \
+}                                              \
+case O(name, SW):                              \
+{                                              \
+  int t;                                       \
+  int hm = 0x8000;                             \
+  rd = GET_W_REG (code->src.reg);              \
+  if ((GET_MEMORY_B (pc + 1) & 0x40) == 0)     \
+    {                                          \
+      how1;                                    \
+    }                                          \
+  else                                         \
+    {                                          \
+      how2;                                    \
+    }                                          \
+  goto shift16;                                        \
+}                                              \
+case O(name, SL):                              \
+{                                              \
+  int t;                                       \
+  int hm = 0x80000000;                                 \
+  rd = GET_L_REG (code->src.reg);              \
+  if ((GET_MEMORY_B (pc + 1) & 0x40) == 0)     \
+    {                                          \
+      how1;                                    \
+    }                                          \
+  else                                         \
+    {                                          \
+      how2;                                    \
+    }                                          \
+  goto shift32;                                        \
+}
+
 #define OBITOP(name,f, s, op)                  \
 case  O(name, SB):                             \
 {                                              \
@@ -1204,38 +1249,31 @@ sim_resume (step, siggnal)
          printf ("%c", cpu.regs[2]);
          goto next;
 
-         OSHIFTS (O_NOT, rd = ~rd; v = 0;);
-         OSHIFTS (O_SHLL, c = rd & hm; v = 0;
-                  rd <<= 1);
-         OSHIFTS (O_SHLR, c = rd & 1; v = 0;
-                  rd = (unsigned int) rd >> 1);
-         OSHIFTS (O_SHAL, c = rd & hm;
-                  v = (rd & hm) != ((rd & (hm >> 1)) << 1);
-                  rd <<= 1);
-         OSHIFTS (O_SHAR, t = rd & hm;
-                  c = rd & 1;
-                  v = 0;
-                  rd >>= 1;
-                  rd |= t;
-                  );
-         OSHIFTS (O_ROTL, c = rd & hm;
-                  v = 0;
-                  rd <<= 1;
-                  rd |= C);
-         OSHIFTS (O_ROTR, c = rd & 1;
-                  v = 0;
-                  rd = (unsigned int) rd >> 1;
-                  if (c) rd |= hm;);
-         OSHIFTS (O_ROTXL, t = rd & hm;
-                  rd <<= 1;
-                  rd |= C;
-                  c = t;
-                  v = 0;
-                  );
-         OSHIFTS (O_ROTXR, t = rd & 1;
-                  rd = (unsigned int) rd >> 1;
-                  if (C) rd |= hm; c = t;
-                  v = 0;);
+         ONOT (O_NOT, rd = ~rd; v = 0;);
+         OSHIFTS (O_SHLL,
+                  c = rd & hm; v = 0; rd <<= 1,
+                  c = rd & (hm >> 1); v = 0; rd <<= 2);
+         OSHIFTS (O_SHLR,
+                  c = rd & 1; v = 0; rd = (unsigned int) rd >> 1,
+                  c = rd & 2; v = 0; rd = (unsigned int) rd >> 2);
+         OSHIFTS (O_SHAL,
+                  c = rd & hm; v = (rd & hm) != ((rd & (hm >> 1)) << 1); rd <<= 1,
+                  c = rd & (hm >> 1); v = (rd & (hm >> 1)) != ((rd & (hm >> 2)) << 2); rd <<= 2);
+         OSHIFTS (O_SHAR,
+                  t = rd & hm; c = rd & 1; v = 0; rd >>= 1; rd |= t,
+                  t = rd & hm; c = rd & 2; v = 0; rd >>= 2; rd |= t | t >> 1 );
+         OSHIFTS (O_ROTL,
+                  c = rd & hm; v = 0; rd <<= 1; rd |= C,
+                  c = rd & (hm >> 1); v = 0; rd <<= 2; rd |= C);
+         OSHIFTS (O_ROTR,
+                  c = rd & 1; v = 0; rd = (unsigned int) rd >> 1; if (c) rd |= hm,
+                  c = rd & 2; v = 0; rd = (unsigned int) rd >> 2; if (c) rd |= hm);
+         OSHIFTS (O_ROTXL,
+                  t = rd & hm; rd <<= 1; rd |= C; c = t; v = 0,
+                  t = rd & (hm >> 1); rd <<= 2; rd |= C; c = t; v = 0);
+         OSHIFTS (O_ROTXR,
+                  t = rd & 1; rd = (unsigned int) rd >> 1; if (C) rd |= hm; c = t; v = 0,
+                  t = rd & 2; rd = (unsigned int) rd >> 2; if (C) rd |= hm; c = t; v = 0);
 
        case O (O_JMP, SB):
          {
@@ -1427,7 +1465,6 @@ sim_resume (step, siggnal)
        case O (O_NOP, SB):
          goto next;
 
-/* start-sanitize-h8s */
        case O (O_STM, SL):
          {
            int nregs, firstreg, i;
@@ -1462,7 +1499,6 @@ sim_resume (step, siggnal)
          }
          goto next;
 
-/* end-sanitize-h8s */
        default:
          cpu.exception = SIGILL;
          goto end;
@@ -1933,10 +1969,7 @@ sim_load (prog, from_tty)
       if (bfd_check_format (abfd, bfd_object)) 
        {
          set_h8300h (abfd->arch_info->mach == bfd_mach_h8300h
-/* start-sanitize-h8s */
-                     || abfd->arch_info->mach == bfd_mach_h8300s
-/* end-sanitize-h8s */
-                     );
+                     || abfd->arch_info->mach == bfd_mach_h8300s);
        }
       bfd_close (abfd);
     }
This page took 0.0254 seconds and 4 git commands to generate.