Enums.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. #pragma once
  2. /* Machine registers */
  3. enum eReg
  4. {
  5. rAX = 1, /* These are numbered relative to real 8086 */
  6. rCX = 2,
  7. rDX = 3,
  8. rBX = 4,
  9. rSP = 5,
  10. rBP = 6,
  11. rSI = 7,
  12. rDI = 8,
  13. rES = 9,
  14. rCS = 10,
  15. rSS = 11,
  16. rDS = 12,
  17. rAL = 13,
  18. rCL = 14,
  19. rDL = 15,
  20. rBL = 16,
  21. rAH = 17,
  22. rCH = 18,
  23. rDH = 19,
  24. rBH = 20,
  25. rTMP= 21, /* temp register for DIV/IDIV/MOD */
  26. INDEXBASE = 22 /* Indexed modes go from INDEXBASE to INDEXBASE+7 */
  27. };
  28. /* Register types */
  29. enum regType
  30. {
  31. BYTE_REG,
  32. WORD_REG
  33. };
  34. enum condId
  35. {
  36. GLOB_VAR, /* global variable */
  37. REGISTER, /* register */
  38. LOCAL_VAR, /* negative disp */
  39. PARAM, /* positive disp */
  40. GLOB_VAR_IDX, /* indexed global variable *//*** should merge w/glob-var*/
  41. CONSTANT, /* constant */
  42. STRING, /* string */
  43. LONG_VAR, /* long variable */
  44. FUNCTION, /* function */
  45. OTHER /* other **** tmp solution */
  46. };
  47. enum condOp
  48. {
  49. /* For conditional expressions */
  50. LESS_EQUAL = 0, /* <= */
  51. LESS, /* < */
  52. EQUAL, /* == */
  53. NOT_EQUAL, /* != */
  54. GREATER, /* > */
  55. GREATER_EQUAL, /* >= */
  56. /* For general expressions */
  57. AND, /* & */
  58. OR, /* | */
  59. XOR, /* ^ */
  60. NOT, /* ~ */ /* 1's complement */
  61. ADD, /* + */
  62. SUB, /* - */
  63. MUL, /* * */
  64. DIV, /* / */
  65. SHR, /* >> */
  66. SHL, /* << */
  67. MOD, /* % */
  68. DBL_AND, /* && */
  69. DBL_OR, /* || */
  70. DUMMY /* */
  71. };
  72. /* LOW_LEVEL operand location: source or destination */
  73. enum opLoc
  74. {
  75. SRC, /* Source operand */
  76. DST, /* Destination operand */
  77. LHS_OP /* Left-hand side operand (for HIGH_LEVEL) */
  78. };
  79. /* LOW_LEVEL icode flags */
  80. enum eLLFlags
  81. {
  82. B =0x0000001, /* uint8_t operands (value implicitly used) */
  83. I =0x0000002, /* Immed. source */
  84. NOT_HLL =0x0000004, /* Not HLL inst. */
  85. FLOAT_OP =0x0000008, /* ESC or WAIT */
  86. SEG_IMMED =0x0000010, /* Number is relocated segment value */
  87. IMPURE =0x0000020, /* Instruction modifies code */
  88. WORD_OFF =0x0000040, /* Inst has uint16_t offset ie.could be address */
  89. TERMINATES =0x0000080, /* Instruction terminates program */
  90. CASE =0x0000100, /* Label as case part of switch */
  91. SWITCH =0x0000200, /* Treat indirect JMP as switch stmt */
  92. TARGET =0x0000400, /* Jump target */
  93. SYNTHETIC =0x0000800, /* Synthetic jump instruction */
  94. NO_LABEL =0x0001000, /* Immed. jump cannot be linked to a label */
  95. NO_CODE =0x0002000, /* Hole in Icode array */
  96. SYM_USE =0x0004000, /* Instruction uses a symbol */
  97. SYM_DEF =0x0008000, /* Instruction defines a symbol */
  98. NO_SRC =0x0010000, /* Opcode takes no source */
  99. NO_OPS =0x0020000, /* Opcode takes no operands */
  100. IM_OPS =0x0040000, /* Opcode takes implicit operands */
  101. SRC_B =0x0080000, /* Source operand is uint8_t (dest is uint16_t) */
  102. #define NO_SRC_B 0xF7FFFF /* Masks off SRC_B */
  103. HLL_LABEL =0x0100000, /* Icode has a high level language label */
  104. IM_DST =0x0200000, /* Implicit DST for opcode (SIGNEX) */
  105. IM_SRC =0x0400000, /* Implicit SRC for opcode (dx:ax) */
  106. IM_TMP_DST =0x0800000, /* Implicit rTMP DST for opcode (DIV/IDIV) */
  107. JMP_ICODE =0x1000000, /* Jmp dest immed.op converted to icode index */
  108. JX_LOOP =0x2000000, /* Cond jump is part of loop conditional exp */
  109. REST_STK =0x4000000 /* Stack needs to be restored after CALL */
  110. };
  111. /* Types of icodes */
  112. enum icodeType
  113. {
  114. NOT_SCANNED = 0, /* not even scanned yet */
  115. LOW_LEVEL, /* low-level icode */
  116. HIGH_LEVEL /* high-level icode */
  117. };
  118. /* LOW_LEVEL icode opcodes */
  119. enum llIcode
  120. {
  121. iCBW, /* 0 */
  122. iAAA,
  123. iAAD,
  124. iAAM,
  125. iAAS,
  126. iADC,
  127. iADD,
  128. iAND,
  129. iBOUND,
  130. iCALL,
  131. iCALLF, /* 10 */
  132. iCLC,
  133. iCLD,
  134. iCLI,
  135. iCMC,
  136. iCMP,
  137. iCMPS,
  138. iREPNE_CMPS,
  139. iREPE_CMPS,
  140. iDAA,
  141. iDAS, /* 20 */
  142. iDEC,
  143. iDIV,
  144. iENTER,
  145. iESC,
  146. iHLT,
  147. iIDIV,
  148. iIMUL,
  149. iIN,
  150. iINC,
  151. iINS, /* 30 */
  152. iREP_INS,
  153. iINT,
  154. iIRET,
  155. iJB,
  156. iJBE,
  157. iJAE,
  158. iJA,
  159. iJE,
  160. iJNE,
  161. iJL, /* 40 */
  162. iJGE,
  163. iJLE,
  164. iJG,
  165. iJS,
  166. iJNS,
  167. iJO,
  168. iJNO,
  169. iJP,
  170. iJNP,
  171. iJCXZ, /* 50 */
  172. iJMP,
  173. iJMPF,
  174. iLAHF,
  175. iLDS,
  176. iLEA,
  177. iLEAVE,
  178. iLES,
  179. iLOCK,
  180. iLODS,
  181. iREP_LODS, /* 60 */
  182. iLOOP,
  183. iLOOPE,
  184. iLOOPNE,
  185. iMOV, /* 64 */
  186. iMOVS,
  187. iREP_MOVS,
  188. iMUL, /* 67 */
  189. iNEG,
  190. iNOT,
  191. iOR, /* 70 */
  192. iOUT,
  193. iOUTS,
  194. iREP_OUTS,
  195. iPOP,
  196. iPOPA,
  197. iPOPF,
  198. iPUSH,
  199. iPUSHA,
  200. iPUSHF,
  201. iRCL, /* 80 */
  202. iRCR,
  203. iROL,
  204. iROR,
  205. iRET, /* 84 */
  206. iRETF,
  207. iSAHF,
  208. iSAR,
  209. iSHL,
  210. iSHR,
  211. iSBB, /* 90 */
  212. iSCAS,
  213. iREPNE_SCAS,
  214. iREPE_SCAS,
  215. iSIGNEX,
  216. iSTC,
  217. iSTD,
  218. iSTI,
  219. iSTOS,
  220. iREP_STOS,
  221. iSUB, /* 100 */
  222. iTEST,
  223. iWAIT,
  224. iXCHG,
  225. iXLAT,
  226. iXOR,
  227. iINTO,
  228. iNOP,
  229. iREPNE,
  230. iREPE,
  231. iMOD /* 110 */
  232. };
  233. /* Conditional Expression enumeration nodes and operators */
  234. enum condNodeType
  235. {
  236. UNKNOWN_OP=0,
  237. BOOLEAN_OP, /* condOps */
  238. NEGATION, /* not (2's complement) */
  239. ADDRESSOF, /* addressOf (&) */
  240. DEREFERENCE, /* contents of (*) */
  241. IDENTIFIER, /* {register | local | param | constant | global} */
  242. /* The following are only available to C programs */
  243. POST_INC, /* ++ (post increment) */
  244. POST_DEC, /* -- (post decrement) */
  245. PRE_INC, /* ++ (pre increment) */
  246. PRE_DEC /* -- (pre decrement) */
  247. } ;
  248. /* Enumeration to determine whether pIcode points to the high or low part
  249. * of a long number */
  250. enum hlFirst
  251. {
  252. HIGH_FIRST, /* High value is first */
  253. LOW_FIRST /* Low value is first */
  254. };
  255. /* HIGH_LEVEL icodes opcodes */
  256. enum hlIcode
  257. {
  258. HLI_ASSIGN, /* := */
  259. HLI_CALL, /* Call procedure */
  260. HLI_JCOND, /* Conditional jump */
  261. HLI_RET, /* Return from procedure */
  262. /* pseudo high-level icodes */
  263. HLI_POP, /* Pop expression */
  264. HLI_PUSH /* Push expression */
  265. } ;
  266. /* Type definitions used in the decompiled program */
  267. enum hlType
  268. {
  269. TYPE_UNKNOWN = 0, /* unknown so far */
  270. TYPE_BYTE_SIGN, /* signed byte (8 bits) */
  271. TYPE_BYTE_UNSIGN, /* unsigned byte */
  272. TYPE_WORD_SIGN, /* signed word (16 bits) */
  273. TYPE_WORD_UNSIGN, /* unsigned word (16 bits) */
  274. TYPE_LONG_SIGN, /* signed long (32 bits) */
  275. TYPE_LONG_UNSIGN, /* unsigned long (32 bits) */
  276. TYPE_RECORD, /* record structure */
  277. TYPE_PTR, /* pointer (32 bit ptr) */
  278. TYPE_STR, /* string */
  279. TYPE_CONST, /* constant (any type) */
  280. TYPE_FLOAT, /* floating point */
  281. TYPE_DOUBLE /* double precision float */
  282. };
  283. /* Operand is defined, used or both flag */
  284. enum operDu
  285. {
  286. eDEF=0x10, /* Operand is defined */
  287. eUSE=0x100, /* Operand is used */
  288. USE_DEF, /* Operand is used and defined */
  289. NONE /* No operation is required on this operand */
  290. };