home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Source ƒ / ASM 2.0 ƒ / table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-15  |  8.6 KB  |  269 lines

  1. #
  2.  
  3. /*
  4.  *    table.h --- basic definitions for the mnemonic table
  5.  *
  6.  *      Table.c is generated using an awk program.  The mnemonic
  7.  *    table consists of a base mnemonic, the number of templates
  8.  *    to match against the operand field, and a pointer to the
  9.  *    list of templates.  The templates consist of the allowed
  10.  *      sizes that follow the mnemonic, and up to 4 ea classes
  11.  *    for the instruction.  A successful match must match the
  12.  *    type and number of operands.  Some pseudo ops are different,
  13.  *    since they have an open-ended number of operands (e.g. ds,dc)
  14.  *    These are marked in the table with a first EA type of MULTI.
  15.  */
  16.  
  17. struct tmpl{    /* a template to match */
  18.     char    sizes;    /* allowed sizes (bit map) */
  19.     char    modes[4];       /* up to 4 EA fields may be specified */
  20.     char    class;    /* opcode class */
  21.     short   op;     /* base opcode */
  22.     short   op2;    /* second opcode (F-line, etc) */
  23.     };
  24.  
  25. struct mne{    /* a mnemonic */
  26.     char    *mne_name;
  27.     char    ntmpl;          /* number of templates to test */
  28.     struct tmpl *ptmpl;     /* pointer to templates to test */
  29.     };
  30.  
  31. /* sizes */
  32. #define    B    0x01
  33. #define W    0x02
  34. #define L    0x04
  35. #define S    0x08
  36. #define D    0x10
  37. #define X    0x20
  38. #define P    0x40
  39. #define U    0x80
  40. /* composite sizes */
  41. #define    bwlu    (B|W|L|U)
  42. #define    bwlsdxp    (B|W|L|S|D|X|P)
  43. #define    wlu    (W|L|U)
  44. #define    bu    (B|U)
  45. #define wu    (W|U)
  46. #define    lu    (L|U)
  47. #define    wl    (W|L)
  48. #define xu      (X|U)
  49. #define bwlsdxpu (B|W|L|S|D|X|P|U)
  50. #define anysz    (B|W|L|S|D|X|P|U)
  51.  
  52. /* opcode classes */
  53. #define INH             0
  54. #define RXRY            1
  55. #define RXRYS           2
  56. #define RXRYR           3
  57. #define RXRYP           4
  58. #define EAREG           5
  59. #define EAREGS          6
  60. #define REGEA           7
  61. #define REGEAS          8
  62. #define IMMEAS          9
  63. #define QUKEA           10
  64. #define IMMB            11
  65. #define IMMW            12
  66. #define IMMWS           13
  67. #define IMM3            14
  68. #define IMM4            15
  69. #define RSHIFT          16
  70. #define QSHIFT          17
  71. #define EA              18
  72. #define EAREV           19
  73. #define EAS             20
  74. #define BCC             21
  75. #define BIT             22
  76. #define BITFLD          23
  77. #define BITFLD2         24
  78. #define CALLM           25
  79. #define CAS             26
  80. #define CAS2            27
  81. #define CHK             28
  82. #define CHK2            29
  83. #define DBCC            30
  84. #define MULDIV          40
  85. #define REG             41
  86. #define MOVEU           42      /* move to/from usp */
  87. #define REGIMM          43
  88. #define MOVE            44
  89. #define MOVEC           45
  90. #define MOVEQ           46
  91. #define MOVEMO          47
  92. #define MOVEMI          48
  93. #define MOVEPO          49
  94. #define MOVEPI          50
  95. #define MOVES           51
  96. #define TRAPCC          52
  97.  
  98. /* floating point classes */
  99. #define FEAREG          53
  100. #define FREGREG         54
  101. #define FMONAD          55
  102. #define FBCC            56
  103. #define FDBCC           57
  104. #define FINH            58
  105. #define FEA             59
  106. #define FSCC            60
  107. #define FEAPAIR         61
  108. #define FREGPAIR        62
  109. #define FTSTEA          63
  110. #define FTSTREG         64
  111. #define FMOVE           65
  112. #define FMOVECR         66
  113. #define FMOVEMI         67
  114. #define FMOVEMO         68
  115. #define FMOVEMCI        69
  116. #define FMOVEMCO        70
  117. #define FTRAPCC         71
  118.  
  119. /* PMMU classes */
  120. #define PINH            72
  121. #define PBCC            73
  122. #define PDBCC           74
  123. #define PFLUSH          75
  124. #define PEA             76
  125. #define PLOAD           77
  126. #define PMOVEI          78
  127. #define PMOVEO          79
  128. #define PSCC            80
  129. #define PTEST           81
  130. #define PTRAPCC         82
  131. #define PVALID          83
  132. #define PMOVEIF         84
  133.  
  134. /* generic co-processor classes */
  135. #define CPINH           85
  136. #define CPBCC           86
  137. #define CPDBCC          87
  138. #define CPGEN           88
  139. #define CPEA            89
  140. #define CPSCC           90
  141. #define CPTRAPCC        91
  142.  
  143. /* 68hc16 specific classes */
  144. #define    LPSTOP        92
  145. #define    TABEA        93
  146. #define    TABREG        94
  147.  
  148. /* pseudo op classes */
  149. #define EQU             100
  150. #define DC              101
  151. #define OPT             102
  152. #define ORG             103
  153. #define DS              104
  154. #define FEQU            105
  155. #define FOPT            106
  156. #define NULL_OP         107
  157. #define ALIGN           108
  158. #define INCLUDE         109
  159. #define RORG            110
  160.  
  161. struct ea {
  162.     char    type;
  163.     char    itype;  /* when INDEX or PCINDEX, itype specifies sub-mode */
  164.     int     reg;    /* An,Dn,Sp,FPn,Rc,FPc,Pn */
  165.     int    reg2;    /* second register for reg. pairs */
  166.     int    const;    /* #val, displacement, branch dest */
  167.     int    const2;    /* second constant (on static bit field) */
  168.     char    stat;   /* when type==FIELD, stat1==1 -> static */
  169.     char    stat2;  /* when type==FIELD, stat2==1 -> static */
  170.     char    br_sup; /* supress An or PC when set */
  171.     char    xn_sup; /* supress Xn when set */
  172.     char    bdsiz;  /* size and/or supress for base displacement */
  173.     char    odsiz;  /* size and/or supress for outer displacement */
  174.     char    siz;    /* size for indexed modes */
  175.     char    scl;    /* scale for indexed modes */
  176.     char    prepst; /* 0=pre or mem indir, 1=post */
  177.     char    force;  /* const or bdsiz involved a forward ref */
  178.     char    force2; /* const2 or odsiz involved a forward ref */
  179.     };
  180.  
  181. /* Basic EA types */
  182. #define EMPTY   0       /* not used, must be defined as zero */
  183. #define DN      1       /* Dn */
  184. #define AN      2       /* An, SP */
  185. #define ANI     3       /* (An) */
  186. #define PSTINC  4       /* (An)+ */
  187. #define PREDEC  5       /* -(An) */
  188. #define INDEX   6       /* mode == 05n or 06n */
  189. #define EXPR    7       /* expression (labels, absolute addressing) */
  190. #define IMMED   8       /* #expression */
  191. #define PCINDEX 9       /* mode == 072 or 073 */
  192.  
  193. /* Other basic EA's, not used in general EA classes */
  194. #define DPAIR   10      /* Dn:Dn */
  195. #define RPAIR   11      /* (Rn):(Rn) */
  196. #define RLIST   12      /* e.g. A0-A3/D5/D7 */
  197. #define FIELD   13      /* {Dn/#:Dn/#} */
  198. #define CN      14      /* control reg (including USP) */
  199. #define CCR     15      /* condition code register */
  200. #define SR      16      /* status register */
  201. #define FN      17      /* FPn */
  202. #define FCN     18      /* FPCR,FPSR,FPIAR */
  203. #define FLIST   19      /* e.g. FP2-FP4/FP7 */
  204. #define FPAIR   20      /* FPm:FPn */
  205. #define FCLIST  21      /* FPCR/FPSR/FPIAR */
  206. #define DYNK    22      /* dynamic K factor {Dn} */
  207. #define STATK   23      /* static K factor {const} */
  208. #define PN      24      /* PMMU register */
  209. #define STRING  25      /* ASCII string */
  210.  
  211. /* composite EA types. can be one or more of the basic types */
  212. #define RN      26      /* DN or AN */
  213. #define ANYEA   27      /* any EA */
  214. #define CONTROL 28      /* Control */
  215. #define ALTMEM  29      /* Alterable memory (does not include Dn) */
  216. #define DATALT  30      /* Data alterable */
  217. #define ALTER   31      /* alterable (An not allowed on byte operations) */
  218. #define DATA    32      /* Data */
  219. #define CALTPR  33      /* Control Alterable, or predec */
  220. #define CTLPST  34      /* Control, or postinc */
  221. #define CTLALT  35      /* Control Alterable */
  222. #define MEMORY  36      /* Memory */
  223. #define PEA1    37      /* EXPR, DN or CN (Special for PMMU) */
  224. #define MULTI   38      /* up to EAMAX of EXPR's */
  225.  
  226. /* indexed addressing mode types (e->itype) */
  227. #define D16AN   1       /* d16 + (An) */
  228. #define BRIEF   2       /* d8 + (An) + (Xn.siz*scl) */
  229. #define FULL    3       /* full format */
  230.  
  231. /*
  232.  *      For each basic EA type returned by scanea(), the remaining
  233.  *      structure elements are set as follows:
  234.  *
  235.  *      Type    Sets
  236.  *
  237.  *      EMPTY   nothing
  238.  *      DN      reg = 0-7
  239.  *      AN      reg = 0-7
  240.  *      ANI     reg = 0-7
  241.  *      PSTINC  reg = 0-7
  242.  *      PREDEC  reg = 0-7
  243.  *      INDEX   see do_indexed() and/or oh_shit()
  244.  *      EXPR    const = result of expr. eval, csiz: 0=none, 1=.W, 2=.L
  245.  *      IMMED   const = immediate value
  246.  *      PCINDEX see do_indexed() and/or oh_shit()
  247.  *      DPAIR   reg = 1st reg#, reg2 = 2nd reg#
  248.  *      RPAIR   reg = 1st reg#, reg2 = 2nd reg#,
  249.  *              stat1 ? reg is An : reg is Dn
  250.  *              stat2 ? reg2 is An : reg2 is Dn
  251.  *      RLIST   reg = bit map of registers, A7=msb, D0=lsb
  252.  *      FIELD   reg = 1st reg, reg2 = 2nd reg,
  253.  *              const = 1st constant, const2 = 2nd constant,
  254.  *              stat1 ? 1st is STATIC : 1st is Dynamic,
  255.  *              stat2 ? 2nd is STATIC : 2nd is Dynamic
  256.  *      CN      reg = control reg# as per movec encoding
  257.  *      CCR     nothing
  258.  *      SR      nothing
  259.  *      FN      reg = 0-7
  260.  *      FCN     reg = Fp control reg# as per fmovec encoding
  261.  *      FLIST   reg = bit map of FP regs, FP7=msb, FP0=lsb
  262.  *      FPAIR   reg = 1st fp reg, reg2 = 2nd fp reg
  263.  *      FCLIST  reg = bit map as per fmovem encoding
  264.  *      DYNK    reg = 0-7
  265.  *      STATK   const = expression
  266.  *      PN      reg = reg# as per second word on PMOVE
  267.  *      STRING  const = ptr to character string
  268.  */
  269.