gencode.c

来自「这个是LINUX下的GDB调度工具的源码」· C语言 代码 · 共 2,469 行 · 第 1/5 页

C
2,469
字号
    "",    "z = 17; /* Ignore result.  */",    "res = Sx - Sy;",    "carry = (unsigned) res > (unsigned) Sx;",    "res_grd = Sx_grd - Sy_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "pwsb Sx,Sy,Dz",	"10100100xxyyzzzz",  },  { "","", "pwad Sx,Sy,Dz",	"10110100xxyyzzzz",  },  { "","", "(if cc) pabs Sx,Dz",	"100010ccxx01zzzz",    "/* FIXME: duplicate code pabs.  */",    "res = DSP_R (x);",    "res_grd = GET_DSP_GRD (x);",    "if (res >= 0)",    "  carry = 0;",    "else",    "  {",    "    res = -res;",    "    carry = (res != 0); /* The manual has a bug here.  */",     "    res_grd = -res_grd - carry;",     "  }",    "COMPUTE_OVERFLOW;",    "/* ??? The re-computing of overflow after",    "   saturation processing is specific to pabs.  */",    "overflow = res_grd != SIGN32 (res) ? DSR_MASK_V : 0;",    "ADD_SUB_GE;",  },  { "","", "pabs Sx,Dz",	"10001000xx..zzzz",    "res = DSP_R (x);",    "res_grd = GET_DSP_GRD (x);",    "if (res >= 0)",    "  carry = 0;",    "else",    "  {",    "    res = -res;",    "    carry = (res != 0); /* The manual has a bug here.  */",     "    res_grd = -res_grd - carry;",     "  }",    "COMPUTE_OVERFLOW;",    "/* ??? The re-computing of overflow after",    "   saturation processing is specific to pabs.  */",    "overflow = res_grd != SIGN32 (res) ? DSR_MASK_V : 0;",    "ADD_SUB_GE;",  },  { "","", "(if cc) prnd Sx,Dz",	"100110ccxx01zzzz",    "/* FIXME: duplicate code prnd.  */",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "",    "res = (Sx + 0x8000) & 0xffff0000;",    "carry = (unsigned) res < (unsigned) Sx;",    "res_grd = Sx_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "prnd Sx,Dz",	"10011000xx..zzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "",    "res = (Sx + 0x8000) & 0xffff0000;",    "carry = (unsigned) res < (unsigned) Sx;",    "res_grd = Sx_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pabs Sy,Dz",	"101010cc01yyzzzz",    "/* FIXME: duplicate code pabs.  */",    "res = DSP_R (y);",    "res_grd = 0;",    "overflow = 0;",    "greater_equal = DSR_MASK_G;",    "if (res >= 0)",    "  carry = 0;",    "else",    "  {",    "    res = -res;",    "    carry = 1;",    "    if (res < 0)",    "      {",    "        if (S)",    "          res = 0x7fffffff;",    "        else",    "          {",    "            overflow = DSR_MASK_V;",    "            greater_equal = 0;",    "          }",    "      }",    "  }",  },  { "","", "pabs Sy,Dz",	"10101000..yyzzzz",    "res = DSP_R (y);",    "res_grd = 0;",    "overflow = 0;",    "greater_equal = DSR_MASK_G;",    "if (res >= 0)",    "  carry = 0;",    "else",    "  {",    "    res = -res;",    "    carry = 1;",    "    if (res < 0)",    "      {",    "        if (S)",    "          res = 0x7fffffff;",    "        else",    "          {",    "            overflow = DSR_MASK_V;",    "            greater_equal = 0;",    "          }",    "      }",    "  }",  },  { "","", "(if cc) prnd Sy,Dz",	"101110cc01yyzzzz",    "/* FIXME: duplicate code prnd.  */",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = (Sy + 0x8000) & 0xffff0000;",    "carry = (unsigned) res < (unsigned) Sy;",    "res_grd = Sy_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "prnd Sy,Dz",	"10111000..yyzzzz",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = (Sy + 0x8000) & 0xffff0000;",    "carry = (unsigned) res < (unsigned) Sy;",    "res_grd = Sy_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pshl Sx,Sy,Dz",	"100000ccxxyyzzzz",    "int Sx = DSP_R (x) & 0xffff0000;",    "int Sy = DSP_R (y) >> 16 & 0x7f;",    "",    "if (Sy <= 16)",    "  res = Sx << Sy;",    "else if (Sy >= 128 - 16)",    "  res = (unsigned) Sx >> 128 - Sy;	/* no sign extension */",    "else",    "  {",    "    RAISE_EXCEPTION (SIGILL);",    "    return;",    "  }",    "goto cond_logical;",  },  { "","", "(if cc) psha Sx,Sy,Dz",	"100100ccxxyyzzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "int Sy = DSP_R (y) >> 16 & 0x7f;",    "",    "if (Sy <= 32)",    "  {",    "    if (Sy == 32)",    "      {",    "        res = 0;",    "        res_grd = Sx;",    "      }",    "    else",    "      {",    "        res = Sx << Sy;",    "        res_grd = Sx_grd << Sy | (unsigned) Sx >> 32 - Sy;",    "      }",    "    res_grd = SEXT (res_grd);",    "    carry = res_grd & 1;",    "  }",    "else if (Sy >= 96)",    "  {",    "    Sy = 128 - Sy;",    "    if (Sy == 32)",    "      {",    "        res_grd = SIGN32 (Sx_grd);",    "        res = Sx_grd;",    "      }",    "    else",    "      {",    "        res = Sx >> Sy | Sx_grd << 32 - Sy;",    "        res_grd = Sx_grd >> Sy;",    "      }",    "    carry = Sx >> (Sy - 1) & 1;",    "  }",    "else",    "  {",    "    RAISE_EXCEPTION (SIGILL);",    "    return;",    "  }",    "COMPUTE_OVERFLOW;",    "greater_equal = 0;",  },  { "","", "(if cc) psub Sx,Sy,Dz",	"101000ccxxyyzzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = Sx - Sy;",    "carry = (unsigned) res > (unsigned) Sx;",    "res_grd = Sx_grd - Sy_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) psub Sy,Sx,Dz",	"100001ccxxyyzzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = Sy - Sx;",    "carry = (unsigned) res > (unsigned) Sy;",    "res_grd = Sy_grd - Sx_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) padd Sx,Sy,Dz",	"101100ccxxyyzzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = Sx + Sy;",    "carry = (unsigned) res < (unsigned) Sx;",    "res_grd = Sx_grd + Sy_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pand Sx,Sy,Dz",	"100101ccxxyyzzzz",    "res = DSP_R (x) & DSP_R (y);",  "cond_logical:",    "res &= 0xffff0000;",    "res_grd = 0;",    "if (iword & 0x200)\n",    "  goto assign_z;\n",  "logical:",    "carry = 0;",    "overflow = 0;",    "greater_equal = 0;",    "DSR &= ~0xf1;\n",    "if (res)\n",    "  DSR |= res >> 26 & DSR_MASK_N;\n",    "else\n",    "  DSR |= DSR_MASK_Z;\n",    "goto assign_dc;\n",  },  { "","", "(if cc) pxor Sx,Sy,Dz",	"101001ccxxyyzzzz",    "res = DSP_R (x) ^ DSP_R (y);",    "goto cond_logical;",  },  { "","", "(if cc) por Sx,Sy,Dz",	"101101ccxxyyzzzz",    "res = DSP_R (x) | DSP_R (y);",    "goto cond_logical;",  },  { "","", "(if cc) pdec Sx,Dz",	"100010ccxx..zzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "",    "res = Sx - 0x10000;",    "carry = res > Sx;",    "res_grd = Sx_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",    "res &= 0xffff0000;",  },  { "","", "(if cc) pinc Sx,Dz",	"100110ccxx..zzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "",    "res = Sx + 0x10000;",    "carry = res < Sx;",    "res_grd = Sx_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",    "res &= 0xffff0000;",  },  { "","", "(if cc) pdec Sy,Dz",	"101010cc..yyzzzz",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = Sy - 0x10000;",    "carry = res > Sy;",    "res_grd = Sy_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",    "res &= 0xffff0000;",  },  { "","", "(if cc) pinc Sy,Dz",	"101110cc..yyzzzz",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = Sy + 0x10000;",    "carry = res < Sy;",    "res_grd = Sy_grd + carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",    "res &= 0xffff0000;",  },  { "","", "(if cc) pclr Dz",		"100011cc....zzzz",    "res = 0;",    "res_grd = 0;",    "carry = 0;",    "overflow = 0;",    "greater_equal = 1;",  },  { "","", "pclr Du pmuls Se,Sf,Dg",	"0100eeff0001gguu",    "/* Do multiply.  */",    "res = (DSP_R (e) >> 16) * (DSP_R (f) >> 16) * 2;",    "if (res == 0x80000000)",    "  res = 0x7fffffff;",    "DSP_R (g) = res;",    "DSP_GRD (g) = SIGN32 (res);",    "/* FIXME: update DSR based on results of multiply!  */",    "",    "/* Do clr.  */",    "z = u;",    "res = 0;",    "res_grd = 0;",    "goto assign_z;",  },  { "","", "(if cc) pdmsb Sx,Dz",	"100111ccxx..zzzz",    "unsigned Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "int i = 16;",    "",    "if (Sx_grd < 0)",    "  {",    "    Sx_grd = ~Sx_grd;",    "    Sx = ~Sx;",    "  }",    "if (Sx_grd)",    "  {",    "    Sx = Sx_grd;",    "    res = -2;",    "  }",    "else if (Sx)",    "  res = 30;",    "else",    "  res = 31;",    "do",    "  {",    "    if (Sx & ~0 << i)",    "      {",    "        res -= i;",    "        Sx >>= i;",    "      }",    "  }",    "while (i >>= 1);",    "res <<= 16;",    "res_grd = SIGN32 (res);",    "carry = 0;",    "overflow = 0;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pdmsb Sy,Dz",	"101111cc..yyzzzz",    "unsigned Sy = DSP_R (y);",    "int i;",    "",    "if (Sy < 0)",    "  Sy = ~Sy;",    "Sy <<= 1;",    "res = 31;",    "do",    "  {",    "    if (Sy & ~0 << i)",    "      {",    "        res -= i;",    "        Sy >>= i;",    "      }",    "  }",    "while (i >>= 1);",    "res <<= 16;",    "res_grd = SIGN32 (res);",    "carry = 0;",    "overflow = 0;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pneg Sx,Dz",	"110010ccxx..zzzz",    "int Sx = DSP_R (x);",    "int Sx_grd = GET_DSP_GRD (x);",    "",    "res = 0 - Sx;",    "carry = res != 0;",    "res_grd = 0 - Sx_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pcopy Sx,Dz",	"110110ccxx..zzzz",    "res = DSP_R (x);",    "res_grd = GET_DSP_GRD (x);",    "carry = 0;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pneg Sy,Dz",	"111010cc..yyzzzz",    "int Sy = DSP_R (y);",    "int Sy_grd = SIGN32 (Sy);",    "",    "res = 0 - Sy;",    "carry = res != 0;",    "res_grd = 0 - Sy_grd - carry;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) pcopy Sy,Dz",	"111110cc..yyzzzz",    "res = DSP_R (y);",    "res_grd = SIGN32 (res);",    "carry = 0;",    "COMPUTE_OVERFLOW;",    "ADD_SUB_GE;",  },  { "","", "(if cc) psts MACH,Dz",	"110011cc....zzzz",    "res = MACH;",    "res_grd = SIGN32 (res);",    "goto assign_z;",  },  { "","", "(if cc) psts MACL,Dz",	"110111cc....zzzz",    "res = MACL;",    "res_grd = SIGN32 (res);",    "goto assign_z;",  },  { "","", "(if cc) plds Dz,MACH",	"111011cc....zzzz",    "if (0xa05f >> z & 1)",    "  RAISE_EXCEPTION (SIGILL);",    "else",    "  MACH = DSP_R (z);",    "return;",  },  { "","", "(if cc) plds Dz,MACL",	"111111cc....zzzz",    "if (0xa05f >> z & 1)",    "  RAISE_EXCEPTION (SIGILL);",    "else",    "  MACL = DSP_R (z) = res;",    "return;",  },  /* sh4a */  { "","", "(if cc) pswap Sx,Dz",	"100111ccxx01zzzz",    "int Sx = DSP_R (x);",    "",    "res = ((Sx & 0xffff) * 65536) + ((Sx >> 16) & 0xffff);",    "res_grd = GET_DSP_GRD (x);",    "carry = 0;",    "overflow = 0;",    "greater_equal = res & 0x80000000 ? 0 : DSR_MASK_G;",  },  /* sh4a */  { "","", "(if cc) pswap Sy,Dz",	"101111cc01yyzzzz",    "int Sy = DSP_R (y);",    "",    "res = ((Sy & 0xffff) * 65536) + ((Sy >> 16) & 0xffff);",    "res_grd = SIGN32 (Sy);",    "carry = 0;",    "overflow = 0;",    "greater_equal = res & 0x80000000 ? 0 : DSR_MASK_G;",  },  {0, 0}};/* Tables of things to put into enums for sh-opc.h */static char *nibble_type_list[] ={  "HEX_0",  "HEX_1",  "HEX_2",  "HEX_3",  "HEX_4",  "HEX_5",  "HEX_6",  "HEX_7",  "HEX_8",  "HEX_9",  "HEX_A",  "HEX_B",  "HEX_C",  "HEX_D",  "HEX_E",  "HEX_F",  "REG_N",  "REG_M",  "BRANCH_12",  "BRANCH_8",  "DISP_8",  "DISP_4",  "IMM_4",  "IMM_4BY2",  "IMM_4BY4",  "PCRELIMM_8BY2",  "PCRELIMM_8BY4",

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?