Enums.h 7.0 KB

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