Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1370 lines
48 KiB

  1. /*++
  2. Copyright (c) 1993 Digital Equipment Corporation
  3. Copyright (c) 1993-2001 Microsoft Corporation
  4. Module Name:
  5. alpha_optable.c
  6. Abstract:
  7. Declaration for -
  8. Table of operations, their names and charactersitics
  9. Used by ntsd, windbg and acc's dissassembler
  10. Author:
  11. Miche Baker-Harvey (mbh) 10-Jan-1993
  12. Revision History:
  13. --*/
  14. #include "ntsdp.hpp"
  15. #define DEFINE_STRINGS
  16. #include "alpha_strings.h"
  17. #include "alpha_optable.h"
  18. //
  19. // These are the parsing functions. In ntsd, they are defined
  20. // in alpha_asm.c. In windbg, they are defined in MBH - WHERE????
  21. //
  22. ULONG ParseIntMemory (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  23. ULONG ParseFltMemory (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  24. ULONG ParseMemSpec (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  25. ULONG ParseJump (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  26. ULONG ParseIntBranch (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  27. ULONG ParseFltBranch (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  28. ULONG ParseIntOp (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  29. ULONG ParsePal (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  30. ULONG ParseUnknown (PSTR, PSTR *, POPTBLENTRY, PULONG64);
  31. #define NOFNCTBL NULL
  32. #define NOSIZE NULL
  33. //
  34. // These fields are used to find the beginning of the sections
  35. // containing different "ENTRY_TYPE"s
  36. //
  37. POPTBLENTRY InvalidTab;
  38. POPTBLENTRY NonTerminalTab;
  39. POPTBLENTRY TerminalTab;
  40. POPTBLENTRY FunctionTab;
  41. ULONG InvalidTabSize;
  42. ULONG NonTerminalTabSize;
  43. ULONG TerminalTabSize;
  44. ULONG FunctionTabSize;
  45. //
  46. // THE OPCODE TABLE ITSELF
  47. //
  48. // The opcode table "opTable" describes each opcode and function.
  49. // There is an entry for each opcode, and for each function.
  50. //
  51. // The table is organized as follows:
  52. // invalid-ops,
  53. // non-terminal-ops,
  54. // terminal-ops,
  55. // functions,
  56. //
  57. // This organization is NOT required:
  58. // no assumptions are made on it.
  59. //
  60. // Searches based on opcode must search
  61. // INVALID, TERMINAL and NON_TERMINAL
  62. //
  63. // Searches based on instruction name must search
  64. // TERMINAL and FUNCTION
  65. //
  66. //
  67. OPTBLENTRY opTable[] = {
  68. //
  69. // First, the INVALID_ETYPE section.
  70. // (opcode searches begin here)
  71. //
  72. { "?Opc01", ParseUnknown, _01_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  73. { "?Opc02", ParseUnknown, _02_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  74. { "?Opc03", ParseUnknown, _03_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  75. { "?Opc04", ParseUnknown, _04_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  76. { "?Opc05", ParseUnknown, _05_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  77. { "?Opc06", ParseUnknown, _06_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  78. { "?Opc07", ParseUnknown, _07_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  79. { "?Opc0A", ParseUnknown, _0A_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  80. { "?Opc0C", ParseUnknown, _0C_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  81. { "?Opc0D", ParseUnknown, _0D_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  82. { "?Opc0E", ParseUnknown, _0E_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  83. { "?Opc14", ParseUnknown, _14_OP, NO_FUNC, ALPHA_UNKNOWN, INVALID_ETYPE},
  84. //
  85. // This is what hasn't been done yet -
  86. // the EV4 stuff - there are no names for it
  87. // in the alphaops.h header file. Should we
  88. // put them there? Should they be elsewhere?
  89. // Do we want to assemble them?
  90. //
  91. // For the moment, just pretend they are invalid. They never
  92. // come up for all practical purposes, anyway.
  93. //
  94. { "MFPR", ParseUnknown, MFPR_OP, NO_FUNC,
  95. ALPHA_EV4_PR, INVALID_ETYPE },
  96. { "MTPR", ParseUnknown, MTPR_OP, NO_FUNC,
  97. ALPHA_EV4_PR, INVALID_ETYPE },
  98. //
  99. // Secondly, the NON_TERMINAL_ETYPE section
  100. //
  101. { NOFNCTBL, NOSIZE, CALLPAL_OP, NO_FUNC, ALPHA_CALLPAL, NON_TERMINAL_ETYPE },
  102. { NOFNCTBL, NOSIZE, ARITH_OP, NO_FUNC, ALPHA_OPERATE, NON_TERMINAL_ETYPE },
  103. { NOFNCTBL, NOSIZE, BIT_OP, NO_FUNC, ALPHA_OPERATE, NON_TERMINAL_ETYPE },
  104. { NOFNCTBL, NOSIZE, BYTE_OP, NO_FUNC, ALPHA_OPERATE, NON_TERMINAL_ETYPE },
  105. { NOFNCTBL, NOSIZE, MUL_OP, NO_FUNC, ALPHA_OPERATE, NON_TERMINAL_ETYPE },
  106. { NOFNCTBL, NOSIZE, SEXT_OP, NO_FUNC, ALPHA_OPERATE, NON_TERMINAL_ETYPE },
  107. { NOFNCTBL, NOSIZE, MEMSPC_OP, NO_FUNC, ALPHA_MEMSPC, NON_TERMINAL_ETYPE },
  108. { NOFNCTBL, NOSIZE, JMP_OP, NO_FUNC, ALPHA_JUMP, NON_TERMINAL_ETYPE },
  109. { NOFNCTBL, NOSIZE, VAXFP_OP, NO_FUNC, ALPHA_FP_OPERATE, NON_TERMINAL_ETYPE },
  110. { NOFNCTBL, NOSIZE, IEEEFP_OP, NO_FUNC, ALPHA_FP_OPERATE, NON_TERMINAL_ETYPE },
  111. { NOFNCTBL, NOSIZE, FPOP_OP, NO_FUNC, ALPHA_FP_OPERATE, NON_TERMINAL_ETYPE },
  112. //
  113. // Thirdly, the TERMINAL_ETYPE section
  114. // (everything from here on has an instruction name)
  115. //
  116. { szLda, ParseIntMemory, LDA_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  117. { szLdah, ParseIntMemory, LDAH_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  118. { szLdbu, ParseIntMemory, LDBU_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  119. { szLdwu, ParseIntMemory, LDWU_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  120. { szLdl, ParseIntMemory, LDL_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  121. { szLdq, ParseIntMemory, LDQ_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  122. { szLdf, ParseFltMemory, LDF_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  123. { szLdg, ParseFltMemory, LDG_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  124. { szLds, ParseFltMemory, LDS_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  125. { szLdt, ParseFltMemory, LDT_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  126. { szLdq_u, ParseIntMemory, LDQ_U_OP,NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  127. { szLdl_l, ParseIntMemory, LDL_L_OP,NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  128. { szLdq_l, ParseIntMemory, LDQ_L_OP,NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  129. { szStb, ParseIntMemory, STB_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  130. { szStw, ParseIntMemory, STW_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  131. { szStl, ParseIntMemory, STL_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  132. { szStq, ParseIntMemory, STQ_OP, NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  133. { szStf, ParseFltMemory, STF_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  134. { szStg, ParseFltMemory, STG_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  135. { szSts, ParseFltMemory, STS_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  136. { szStt, ParseFltMemory, STT_OP, NO_FUNC, ALPHA_FP_MEMORY, TERMINAL_ETYPE },
  137. { szStq_u, ParseIntMemory, STQ_U_OP,NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  138. { szStl_c, ParseIntMemory, STL_C_OP,NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  139. { szStq_c, ParseIntMemory, STQ_C_OP,NO_FUNC, ALPHA_MEMORY, TERMINAL_ETYPE },
  140. { szBeq, ParseIntBranch, BEQ_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  141. { szBne, ParseIntBranch, BNE_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  142. { szBlt, ParseIntBranch, BLT_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  143. { szBle, ParseIntBranch, BLE_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  144. { szBgt, ParseIntBranch, BGT_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  145. { szBge, ParseIntBranch, BGE_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  146. { szBlbc, ParseIntBranch, BLBC_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  147. { szBlbs, ParseIntBranch, BLBS_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  148. { szBr, ParseIntBranch, BR_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  149. { szBsr, ParseIntBranch, BSR_OP, NO_FUNC, ALPHA_BRANCH, TERMINAL_ETYPE },
  150. { szFbeq, ParseFltBranch, FBEQ_OP, NO_FUNC, ALPHA_FP_BRANCH, TERMINAL_ETYPE },
  151. { szFbne, ParseFltBranch, FBNE_OP, NO_FUNC, ALPHA_FP_BRANCH, TERMINAL_ETYPE },
  152. { szFblt, ParseFltBranch, FBLT_OP, NO_FUNC, ALPHA_FP_BRANCH, TERMINAL_ETYPE },
  153. { szFble, ParseFltBranch, FBLE_OP, NO_FUNC, ALPHA_FP_BRANCH, TERMINAL_ETYPE },
  154. { szFbgt, ParseFltBranch, FBGT_OP, NO_FUNC, ALPHA_FP_BRANCH, TERMINAL_ETYPE },
  155. { szFbge, ParseFltBranch, FBGE_OP, NO_FUNC, ALPHA_FP_BRANCH, TERMINAL_ETYPE },
  156. { "REI", ParseUnknown, PAL1B_OP, NO_FUNC, ALPHA_EV4_REI, TERMINAL_ETYPE},
  157. { "HW_LD", ParseUnknown, PAL1E_OP, NO_FUNC, ALPHA_EV4_MEM, TERMINAL_ETYPE},
  158. { "HW_ST", ParseUnknown, PAL1F_OP, NO_FUNC, ALPHA_EV4_MEM, TERMINAL_ETYPE},
  159. //
  160. // Fourthly, (and finally) the FUNCTION_ETYPE section
  161. // (opcode searches needn't include this section)
  162. //
  163. //
  164. // The memory-special functions
  165. //
  166. { szMb, ParseMemSpec, MEMSPC_OP, MB_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  167. { szWmb, ParseMemSpec, MEMSPC_OP, WMB_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  168. { szMb2, ParseMemSpec, MEMSPC_OP, MB2_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  169. { szMb3, ParseMemSpec, MEMSPC_OP, MB3_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  170. { szFetch,ParseMemSpec, MEMSPC_OP, FETCH_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  171. { szFetch_m,ParseMemSpec,MEMSPC_OP,FETCH_M_FUNC,ALPHA_MEMSPC,FUNCTION_ETYPE },
  172. { szRs, ParseMemSpec, MEMSPC_OP, RS_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  173. { szTrapb,ParseMemSpec, MEMSPC_OP, TRAPB_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  174. { szExcb, ParseMemSpec, MEMSPC_OP, EXCB_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  175. { szRpcc, ParseMemSpec, MEMSPC_OP, RPCC_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  176. { szRc, ParseMemSpec, MEMSPC_OP, RC_FUNC, ALPHA_MEMSPC, FUNCTION_ETYPE },
  177. //
  178. // The jump functions
  179. //
  180. { szJmp, ParseJump, JMP_OP, JMP_FUNC, ALPHA_JUMP, FUNCTION_ETYPE },
  181. { szJsr, ParseJump, JMP_OP, JSR_FUNC, ALPHA_JUMP, FUNCTION_ETYPE },
  182. { szRet, ParseJump, JMP_OP, RET_FUNC, ALPHA_JUMP, FUNCTION_ETYPE },
  183. { szJsr_co, ParseJump, JMP_OP, JSR_CO_FUNC, ALPHA_JUMP, FUNCTION_ETYPE },
  184. //
  185. // The arithmetic ops, which are ALPHA_OPERATE
  186. //
  187. { szAddl, ParseIntOp, ARITH_OP, ADDL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  188. { szAddlv, ParseIntOp, ARITH_OP, ADDLV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  189. { szAddq, ParseIntOp, ARITH_OP, ADDQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  190. { szAddqv, ParseIntOp, ARITH_OP, ADDQV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  191. { szSubl, ParseIntOp, ARITH_OP, SUBL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  192. { szSublv, ParseIntOp, ARITH_OP, SUBLV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  193. { szSubq, ParseIntOp, ARITH_OP, SUBQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  194. { szSubqv, ParseIntOp, ARITH_OP, SUBQV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  195. { szCmpeq, ParseIntOp, ARITH_OP, CMPEQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  196. { szCmplt, ParseIntOp, ARITH_OP, CMPLT_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  197. { szCmple, ParseIntOp, ARITH_OP, CMPLE_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  198. { szCmpult, ParseIntOp, ARITH_OP, CMPULT_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  199. { szCmpule, ParseIntOp, ARITH_OP, CMPULE_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  200. { szCmpbge, ParseIntOp, ARITH_OP, CMPBGE_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  201. { szS4addl, ParseIntOp, ARITH_OP, S4ADDL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  202. { szS4addq, ParseIntOp, ARITH_OP, S4ADDQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  203. { szS4subl, ParseIntOp, ARITH_OP, S4SUBL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  204. { szS4subq, ParseIntOp, ARITH_OP, S4SUBQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  205. { szS8addl, ParseIntOp, ARITH_OP, S8ADDL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  206. { szS8addq, ParseIntOp, ARITH_OP, S8ADDQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  207. { szS8subl, ParseIntOp, ARITH_OP, S8SUBL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  208. { szS8subq, ParseIntOp, ARITH_OP, S8SUBQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  209. //
  210. // The bit ops, which are ALPHA_OPERATE
  211. //
  212. { szAnd, ParseIntOp, BIT_OP, AND_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  213. { szBic, ParseIntOp, BIT_OP, BIC_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  214. { szBis, ParseIntOp, BIT_OP, BIS_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  215. { szOrnot, ParseIntOp, BIT_OP, ORNOT_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  216. { szXor, ParseIntOp, BIT_OP, XOR_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  217. { szEqv, ParseIntOp, BIT_OP, EQV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  218. { szCmoveq, ParseIntOp, BIT_OP, CMOVEQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  219. { szCmovne, ParseIntOp, BIT_OP, CMOVNE_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  220. { szCmovlbs, ParseIntOp, BIT_OP, CMOVLBS_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  221. { szCmovlt, ParseIntOp, BIT_OP, CMOVLT_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  222. { szCmovge, ParseIntOp, BIT_OP, CMOVGE_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  223. { szCmovlbc, ParseIntOp, BIT_OP, CMOVLBC_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  224. { szCmovle, ParseIntOp, BIT_OP, CMOVLE_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  225. { szCmovgt, ParseIntOp, BIT_OP, CMOVGT_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  226. //
  227. // The byte ops, which are ALPHA_OPERATE
  228. //
  229. { szSll, ParseIntOp, BYTE_OP, SLL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  230. { szSra, ParseIntOp, BYTE_OP, SRA_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  231. { szSrl, ParseIntOp, BYTE_OP, SRL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  232. { szExtbl, ParseIntOp, BYTE_OP, EXTBL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  233. { szExtwl, ParseIntOp, BYTE_OP, EXTWL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  234. { szExtll, ParseIntOp, BYTE_OP, EXTLL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  235. { szExtql, ParseIntOp, BYTE_OP, EXTQL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  236. { szExtwh, ParseIntOp, BYTE_OP, EXTWH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  237. { szExtlh, ParseIntOp, BYTE_OP, EXTLH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  238. { szExtqh, ParseIntOp, BYTE_OP, EXTQH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  239. { szInsbl, ParseIntOp, BYTE_OP, INSBL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  240. { szInswl, ParseIntOp, BYTE_OP, INSWL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  241. { szInsll, ParseIntOp, BYTE_OP, INSLL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  242. { szInsql, ParseIntOp, BYTE_OP, INSQL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  243. { szInswh, ParseIntOp, BYTE_OP, INSWH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  244. { szInslh, ParseIntOp, BYTE_OP, INSLH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  245. { szInsqh, ParseIntOp, BYTE_OP, INSQH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  246. { szMskbl, ParseIntOp, BYTE_OP, MSKBL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  247. { szMskwl, ParseIntOp, BYTE_OP, MSKWL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  248. { szMskll, ParseIntOp, BYTE_OP, MSKLL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  249. { szMskql, ParseIntOp, BYTE_OP, MSKQL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  250. { szMskwh, ParseIntOp, BYTE_OP, MSKWH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  251. { szMsklh, ParseIntOp, BYTE_OP, MSKLH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  252. { szMskqh, ParseIntOp, BYTE_OP, MSKQH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  253. { szZap, ParseIntOp, BYTE_OP, ZAP_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  254. { szZapnot, ParseIntOp, BYTE_OP, ZAPNOT_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  255. //
  256. // The multiply ops, which are ALPHA_OPERATE
  257. //
  258. { szMull, ParseIntOp, MUL_OP, MULL_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  259. { szMulqv, ParseIntOp, MUL_OP, MULQV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  260. { szMullv, ParseIntOp, MUL_OP, MULLV_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  261. { szUmulh, ParseIntOp, MUL_OP, UMULH_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  262. { szMulq, ParseIntOp, MUL_OP, MULQ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  263. //
  264. // The sign extend ops, which are ALPHA_OPERATE, but only have an
  265. // rb and rc field.
  266. //
  267. { szSextb, ParseIntOp, SEXT_OP, SEXTB_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  268. { szSextw, ParseIntOp, SEXT_OP, SEXTW_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  269. { szCtpop, ParseIntOp, SEXT_OP, CTPOP_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  270. { szCtlz, ParseIntOp, SEXT_OP, CTLZ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  271. { szCttz, ParseIntOp, SEXT_OP, CTTZ_FUNC, ALPHA_OPERATE, FUNCTION_ETYPE },
  272. //
  273. // The call pal functions
  274. //
  275. { szBpt, ParsePal, CALLPAL_OP, BPT_FUNC,
  276. ALPHA_CALLPAL, FUNCTION_ETYPE },
  277. { szCallsys, ParsePal, CALLPAL_OP, CALLSYS_FUNC,
  278. ALPHA_CALLPAL, FUNCTION_ETYPE },
  279. { szImb, ParsePal, CALLPAL_OP, IMB_FUNC,
  280. ALPHA_CALLPAL, FUNCTION_ETYPE },
  281. { szRdteb, ParsePal, CALLPAL_OP, RDTEB_FUNC,
  282. ALPHA_CALLPAL, FUNCTION_ETYPE },
  283. { szGentrap, ParsePal, CALLPAL_OP, GENTRAP_FUNC,
  284. ALPHA_CALLPAL, FUNCTION_ETYPE },
  285. { szKbpt, ParsePal, CALLPAL_OP, KBPT_FUNC,
  286. ALPHA_CALLPAL, FUNCTION_ETYPE },
  287. { szCallKD, ParsePal, CALLPAL_OP, CALLKD_FUNC,
  288. ALPHA_CALLPAL, FUNCTION_ETYPE },
  289. { szRdteb64, ParsePal, CALLPAL_OP, RDTEB64_FUNC,
  290. ALPHA_CALLPAL, FUNCTION_ETYPE },
  291. { szHalt, ParsePal, CALLPAL_OP, HALT_FUNC,
  292. ALPHA_CALLPAL, FUNCTION_ETYPE },
  293. { szRestart, ParsePal, CALLPAL_OP, RESTART_FUNC,
  294. ALPHA_CALLPAL, FUNCTION_ETYPE },
  295. { szDraina, ParsePal, CALLPAL_OP, DRAINA_FUNC,
  296. ALPHA_CALLPAL, FUNCTION_ETYPE },
  297. { szInitpal, ParsePal, CALLPAL_OP, INITPAL_FUNC,
  298. ALPHA_CALLPAL, FUNCTION_ETYPE },
  299. { szWrentry, ParsePal, CALLPAL_OP, WRENTRY_FUNC,
  300. ALPHA_CALLPAL, FUNCTION_ETYPE },
  301. { szSwpirql, ParsePal, CALLPAL_OP, SWPIRQL_FUNC,
  302. ALPHA_CALLPAL, FUNCTION_ETYPE },
  303. { szRdirql, ParsePal, CALLPAL_OP, RDIRQL_FUNC,
  304. ALPHA_CALLPAL, FUNCTION_ETYPE },
  305. { szDi, ParsePal, CALLPAL_OP, DI_FUNC,
  306. ALPHA_CALLPAL, FUNCTION_ETYPE },
  307. { szEi, ParsePal, CALLPAL_OP, EI_FUNC,
  308. ALPHA_CALLPAL, FUNCTION_ETYPE },
  309. { szSwppal, ParsePal, CALLPAL_OP, SWPPAL_FUNC,
  310. ALPHA_CALLPAL, FUNCTION_ETYPE },
  311. { szSsir, ParsePal, CALLPAL_OP, SSIR_FUNC,
  312. ALPHA_CALLPAL, FUNCTION_ETYPE },
  313. { szCsir, ParsePal, CALLPAL_OP, CSIR_FUNC,
  314. ALPHA_CALLPAL, FUNCTION_ETYPE },
  315. { szRfe, ParsePal, CALLPAL_OP, RFE_FUNC,
  316. ALPHA_CALLPAL, FUNCTION_ETYPE },
  317. { szRetsys, ParsePal, CALLPAL_OP, RETSYS_FUNC,
  318. ALPHA_CALLPAL, FUNCTION_ETYPE },
  319. { szSwpctx, ParsePal, CALLPAL_OP, SWPCTX_FUNC,
  320. ALPHA_CALLPAL, FUNCTION_ETYPE },
  321. { szSwpprocess, ParsePal, CALLPAL_OP, SWPPROCESS_FUNC,
  322. ALPHA_CALLPAL, FUNCTION_ETYPE },
  323. { szRdmces, ParsePal, CALLPAL_OP, RDMCES_FUNC,
  324. ALPHA_CALLPAL, FUNCTION_ETYPE },
  325. { szWrmces, ParsePal, CALLPAL_OP, WRMCES_FUNC,
  326. ALPHA_CALLPAL, FUNCTION_ETYPE },
  327. { szTbia, ParsePal, CALLPAL_OP, TBIA_FUNC,
  328. ALPHA_CALLPAL, FUNCTION_ETYPE },
  329. { szTbis, ParsePal, CALLPAL_OP, TBIS_FUNC,
  330. ALPHA_CALLPAL, FUNCTION_ETYPE },
  331. { szDtbis, ParsePal, CALLPAL_OP, DTBIS_FUNC,
  332. ALPHA_CALLPAL, FUNCTION_ETYPE },
  333. { szRdksp, ParsePal, CALLPAL_OP, RDKSP_FUNC,
  334. ALPHA_CALLPAL, FUNCTION_ETYPE },
  335. { szSwpksp, ParsePal, CALLPAL_OP, SWPKSP_FUNC,
  336. ALPHA_CALLPAL, FUNCTION_ETYPE },
  337. { szRdpsr, ParsePal, CALLPAL_OP, RDPSR_FUNC,
  338. ALPHA_CALLPAL, FUNCTION_ETYPE },
  339. { szRdpcr, ParsePal, CALLPAL_OP, RDPCR_FUNC,
  340. ALPHA_CALLPAL, FUNCTION_ETYPE },
  341. { szRdthread, ParsePal, CALLPAL_OP, RDTHREAD_FUNC,
  342. ALPHA_CALLPAL, FUNCTION_ETYPE },
  343. { szRdcounters, ParsePal, CALLPAL_OP, RDCOUNTERS_FUNC,
  344. ALPHA_CALLPAL, FUNCTION_ETYPE },
  345. { szRdstate, ParsePal, CALLPAL_OP, RDSTATE_FUNC,
  346. ALPHA_CALLPAL, FUNCTION_ETYPE },
  347. { szInitpcr, ParsePal, CALLPAL_OP, INITPCR_FUNC,
  348. ALPHA_CALLPAL, FUNCTION_ETYPE },
  349. { szWrperfmon, ParsePal, CALLPAL_OP, WRPERFMON_FUNC,
  350. ALPHA_CALLPAL, FUNCTION_ETYPE },
  351. { szMt, ParsePal, CALLPAL_OP, MTPR_OP,
  352. ALPHA_CALLPAL, FUNCTION_ETYPE },
  353. { szMf, ParsePal, CALLPAL_OP, MFPR_OP,
  354. ALPHA_CALLPAL, FUNCTION_ETYPE },
  355. { szHwld, ParsePal, CALLPAL_OP, HWLD_OP,
  356. ALPHA_CALLPAL, FUNCTION_ETYPE },
  357. { szHwst, ParsePal, CALLPAL_OP, HWST_OP,
  358. ALPHA_CALLPAL, FUNCTION_ETYPE },
  359. { szRei, ParsePal, CALLPAL_OP, REI_OP,
  360. ALPHA_CALLPAL, FUNCTION_ETYPE },
  361. //
  362. // The VAX Floating point functions
  363. //
  364. { szAddf, ParseUnknown, VAXFP_OP, ADDF_FUNC,
  365. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  366. { szCvtdg, ParseUnknown, VAXFP_OP, CVTDG_FUNC,
  367. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  368. { szAddg, ParseUnknown, VAXFP_OP, ADDG_FUNC,
  369. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  370. { szCmpgeq, ParseUnknown, VAXFP_OP, CMPGEQ_FUNC,
  371. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  372. { szCmpglt, ParseUnknown, VAXFP_OP, CMPGLT_FUNC,
  373. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  374. { szCmpgle, ParseUnknown, VAXFP_OP, CMPGLE_FUNC,
  375. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  376. { szCvtgf, ParseUnknown, VAXFP_OP, CVTGF_FUNC,
  377. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  378. { szCvtgd, ParseUnknown, VAXFP_OP, CVTGD_FUNC,
  379. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  380. { szCvtqf, ParseUnknown, VAXFP_OP, CVTQF_FUNC,
  381. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  382. { szCvtqg, ParseUnknown, VAXFP_OP, CVTQG_FUNC,
  383. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  384. { szDivf, ParseUnknown, VAXFP_OP, DIVF_FUNC,
  385. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  386. { szDivg, ParseUnknown, VAXFP_OP, DIVG_FUNC,
  387. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  388. { szMulf, ParseUnknown, VAXFP_OP, MULF_FUNC,
  389. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  390. { szMulg, ParseUnknown, VAXFP_OP, MULG_FUNC,
  391. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  392. { szSubf, ParseUnknown, VAXFP_OP, SUBF_FUNC,
  393. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  394. { szSubg, ParseUnknown, VAXFP_OP, SUBG_FUNC,
  395. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  396. { szCvtgq, ParseUnknown, VAXFP_OP, CVTGQ_FUNC,
  397. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  398. //
  399. // The IEEE Floating point functions
  400. //
  401. { szAdds, ParseUnknown, IEEEFP_OP, ADDS_FUNC,
  402. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  403. { szSubs, ParseUnknown, IEEEFP_OP, SUBS_FUNC,
  404. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  405. { szMuls, ParseUnknown, IEEEFP_OP, MULS_FUNC,
  406. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  407. { szDivs, ParseUnknown, IEEEFP_OP, DIVS_FUNC,
  408. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  409. { szAddt, ParseUnknown, IEEEFP_OP, ADDT_FUNC,
  410. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  411. { szSubt, ParseUnknown, IEEEFP_OP, SUBT_FUNC,
  412. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  413. { szMult, ParseUnknown, IEEEFP_OP, MULT_FUNC,
  414. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  415. { szDivt, ParseUnknown, IEEEFP_OP, DIVT_FUNC,
  416. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  417. { szCmptun, ParseUnknown, IEEEFP_OP, CMPTUN_FUNC,
  418. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  419. { szCmpteq, ParseUnknown, IEEEFP_OP, CMPTEQ_FUNC,
  420. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  421. { szCmptlt, ParseUnknown, IEEEFP_OP, CMPTLT_FUNC,
  422. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  423. { szCmptle, ParseUnknown, IEEEFP_OP, CMPTLE_FUNC,
  424. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  425. { szCvtts, ParseUnknown, IEEEFP_OP, CVTTS_FUNC,
  426. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  427. { szCvttq, ParseUnknown, IEEEFP_OP, CVTTQ_FUNC,
  428. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  429. { szCvtqs, ParseUnknown, IEEEFP_OP, CVTQS_FUNC,
  430. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  431. { szCvtqt, ParseUnknown, IEEEFP_OP, CVTQT_FUNC,
  432. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  433. { szCvtst, ParseUnknown, IEEEFP_OP, CVTST_FUNC,
  434. ALPHA_FP_CONVERT, FUNCTION_ETYPE },
  435. { szCvtsts, ParseUnknown, IEEEFP_OP, CVTST_S_FUNC,
  436. ALPHA_FP_CONVERT, FUNCTION_ETYPE },
  437. //
  438. // The Common Floating point functions
  439. //
  440. { szCvtlq, ParseUnknown, FPOP_OP, CVTLQ_FUNC,
  441. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  442. { szCpys, ParseUnknown, FPOP_OP, CPYS_FUNC,
  443. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  444. { szCpysn, ParseUnknown, FPOP_OP, CPYSN_FUNC,
  445. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  446. { szCpyse, ParseUnknown, FPOP_OP, CPYSE_FUNC,
  447. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  448. { szMt_fpcr, ParseUnknown, FPOP_OP, MT_FPCR_FUNC,
  449. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  450. { szMf_fpcr, ParseUnknown, FPOP_OP, MF_FPCR_FUNC,
  451. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  452. { szFcmoveq, ParseUnknown, FPOP_OP, FCMOVEQ_FUNC,
  453. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  454. { szFcmovne, ParseUnknown, FPOP_OP, FCMOVNE_FUNC,
  455. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  456. { szFcmovlt, ParseUnknown, FPOP_OP, FCMOVLT_FUNC,
  457. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  458. { szFcmovge, ParseUnknown, FPOP_OP, FCMOVGE_FUNC,
  459. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  460. { szFcmovle, ParseUnknown, FPOP_OP, FCMOVLE_FUNC,
  461. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  462. { szFcmovgt, ParseUnknown, FPOP_OP, FCMOVGT_FUNC,
  463. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  464. { szCvtql, ParseUnknown, FPOP_OP, CVTQL_FUNC,
  465. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  466. { szCvtqlv, ParseUnknown, FPOP_OP, CVTQLV_FUNC,
  467. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  468. { szCvtqlsv, ParseUnknown, FPOP_OP, CVTQLSV_FUNC,
  469. ALPHA_FP_OPERATE, FUNCTION_ETYPE },
  470. }; // end of opTable
  471. #define SEARCHNUM sizeof(opTable) / sizeof(OPTBLENTRY)
  472. //
  473. // Here are the tables of Floating Point flags.
  474. //
  475. FPFLAGS ConvertFlags[] = {
  476. { NONE_FLAGS, NONE_FLAGS_STR },
  477. { C_FLAGS, C_FLAGS_STR },
  478. { V_FLAGS, V_FLAGS_STR },
  479. { VC_FLAGS, VC_FLAGS_STR },
  480. { SV_FLAGS, SV_FLAGS_STR },
  481. { SVC_FLAGS, SVC_FLAGS_STR },
  482. { SVI_FLAGS, SVI_FLAGS_STR },
  483. { SVIC_FLAGS, SVIC_FLAGS_STR },
  484. { D_FLAGS, D_FLAGS_STR },
  485. { VD_FLAGS, VD_FLAGS_STR },
  486. { SVD_FLAGS, SVD_FLAGS_STR },
  487. { SVID_FLAGS, SVID_FLAGS_STR },
  488. { M_FLAGS, M_FLAGS_STR },
  489. { VM_FLAGS, VM_FLAGS_STR },
  490. { SVM_FLAGS, SVM_FLAGS_STR },
  491. { SVIM_FLAGS, SVIM_FLAGS_STR },
  492. { S_FLAGS, S_FLAGS_STR },
  493. { SC_FLAGS, SC_FLAGS_STR },
  494. { FPFLAGS_NOT_AN_ENTRY, "" }
  495. };
  496. FPFLAGS FloatOpFlags[] = {
  497. { C_FLAGS, C_FLAGS_STR },
  498. { M_FLAGS, M_FLAGS_STR },
  499. { NONE_FLAGS, NONE_FLAGS_STR },
  500. { D_FLAGS, D_FLAGS_STR },
  501. { UC_FLAGS, UC_FLAGS_STR },
  502. { UM_FLAGS, UM_FLAGS_STR },
  503. { U_FLAGS, U_FLAGS_STR },
  504. { UD_FLAGS, UD_FLAGS_STR },
  505. { SC_FLAGS, SC_FLAGS_STR },
  506. { S_FLAGS, S_FLAGS_STR },
  507. { SUC_FLAGS, SUC_FLAGS_STR },
  508. { SUM_FLAGS, SUM_FLAGS_STR },
  509. { SU_FLAGS, SU_FLAGS_STR },
  510. { SUD_FLAGS, SUD_FLAGS_STR },
  511. { SUIC_FLAGS, SUIC_FLAGS_STR },
  512. { SUIM_FLAGS, SUIM_FLAGS_STR },
  513. { SUI_FLAGS, SUI_FLAGS_STR },
  514. { SUID_FLAGS, SUID_FLAGS_STR },
  515. { FPFLAGS_NOT_AN_ENTRY, "" }
  516. };
  517. /*** findNameEntry - find POPTBLENTRY based on name
  518. *
  519. * Purpose:
  520. * Search the opTable for a match with the token
  521. * pointed by *pszOp. Must search through the
  522. * TERMINAL and the FUNCTION tables
  523. *
  524. * Input:
  525. * *pszOp - string to search as mnemonic
  526. *
  527. * Returns:
  528. * Pointer to entry in the opTable
  529. *
  530. *************************************************************************/
  531. POPTBLENTRY
  532. findStringEntry (PSTR pszOp)
  533. {
  534. POPTBLENTRY pEntry;
  535. for (pEntry = TerminalTab;
  536. pEntry < &TerminalTab[TerminalTabSize];
  537. pEntry++) {
  538. if (!strcmp(pszOp, pEntry->pszAlphaName))
  539. return(pEntry);
  540. }
  541. for (pEntry = FunctionTab;
  542. pEntry < &FunctionTab[FunctionTabSize];
  543. pEntry++) {
  544. if (!strcmp(pszOp, pEntry->pszAlphaName))
  545. return(pEntry);
  546. }
  547. return((POPTBLENTRY)-1);
  548. }
  549. /* findOpCodeEntry - find POPTBLENTRY based on opcode
  550. *
  551. * Purpose:
  552. * Search the opTable for a match with the token
  553. * pointed by *pszOp. Must search through the
  554. * INVALID, TERMINAL and NON_TERMINAL tables
  555. *
  556. * Input:
  557. * pOpEntry - pointer to NON_TERMINAL_ETYPE in opTable
  558. * function - the function value to be looked up
  559. *
  560. * Output:
  561. * pointer to string mnemonic for the function
  562. *
  563. ***********************************************************************/
  564. POPTBLENTRY
  565. findOpCodeEntry(ULONG opcode)
  566. {
  567. POPTBLENTRY pEntry;
  568. for (pEntry = TerminalTab;
  569. pEntry < &TerminalTab[TerminalTabSize];
  570. pEntry++) {
  571. if (pEntry->opCode == opcode)
  572. return(pEntry);
  573. }
  574. for (pEntry = NonTerminalTab;
  575. pEntry < &NonTerminalTab[NonTerminalTabSize];
  576. pEntry++) {
  577. if (pEntry->opCode == opcode)
  578. return(pEntry);
  579. }
  580. for (pEntry = InvalidTab;
  581. pEntry < &InvalidTab[InvalidTabSize];
  582. pEntry++) {
  583. if (pEntry->opCode == opcode)
  584. return(pEntry);
  585. }
  586. return((POPTBLENTRY)-1);
  587. }
  588. /*** findNonTerminalEntry - find pointer to set of functions
  589. *
  590. * Purpose:
  591. * This routine finds the entry in the table which the is
  592. * nonterminal entry for an opcode.
  593. *
  594. * Input:
  595. * The type of function that is interesting
  596. *
  597. * Output:
  598. * Pointer to the nonterminal entry in opTable
  599. *
  600. * Errors:
  601. * If the entry is not found, a message is printed, and the
  602. * routine exits.
  603. *
  604. * Exceptions:
  605. * None.
  606. *
  607. * Note:
  608. * This routine is called BEFORE NonTerminalTable is established!
  609. * (it's used to set up these tables, in fact).
  610. *
  611. *************************************************************************/
  612. POPTBLENTRY
  613. findNonTerminalEntry(ULONG opCode)
  614. {
  615. ULONG index;
  616. for ( index = 0 ; index < SEARCHNUM; index++ ) {
  617. if ( ( opTable[index].eType == NON_TERMINAL_ETYPE ) &&
  618. ( opTable[index].opCode == opCode ) ) {
  619. return(&opTable[index]);
  620. }
  621. }
  622. dprintf("NonTerminalEntry for opCode %d\n not found in opTable\n",
  623. opCode);
  624. return NULL;
  625. }
  626. /* findFuncName - get string name for a function
  627. *
  628. * Purpose:
  629. * to get function name, given the function number, and a
  630. * pointer to the opTable entry for the NON_TERMINAL_ETYPE
  631. * opcode associated with the function
  632. *
  633. * Input:
  634. * pOpEntry - pointer to NON_TERMINAL_ETYPE in opTable
  635. * function - the function value to be looked up
  636. *
  637. * Output:
  638. * pointer to string mnemonic for the function
  639. *
  640. ***********************************************************************/
  641. char *
  642. findFuncName(POPTBLENTRY pEntry, ULONG function)
  643. {
  644. int cIndex;
  645. POPTBLENTRY pFncEntry;
  646. pFncEntry = pEntry->funcTable;
  647. cIndex = (int)pEntry->funcTableSize;
  648. //
  649. // make sure that this entry pts to a function table
  650. //
  651. if (pEntry->eType != NON_TERMINAL_ETYPE) {
  652. VerbOut("pEntry %N invalid in getFuncName\n", pEntry);
  653. return("???");
  654. }
  655. #if 0
  656. VerbOut("getFuncName: pOpEntry %N function %08x\n",
  657. pEntry, function);
  658. VerbOut("pFncEntry %N cIndex %08x\n",
  659. pFncEntry, function);
  660. #endif
  661. while(cIndex-- > 0) {
  662. if (function == pFncEntry->funcCode)
  663. return(pFncEntry->pszAlphaName);
  664. pFncEntry++;
  665. };
  666. return("???");
  667. }
  668. /** findFlagName - get the string associated with a flag
  669. *
  670. * Purpose - return a string associated with the flags for a
  671. * floating point instruction
  672. *
  673. * Input:
  674. * flag - the flags on the opcode
  675. * opcode - the opcode; if it's Cvt*, we use different flags
  676. *
  677. * Output:
  678. * pointer to string describing flags, or "/???"
  679. *
  680. ***************/
  681. char *
  682. findFlagName(ULONG flag, ULONG function)
  683. {
  684. PFPFLAGS table;
  685. if (function == CVTQL_FUNC) {
  686. switch (flag) {
  687. case C_FLAGS:
  688. return "";
  689. case VC_FLAGS:
  690. return "/v";
  691. case SVC_FLAGS:
  692. return "/sv";
  693. }
  694. }
  695. if ((function == CVTTQ_FUNC) || (function == CVTGQ_FUNC)) {
  696. table = ConvertFlags;
  697. } else {
  698. table = FloatOpFlags;
  699. }
  700. while (table->flags != FPFLAGS_NOT_AN_ENTRY) {
  701. if (table->flags == flag) {
  702. return(table->flagname);
  703. }
  704. table++;
  705. }
  706. // no match found
  707. //
  708. return("/???");
  709. }
  710. /*** opTableInit - initialize fields used in and with the opTable
  711. *
  712. * Purpose:
  713. * This routine is called once, and sets up pointers to the
  714. * subtables embedded in the opTable, such as AddOpTab, and
  715. * sizes for these subtables. It also checks that all like
  716. * instructions are grouped together in the table, which is
  717. * the only requirement on it.
  718. *
  719. * Input:
  720. * None.
  721. *
  722. * Output:
  723. * None.
  724. *
  725. * Errors:
  726. * If the table is not properly organized (four types separated,
  727. * and the functions for a single opcode grouped), this prints a
  728. * messages and fails
  729. *
  730. * Exceptions:
  731. * None.
  732. *
  733. *************************************************************************/
  734. HRESULT
  735. opTableInit(void)
  736. {
  737. ULONG typesDone[4] = {0,0,0,0};
  738. ULONG palDone, arithDone, bitDone, byteDone, jmpDone;
  739. ULONG fpopDone, vaxDone, IEEEDone, mulDone, sextDone, memSpcDone;
  740. ULONG index;
  741. POPTBLENTRY entry;
  742. ENTRY_TYPE curType = NOT_AN_ETYPE;
  743. ULONG curFunc = NO_FUNC; // OPCODE field in func entry
  744. //
  745. // To set the end of the table, and its size, without having
  746. // nested case statements, maintain pointers to the entry and
  747. // function tables we are currently walking through
  748. //
  749. PULONG curTypeSize, curFuncSize;
  750. POPTBLENTRY * curTypeTable, * curFuncTable;
  751. //
  752. // these will be reset before they are needed, but not before
  753. // they are used.
  754. //
  755. curTypeTable = (POPTBLENTRY *)&curTypeTable;
  756. curTypeSize = (PULONG)&curTypeSize;
  757. curFuncTable = (POPTBLENTRY *)&curFuncTable;
  758. curFuncSize = (PULONG)&curFuncSize;
  759. palDone = arithDone = bitDone = byteDone = jmpDone = 0;
  760. fpopDone = vaxDone = IEEEDone = mulDone = sextDone = memSpcDone = 0;
  761. for (index = 0 ; index < SEARCHNUM; index++) {
  762. entry = &opTable[index];
  763. switch(entry->eType) {
  764. case INVALID_ETYPE:
  765. if (curType == entry->eType)
  766. continue;
  767. //
  768. // The entries must be together; if this is a
  769. // new type, we must never have seen it before
  770. //
  771. if (typesDone[INVALID_ETYPE]) {
  772. ErrOut("Invalid table format: duplicate start of ");
  773. ErrOut("INVALID_ETYPE at index %d\n", index);
  774. return E_FAIL;
  775. }
  776. //
  777. // Finish off the old tables
  778. //
  779. *curTypeSize = (ULONG)(entry - *curTypeTable);
  780. if (curType == FUNCTION_ETYPE) {
  781. *curFuncSize = (ULONG)(entry - *curFuncTable);
  782. }
  783. //
  784. // Set up the new table
  785. //
  786. InvalidTab = entry;
  787. curTypeSize = &InvalidTabSize;
  788. curTypeTable = &InvalidTab;
  789. curType = INVALID_ETYPE;
  790. typesDone[INVALID_ETYPE] = 1;
  791. break;
  792. case NON_TERMINAL_ETYPE:
  793. if (curType == entry->eType)
  794. continue;
  795. if (typesDone[NON_TERMINAL_ETYPE]) {
  796. ErrOut("Invalid table format: duplicate start of ");
  797. ErrOut("NON_TERMINAL_ETYPE at index %d\n", index);
  798. return E_FAIL;
  799. }
  800. *curTypeSize = (ULONG)(entry - *curTypeTable);
  801. if (curType == FUNCTION_ETYPE) {
  802. *curFuncSize = (ULONG)(entry - *curFuncTable);
  803. }
  804. NonTerminalTab = entry;
  805. curTypeSize = &NonTerminalTabSize;
  806. curTypeTable = &NonTerminalTab;
  807. curType = NON_TERMINAL_ETYPE;
  808. typesDone[NON_TERMINAL_ETYPE] = 1;
  809. break;
  810. case TERMINAL_ETYPE:
  811. if (curType == entry->eType)
  812. continue;
  813. if (typesDone[TERMINAL_ETYPE]) {
  814. ErrOut("Invalid table format: duplicate start of ");
  815. ErrOut("TERMINAL_ETYPE at index %d\n", index);
  816. return E_FAIL;
  817. }
  818. *curTypeSize = (ULONG)(entry - *curTypeTable);
  819. if (curType == FUNCTION_ETYPE) {
  820. *curFuncSize = (ULONG)(entry - *curFuncTable);
  821. }
  822. TerminalTab = entry;
  823. curTypeSize = &TerminalTabSize;
  824. curTypeTable = &TerminalTab;
  825. curType = TERMINAL_ETYPE;
  826. typesDone[TERMINAL_ETYPE] = 1;
  827. break;
  828. case FUNCTION_ETYPE:
  829. if (entry->opCode == curFunc)
  830. continue;
  831. //
  832. // Take care of a new eType table; this exactly
  833. // parallels the three cases above (*_ETYPE)
  834. //
  835. if (curType != FUNCTION_ETYPE) {
  836. if (typesDone[FUNCTION_ETYPE]) {
  837. ErrOut("Invalid table format: duplicate start of ");
  838. ErrOut("FUNCTION_ETYPE at index %d\n", index);
  839. return E_FAIL;
  840. }
  841. *curTypeSize = (ULONG)(entry - *curTypeTable);
  842. FunctionTab = entry;
  843. curTypeSize = &FunctionTabSize;
  844. curTypeTable = &FunctionTab;
  845. curType = FUNCTION_ETYPE;
  846. typesDone[FUNCTION_ETYPE] = 1;
  847. }
  848. //
  849. // Next, handle a new function table when this is a new
  850. // function (==> when this is the first entry in the
  851. // FunctionTab)
  852. //
  853. switch(entry->opCode) {
  854. POPTBLENTRY e;
  855. case CALLPAL_OP:
  856. if (palDone) {
  857. ErrOut("Invalid table format: duplicate start of ");
  858. ErrOut("CALLPAL_OP at index %d\n", index);
  859. return E_FAIL;
  860. }
  861. *curFuncSize = (ULONG)(entry - *curFuncTable);
  862. e = findNonTerminalEntry(CALLPAL_OP);
  863. if (e == NULL) {
  864. return E_FAIL;
  865. }
  866. e->funcTable = entry;
  867. curFuncSize = &(e->funcTableSize);
  868. curFuncTable = &(e->funcTable);
  869. curFunc = CALLPAL_OP;
  870. palDone = 1;
  871. break;
  872. case ARITH_OP:
  873. if (arithDone) {
  874. ErrOut("Invalid table format: duplicate start of ");
  875. ErrOut("ARITH_OP at index %d\n", index);
  876. return E_FAIL;
  877. }
  878. *curFuncSize = (ULONG)(entry - *curFuncTable);
  879. e = findNonTerminalEntry(ARITH_OP);
  880. if (e == NULL) {
  881. return E_FAIL;
  882. }
  883. e->funcTable = entry;
  884. curFuncSize = &(e->funcTableSize);
  885. curFuncTable = &(e->funcTable);
  886. curFunc = ARITH_OP;
  887. arithDone = 1;
  888. break;
  889. case BIT_OP:
  890. if (bitDone) {
  891. ErrOut("Invalid table format: duplicate start of ");
  892. ErrOut("BIT_OP at index %d\n", index);
  893. return E_FAIL;
  894. }
  895. *curFuncSize = (ULONG)(entry - *curFuncTable);
  896. e = findNonTerminalEntry(BIT_OP);
  897. if (e == NULL) {
  898. return E_FAIL;
  899. }
  900. e->funcTable = entry;
  901. curFuncSize = &(e->funcTableSize);
  902. curFuncTable = &(e->funcTable);
  903. curFunc = BIT_OP;
  904. bitDone = 1;
  905. break;
  906. case BYTE_OP:
  907. if (byteDone) {
  908. ErrOut("Invalid table format: duplicate start of ");
  909. ErrOut("BYTE_OP at index %d\n", index);
  910. return E_FAIL;
  911. }
  912. *curFuncSize = (ULONG)(entry - *curFuncTable);
  913. e = findNonTerminalEntry(BYTE_OP);
  914. if (e == NULL) {
  915. return E_FAIL;
  916. }
  917. e->funcTable = entry;
  918. curFuncSize = &(e->funcTableSize);
  919. curFuncTable = &(e->funcTable);
  920. curFunc = BYTE_OP;
  921. byteDone = 1;
  922. break;
  923. case MUL_OP:
  924. if (mulDone) {
  925. ErrOut("Invalid table format: duplicate start of ");
  926. ErrOut("MUL_OP at index %d\n", index);
  927. return E_FAIL;
  928. }
  929. *curFuncSize = (ULONG)(entry - *curFuncTable);
  930. e = findNonTerminalEntry(MUL_OP);
  931. if (e == NULL) {
  932. return E_FAIL;
  933. }
  934. e->funcTable = entry;
  935. curFuncSize = &(e->funcTableSize);
  936. curFuncTable = &(e->funcTable);
  937. curFunc = MUL_OP;
  938. mulDone = 1;
  939. break;
  940. case SEXT_OP:
  941. if (sextDone) {
  942. ErrOut("Invalid table format: duplicate start of ");
  943. ErrOut("SEXT_OP at index %d\n", index);
  944. return E_FAIL;
  945. }
  946. *curFuncSize = (ULONG)(entry - *curFuncTable);
  947. e = findNonTerminalEntry(SEXT_OP);
  948. if (e == NULL) {
  949. return E_FAIL;
  950. }
  951. e->funcTable = entry;
  952. curFuncSize = &(e->funcTableSize);
  953. curFuncTable = &(e->funcTable);
  954. curFunc = SEXT_OP;
  955. sextDone = 1;
  956. break;
  957. case MEMSPC_OP:
  958. if (memSpcDone) {
  959. ErrOut("Invalid table format: duplicate start of ");
  960. ErrOut("MEMSPC_OP at index %d\n", index);
  961. return E_FAIL;
  962. }
  963. *curFuncSize = (ULONG)(entry - *curFuncTable);
  964. e = findNonTerminalEntry(MEMSPC_OP);
  965. if (e == NULL) {
  966. return E_FAIL;
  967. }
  968. e->funcTable = entry;
  969. curFuncSize = &(e->funcTableSize);
  970. curFuncTable = &(e->funcTable);
  971. curFunc = MEMSPC_OP;
  972. memSpcDone = 1;
  973. break;
  974. case JMP_OP:
  975. if (jmpDone) {
  976. ErrOut("Invalid table format: duplicate start of ");
  977. ErrOut("JMP_OP at index %d\n", index);
  978. return E_FAIL;
  979. }
  980. *curFuncSize = (ULONG)(entry - *curFuncTable);
  981. e = findNonTerminalEntry(JMP_OP);
  982. if (e == NULL) {
  983. return E_FAIL;
  984. }
  985. e->funcTable = entry;
  986. curFuncSize = &(e->funcTableSize);
  987. curFuncTable = &(e->funcTable);
  988. curFunc = JMP_OP;
  989. jmpDone = 1;
  990. break;
  991. case VAXFP_OP:
  992. if (vaxDone) {
  993. ErrOut("Invalid table format: duplicate start of ");
  994. ErrOut("VAXFP_OP at index %d\n", index);
  995. return E_FAIL;
  996. }
  997. *curFuncSize = (ULONG)(entry - *curFuncTable);
  998. e = findNonTerminalEntry(VAXFP_OP);
  999. if (e == NULL) {
  1000. return E_FAIL;
  1001. }
  1002. e->funcTable = entry;
  1003. curFuncSize = &(e->funcTableSize);
  1004. curFuncTable = &(e->funcTable);
  1005. curFunc = VAXFP_OP;
  1006. vaxDone = 1;
  1007. break;
  1008. case IEEEFP_OP:
  1009. if (IEEEDone) {
  1010. ErrOut("Invalid table format: duplicate start of ");
  1011. ErrOut("IEEEFP_OP at index %d\n", index);
  1012. return E_FAIL;
  1013. }
  1014. *curFuncSize = (ULONG)(entry - *curFuncTable);
  1015. e = findNonTerminalEntry(IEEEFP_OP);
  1016. if (e == NULL) {
  1017. return E_FAIL;
  1018. }
  1019. e->funcTable = entry;
  1020. curFuncSize = &(e->funcTableSize);
  1021. curFuncTable = &(e->funcTable);
  1022. curFunc = IEEEFP_OP;
  1023. IEEEDone = 1;
  1024. break;
  1025. case FPOP_OP:
  1026. if (fpopDone) {
  1027. ErrOut("Invalid table format: duplicate start of ");
  1028. ErrOut("FPOP_OP at index %d\n", index);
  1029. return E_FAIL;
  1030. }
  1031. *curFuncSize = (ULONG)(entry - *curFuncTable);
  1032. e = findNonTerminalEntry(FPOP_OP);
  1033. if (e == NULL) {
  1034. return E_FAIL;
  1035. }
  1036. e->funcTable = entry;
  1037. curFuncSize = &(e->funcTableSize);
  1038. curFuncTable = &(e->funcTable);
  1039. curFunc = FPOP_OP;
  1040. fpopDone = 1;
  1041. break;
  1042. default:
  1043. ErrOut("Unexpected function type %d at %08x for %s\n",
  1044. entry->eType, entry, entry->pszAlphaName);
  1045. return E_FAIL;
  1046. } // end of Function table switch
  1047. break;
  1048. default:
  1049. ErrOut("Unexpected entry type %d at %08x for %s\n",
  1050. entry->eType, entry, entry->pszAlphaName);
  1051. return E_FAIL;
  1052. } // end of etype table switch
  1053. } // end of For switch
  1054. //
  1055. // close out the size of the last tables
  1056. //
  1057. if (curType == FUNCTION_ETYPE) {
  1058. *curFuncSize = (ULONG)(&opTable[SEARCHNUM] - *curFuncTable);
  1059. }
  1060. *curTypeSize = (ULONG)(&opTable[SEARCHNUM] - *curTypeTable);
  1061. #if 0
  1062. if (fVerboseOutput) {
  1063. printTable();
  1064. }
  1065. #endif
  1066. return S_OK;
  1067. } // end of opTableInit
  1068. void printTable(void)
  1069. {
  1070. ULONG i;
  1071. POPTBLENTRY e;
  1072. for (i = 0 ; i < SEARCHNUM; i++) {
  1073. e = &opTable[i];
  1074. switch (e->eType) {
  1075. case INVALID_ETYPE:
  1076. dprintf("%12s %08x op: %4d %8d %2d INVALID\n",
  1077. e->pszAlphaName, e->parsFunc, e->opCode, e->funcCode, e->iType);
  1078. break;
  1079. case TERMINAL_ETYPE:
  1080. dprintf("%12s %08x op: %4d %8d %2d TERMINAL\n",
  1081. e->pszAlphaName, e->parsFunc, e->opCode, e->funcCode, e->iType);
  1082. break;
  1083. case FUNCTION_ETYPE:
  1084. dprintf("%12s %08x op: %4d %8d %2d FUNCTION\n",
  1085. e->pszAlphaName, e->parsFunc, e->opCode, e->funcCode, e->iType);
  1086. break;
  1087. case NON_TERMINAL_ETYPE:
  1088. dprintf("%12x %08x op: %4d %8d %2d NON_TERMINAL\n",
  1089. e->funcTable, e->funcTableSize,
  1090. e->opCode, e->funcCode, e->iType);
  1091. break;
  1092. }
  1093. }
  1094. dprintf("InvalidTab %08x InvalidTabSize %03x\n",
  1095. InvalidTab, InvalidTabSize);
  1096. dprintf("TerminalTab %08x TerminalTabSize %03x\n",
  1097. TerminalTab, TerminalTabSize);
  1098. dprintf("NonTerminalTab %08x NonTerminalTabSize %03x\n",
  1099. NonTerminalTab, NonTerminalTabSize);
  1100. dprintf("FunctionTab %08x FunctionTabSize %03x\n",
  1101. FunctionTab, FunctionTabSize);
  1102. }