This commit was generated by cvs2svn to track changes on a CVS vendor
[binutils-gdb.git] / sim / h8300 / compile.c
index 4822bd029921de6fb0759b32022e726be33a9d9e..8e4b55d6a2807d280fc74104eba1448fbb337331 100644 (file)
@@ -32,8 +32,9 @@
 #endif
 #include "ansidecl.h"
 #include "bfd.h"
-#include "callback.h"
-#include "remote-sim.h"
+#include "gdb/callback.h"
+#include "gdb/remote-sim.h"
+#include "gdb/sim-h8300.h"
 
 #ifndef SIGTRAP
 # define SIGTRAP 5
@@ -86,7 +87,7 @@ void sim_set_simcache_size PARAMS ((int));
                               (N << 3) | (Z << 2) | (V<<1) | C;
 
 #define BUILDEXR()         \
-  if( h8300smode ) cpu.exr = ( trace<<7 ) | intMask;
+  if (h8300smode) cpu.exr = (trace<<7) | intMask;
 
 #define GETSR()                    \
   c = (cpu.ccr >> 0) & 1;\
@@ -99,7 +100,7 @@ void sim_set_simcache_size PARAMS ((int));
   intMaskBit = (cpu.ccr >> 7) & 1;
 
 #define GETEXR()           \
-  if( h8300smode ) { \
+  if (h8300smode) { \
     trace = (cpu.exr >> 7) & 1;\
     intMask = cpu.exr & 7; }
 
@@ -850,7 +851,7 @@ mop (code, bsize, sign)
 }
 
 #define ONOT(name, how) \
-case O(name, SB):                              \
+case O (name, SB):                             \
 {                                              \
   int t;                                       \
   int hm = 0x80;                               \
@@ -858,7 +859,7 @@ case O(name, SB):                           \
   how;                                                 \
   goto shift8;                                 \
 }                                              \
-case O(name, SW):                              \
+case O (name, SW):                             \
 {                                              \
   int t;                                       \
   int hm = 0x8000;                             \
@@ -866,7 +867,7 @@ case O(name, SW):                           \
   how;                                                 \
   goto shift16;                                        \
 }                                              \
-case O(name, SL):                              \
+case O (name, SL):                             \
 {                                              \
   int t;                                       \
   int hm = 0x80000000;                                 \
@@ -876,7 +877,7 @@ case O(name, SL):                           \
 }
 
 #define OSHIFTS(name, how1, how2) \
-case O(name, SB):                              \
+case O (name, SB):                             \
 {                                              \
   int t;                                       \
   int hm = 0x80;                               \
@@ -891,7 +892,7 @@ case O(name, SB):                           \
     }                                          \
   goto shift8;                                 \
 }                                              \
-case O(name, SW):                              \
+case O (name, SW):                             \
 {                                              \
   int t;                                       \
   int hm = 0x8000;                             \
@@ -906,7 +907,7 @@ case O(name, SW):                           \
     }                                          \
   goto shift16;                                        \
 }                                              \
-case O(name, SL):                              \
+case O (name, SL):                             \
 {                                              \
   int t;                                       \
   int hm = 0x80000000;                                 \
@@ -923,14 +924,14 @@ case O(name, SL):                         \
 }
 
 #define OBITOP(name,f, s, op)                  \
-case  O(name, SB):                             \
+case (name, SB):                             \
 {                                              \
   int m;                                       \
   int b;                                       \
   if (f) ea = fetch (&code->dst);              \
-  m=1<< fetch(&code->src);                     \
+  m=1<< fetch (&code->src);                    \
   op;                                          \
-  if(s) store (&code->dst,ea); goto next;      \
+  if (s) store (&code->dst,ea); goto next;     \
 }
 
 int
@@ -1021,15 +1022,15 @@ sim_resume (sd, step, siggnal)
 
 
 #define ALUOP(STORE, NAME, HOW) \
