Enums.h 7.2 KB

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