Enums.h 7.6 KB

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