-    case O(NAME,SB):  HOW; if(STORE)goto alu8;else goto just_flags_alu8;  \
-    case O(NAME, SW): HOW; if(STORE)goto alu16;else goto just_flags_alu16; \
-    case O(NAME,SL):  HOW; if(STORE)goto alu32;else goto just_flags_alu32;
+    case O (NAME,SB):  HOW; if (STORE)goto alu8;else goto just_flags_alu8;  \
+    case O (NAME, SW): HOW; if (STORE)goto alu16;else goto just_flags_alu16; \
+    case O (NAME,SL):  HOW; if (STORE)goto alu32;else goto just_flags_alu32;
 
 
 #define LOGOP(NAME, HOW) \
-    case O(NAME,SB): HOW; goto log8;\
-    case O(NAME, SW): HOW; goto log16;\
-    case O(NAME,SL): HOW; goto log32;
+    case O (NAME,SB): HOW; goto log8;\
+    case O (NAME, SW): HOW; goto log16;\
+    case O (NAME,SL): HOW; goto log32;
 
 
 
@@ -1044,10 +1045,10 @@ sim_resume (sd, step, siggnal)
 #endif
 
       if (code->opcode)
-       {
-        cycles += code->cycles;
-        insts++;
-       }
+       {
+         cycles += code->cycles;
+         insts++;
+       }
 
       switch (code->opcode)
        {
@@ -1075,8 +1076,8 @@ sim_resume (sd, step, siggnal)
          res = rd + ea;
          goto alu8;
 
-#define EA    ea = fetch(&code->src);
-#define RD_EA ea = fetch(&code->src); rd = fetch(&code->dst);
+#define EA    ea = fetch (&code->src);
+#define RD_EA ea = fetch (&code->src); rd = fetch (&code->dst);
 
          ALUOP (1, O_SUB, RD_EA;
                 ea = -ea;
@@ -1139,35 +1140,35 @@ sim_resume (sd, step, siggnal)
 
        case O (O_EEPMOV, SB):
        case O (O_EEPMOV, SW):
-                if(h8300hmode||h8300smode)
-                 {
-                   register unsigned char *_src,*_dst;
-                   unsigned int count = (code->opcode==O(O_EEPMOV, SW))?cpu.regs[R4_REGNUM]&0xffff:
-                                                                        cpu.regs[R4_REGNUM]&0xff;
-
-                  _src = cpu.regs[R5_REGNUM] < memory_size ? cpu.memory+cpu.regs[R5_REGNUM] :
-                                                             cpu.eightbit + (cpu.regs[R5_REGNUM] & 0xff);
-                  if((_src+count)>=(cpu.memory+memory_size))
-                  {
-                          if((_src+count)>=(cpu.eightbit+0x100))
-                             goto illegal;
-                  }
-                  _dst = cpu.regs[R6_REGNUM] < memory_size ? cpu.memory+cpu.regs[R6_REGNUM] :
+         if (h8300hmode||h8300smode)
+           {
+             register unsigned char *_src,*_dst;
+             unsigned int count = (code->opcode == O(O_EEPMOV, SW))?cpu.regs[R4_REGNUM]&0xffff:
+               cpu.regs[R4_REGNUM]&0xff;
+
+             _src = cpu.regs[R5_REGNUM] < memory_size ? cpu.memory+cpu.regs[R5_REGNUM] :
+               cpu.eightbit + (cpu.regs[R5_REGNUM] & 0xff);
+             if ((_src+count)>=(cpu.memory+memory_size))
+               {
+                 if ((_src+count)>=(cpu.eightbit+0x100))
+                   goto illegal;
+               }
+             _dst = cpu.regs[R6_REGNUM] < memory_size ? cpu.memory+cpu.regs[R6_REGNUM] :
                                                              cpu.eightbit + (cpu.regs[R6_REGNUM] & 0xff);
-                  if((_dst+count)>=(cpu.memory+memory_size))
-                  {
-                          if((_dst+count)>=(cpu.eightbit+0x100))
-                             goto illegal;
-                  }
-                  memcpy(_dst,_src,count);
-
-                  cpu.regs[R5_REGNUM]+=count;
-                  cpu.regs[R6_REGNUM]+=count;
-                  cpu.regs[R4_REGNUM]&=(code->opcode==O(O_EEPMOV, SW))?(~0xffff):(~0xff);
-                  cycles += 2*count;
-                  goto next;
-            }
-           goto illegal;
+             if ((_dst+count)>=(cpu.memory+memory_size))
+               {
+                 if ((_dst+count)>=(cpu.eightbit+0x100))
+                   goto illegal;
+               }
+             memcpy(_dst,_src,count);
+
+             cpu.regs[R5_REGNUM]+=count;
+             cpu.regs[R6_REGNUM]+=count;
+             cpu.regs[R4_REGNUM]&=(code->opcode == O(O_EEPMOV, SW))?(~0xffff):(~0xff);
+             cycles += 2*count;
+             goto next;
+           }
+         goto illegal;
 
        case O (O_ADDS, SL):
          SET_L_REG (code->dst.reg,
@@ -1248,67 +1249,67 @@ sim_resume (sd, step, siggnal)
          goto just_flags_inc32;
 
 #define GET_CCR(x) BUILDSR();x = cpu.ccr
-#define GET_EXR(x) BUILDEXR();x = cpu.exr
+#define GET_EXR(x) BUILDEXR ();x = cpu.exr
 
        case O (O_LDC, SB):
        case O (O_LDC, SW):
-         res = fetch(&code->src);
+         res = fetch (&code->src);
          goto setc;
        case O (O_STC, SB):
        case O (O_STC, SW):
-          if(code->src.type==OP_CCR)
-          {
-            GET_CCR(res);
-          }
-          else if(code->src.type==OP_EXR && h8300smode)
-          {
-            GET_EXR(res);
-          }
-          else
+         if (code->src.type == OP_CCR)
+           {
+             GET_CCR (res);
+           }
+         else if (code->src.type == OP_EXR && h8300smode)
+           {
+             GET_EXR (res);
+           }
+         else
            goto illegal;
          store (&code->dst, res);
          goto next;
 
        case O (O_ANDC, SB):
-          if(code->dst.type==OP_CCR)
-          {
-            GET_CCR (rd);
-          }
-          else if(code->dst.type==OP_EXR && h8300smode)
-          {
-            GET_EXR (rd);
-          }
-          else
+         if (code->dst.type == OP_CCR)
+           {
+             GET_CCR (rd);
+           }
+         else if (code->dst.type == OP_EXR && h8300smode)
+           {
+             GET_EXR (rd);
+           }
+         else
            goto illegal;
          ea = code->src.literal;
          res = rd & ea;
          goto setc;
 
        case O (O_ORC, SB):
-          if(code->dst.type==OP_CCR)
-          {
-            GET_CCR (rd);
-          }
-          else if(code->dst.type==OP_EXR && h8300smode)
-          {
-            GET_EXR (rd);
-          }
-          else
+         if (code->dst.type == OP_CCR)
+           {
+             GET_CCR (rd);
+           }
+         else if (code->dst.type == OP_EXR && h8300smode)
+           {
+             GET_EXR (rd);
+           }
+         else
            goto illegal;
          ea = code->src.literal;
          res = rd | ea;
          goto setc;
 
        case O (O_XORC, SB):
-          if(code->dst.type==OP_CCR)
-          {
-            GET_CCR (rd);
-          }
-          else if(code->dst.type==OP_EXR && h8300smode)
-          {
-            GET_EXR (rd);
-          }
-          else
+         if (code->dst.type == OP_CCR)
+           {
+             GET_CCR (rd);
+           }
+         else if (code->dst.type == OP_EXR && h8300smode)
+           {
+             GET_EXR (rd);
+           }
+         else
            goto illegal;
          ea = code->src.literal;
          res = rd ^ ea;
@@ -1410,7 +1411,7 @@ sim_resume (sd, step, siggnal)
                   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 );
+                  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; v = 0; rd <<= 1; rd |= C; c = rd & hm; rd <<= 1; rd |= C);
@@ -1489,7 +1490,7 @@ sim_resume (sd, step, siggnal)
              the macros here instead of looking for .../sys/wait.h.  */
 #define SIM_WIFEXITED(v) (((v) & 0xff) == 0)
 #define SIM_WIFSIGNALED(v) (((v) & 0x7f) > 0 && (((v) & 0x7f) < 0x7f))
-         if (! SIM_WIFEXITED (cpu.regs[0]) && SIM_WIFSIGNALED (cpu.regs[0])) 
+         if (! SIM_WIFEXITED (cpu.regs[0]) && SIM_WIFSIGNALED (cpu.regs[0]))
            cpu.exception = SIGILL;
          else
            cpu.exception = SIGTRAP;
@@ -1502,7 +1503,7 @@ sim_resume (sd, step, siggnal)
          OBITOP (O_BNOT, 1, 1, ea ^= m);
          OBITOP (O_BTST, 1, 0, nz = ea & m);
          OBITOP (O_BCLR, 1, 1, ea &= ~m);
-         OBITOP (O_BSET, 1, 1, ea |= m);       
+         OBITOP (O_BSET, 1, 1, ea |= m);
          OBITOP (O_BLD, 1, 0, c = ea & m);
          OBITOP (O_BILD, 1, 0, c = !(ea & m));
          OBITOP (O_BST, 1, 1, ea &= ~m;
@@ -1534,20 +1535,20 @@ sim_resume (sd, step, siggnal)
          break;
 
        case O (O_TAS, SB):
-          if( !h8300smode || code->src.type != X (OP_REG, SL) )
-               goto illegal;
-          switch(code->src.reg)
-          {
-           case R0_REGNUM:
-           case R1_REGNUM:
-           case R4_REGNUM:
-           case R5_REGNUM:
-               break;
-           default:
-             goto illegal;
-          }
-          res =  fetch (&code->src);
-          store (&code->src,res|0x80);
+         if (!h8300smode || code->src.type != X (OP_REG, SL))
+           goto illegal;
+         switch (code->src.reg)
+           {
+           case R0_REGNUM:
+           case R1_REGNUM:
+           case R4_REGNUM:
+           case R5_REGNUM:
+             break;
+           default:
+             goto illegal;
+           }
+         res = fetch (&code->src);
+         store (&code->src,res|0x80);
          goto just_flags_log8;
 
        case O (O_DIVU, SB):
@@ -1681,18 +1682,18 @@ sim_resume (sd, step, siggnal)
       abort ();
 
     setc:
-      if(code->dst.type==OP_CCR)
-      {
-       cpu.ccr = res;
-       GETSR ();
-      }
-      else if(code->dst.type==OP_EXR && h8300smode)
-      {
-       cpu.exr = res;
-       GETEXR ();
-      }
+      if (code->dst.type == OP_CCR)
+       {
+         cpu.ccr = res;
+         GETSR ();
+       }
+      else if (code->dst.type == OP_EXR && h8300smode)
+       {
+         cpu.exr = res;
+         GETEXR ();
+       }
       else
-        goto illegal;
+       goto illegal;
 
       goto next;
 
@@ -1873,7 +1874,7 @@ sim_resume (sd, step, siggnal)
 
   cpu.pc = pc;
   BUILDSR ();
-  BUILDEXR();
+  BUILDEXR ();
   cpu.mask = oldmask;
   signal (SIGINT, prev);
 }
@@ -1994,8 +1995,8 @@ sim_fetch_register (sd, rn, buf, length)
 
   init_pointers ();
 
-  if(!h8300smode && rn >=EXR_REGNUM)
-       rn++;
+  if (!h8300smode && rn >=EXR_REGNUM)
+    rn++;
   switch (rn)
     {
     default: