Enums.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. #define ICODEMASK 0x0FF00FF /* Masks off parser flags */
  85. };
  86. /* Types of icodes */
  87. enum icodeType
  88. {
  89. NOT_SCANNED = 0, // not even scanned yet
  90. LOW_LEVEL, // low-level icode
  91. HIGH_LEVEL // high-level icode
  92. };
  93. /* LOW_LEVEL icode opcodes */
  94. enum llIcode
  95. {
  96. //iINVALID,
  97. iCBW, /* 0 */
  98. iAAA,
  99. iAAD,
  100. iAAM,
  101. iAAS,
  102. iADC,
  103. iADD,
  104. iAND,
  105. iBOUND,
  106. iCALL,
  107. iCALLF, /* 10 */
  108. iCLC,
  109. iCLD,
  110. iCLI,
  111. iCMC,
  112. iCMP,
  113. iCMPS,
  114. iREPNE_CMPS,
  115. iREPE_CMPS,
  116. iDAA,
  117. iDAS, /* 20 */
  118. iDEC,
  119. iDIV,
  120. iENTER,
  121. iESC,
  122. iHLT,
  123. iIDIV,
  124. iIMUL,
  125. iIN,
  126. iINC,
  127. iINS, /* 30 */
  128. iREP_INS,
  129. iINT,
  130. iIRET,
  131. iJB,
  132. iJBE,
  133. iJAE,
  134. iJA,
  135. iJE,
  136. iJNE,
  137. iJL, /* 40 */
  138. iJGE,
  139. iJLE,
  140. iJG,
  141. iJS,
  142. iJNS,
  143. iJO,
  144. iJNO,
  145. iJP,
  146. iJNP,
  147. iJCXZ, /* 50 */
  148. iJMP,
  149. iJMPF,
  150. iLAHF,
  151. iLDS,
  152. iLEA,
  153. iLEAVE,
  154. iLES,
  155. iLOCK,
  156. iLODS,
  157. iREP_LODS, /* 60 */
  158. iLOOP,
  159. iLOOPE,
  160. iLOOPNE,
  161. iMOV, /* 64 */
  162. iMOVS,
  163. iREP_MOVS,
  164. iMUL, /* 67 */
  165. iNEG,
  166. iNOT,
  167. iOR, /* 70 */
  168. iOUT,
  169. iOUTS,
  170. iREP_OUTS,
  171. iPOP,
  172. iPOPA,
  173. iPOPF,
  174. iPUSH,
  175. iPUSHA,
  176. iPUSHF,
  177. iRCL, /* 80 */
  178. iRCR,
  179. iROL,
  180. iROR,
  181. iRET, /* 84 */
  182. iRETF,
  183. iSAHF,
  184. iSAR,
  185. iSHL,
  186. iSHR,
  187. iSBB, /* 90 */
  188. iSCAS,
  189. iREPNE_SCAS,
  190. iREPE_SCAS,
  191. iSIGNEX,
  192. iSTC,
  193. iSTD,
  194. iSTI,
  195. iSTOS,
  196. iREP_STOS,
  197. iSUB, /* 100 */
  198. iTEST,
  199. iWAIT,
  200. iXCHG,
  201. iXLAT,
  202. iXOR,
  203. iINTO,
  204. iNOP,
  205. iREPNE,
  206. iREPE,
  207. iMOD /* 110 */
  208. };
  209. /* Conditional Expression enumeration nodes and operators */
  210. enum condNodeType
  211. {
  212. UNKNOWN_OP=0,
  213. BOOLEAN_OP, /* condOps */
  214. NEGATION, /* not (2's complement) */
  215. ADDRESSOF, /* addressOf (&) */
  216. DEREFERENCE, /* contents of (*) */
  217. IDENTIFIER, /* {register | local | param | constant | global} */
  218. /* The following are only available to C programs */
  219. POST_INC, /* ++ (post increment) */
  220. POST_DEC, /* -- (post decrement) */
  221. PRE_INC, /* ++ (pre increment) */
  222. PRE_DEC /* -- (pre decrement) */
  223. } ;
  224. /* Enumeration to determine whether pIcode points to the high or low part
  225. * of a long number */
  226. enum hlFirst
  227. {
  228. HIGH_FIRST, /* High value is first */
  229. LOW_FIRST /* Low value is first */
  230. };
  231. /* HIGH_LEVEL icodes opcodes */
  232. enum hlIcode
  233. {
  234. HLI_INVALID=0,
  235. HLI_ASSIGN, /* := */
  236. HLI_CALL, /* Call procedure */
  237. HLI_JCOND, /* Conditional jump */
  238. HLI_RET, /* Return from procedure */
  239. /* pseudo high-level icodes */
  240. HLI_POP, /* Pop expression */
  241. HLI_PUSH /* Push expression */
  242. } ;
  243. /* Type definitions used in the decompiled program */
  244. enum hlType
  245. {
  246. TYPE_UNKNOWN = 0, /* unknown so far */
  247. TYPE_BYTE_SIGN, /* signed byte (8 bits) */
  248. TYPE_BYTE_UNSIGN, /* unsigned byte */
  249. TYPE_WORD_SIGN, /* signed word (16 bits) */
  250. TYPE_WORD_UNSIGN, /* unsigned word (16 bits) */
  251. TYPE_LONG_SIGN, /* signed long (32 bits) */
  252. TYPE_LONG_UNSIGN, /* unsigned long (32 bits) */
  253. TYPE_RECORD, /* record structure */
  254. TYPE_PTR, /* pointer (32 bit ptr) */
  255. TYPE_STR, /* string */
  256. TYPE_CONST, /* constant (any type) */
  257. TYPE_FLOAT, /* floating point */
  258. TYPE_DOUBLE /* double precision float */
  259. };
  260. /* Operand is defined, used or both flag */
  261. enum operDu
  262. {
  263. eDEF=0x10, /* Operand is defined */
  264. eUSE=0x100, /* Operand is used */
  265. USE_DEF, /* Operand is used and defined */
  266. NONE /* No operation is required on this operand */
  267. };
  268. /* LOW_LEVEL icode, DU flag bits */
  269. enum eDuFlags
  270. {
  271. Cf=1,
  272. Sf=2,
  273. Zf=4,
  274. Df=8
  275. };