xcore.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #ifndef CAPSTONE_XCORE_H
  2. #define CAPSTONE_XCORE_H
  3. /* Capstone Disassembly Engine */
  4. /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2014-2015 */
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #include "platform.h"
  9. #ifdef _MSC_VER
  10. #pragma warning(disable:4201)
  11. #endif
  12. /// Operand type for instruction's operands
  13. typedef enum xcore_op_type {
  14. XCORE_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized).
  15. XCORE_OP_REG, ///< = CS_OP_REG (Register operand).
  16. XCORE_OP_IMM, ///< = CS_OP_IMM (Immediate operand).
  17. XCORE_OP_MEM, ///< = CS_OP_MEM (Memory operand).
  18. } xcore_op_type;
  19. /// XCore registers
  20. typedef enum xcore_reg {
  21. XCORE_REG_INVALID = 0,
  22. XCORE_REG_CP,
  23. XCORE_REG_DP,
  24. XCORE_REG_LR,
  25. XCORE_REG_SP,
  26. XCORE_REG_R0,
  27. XCORE_REG_R1,
  28. XCORE_REG_R2,
  29. XCORE_REG_R3,
  30. XCORE_REG_R4,
  31. XCORE_REG_R5,
  32. XCORE_REG_R6,
  33. XCORE_REG_R7,
  34. XCORE_REG_R8,
  35. XCORE_REG_R9,
  36. XCORE_REG_R10,
  37. XCORE_REG_R11,
  38. // pseudo registers
  39. XCORE_REG_PC, ///< pc
  40. // internal thread registers
  41. // see The-XMOS-XS1-Architecture(X7879A).pdf
  42. XCORE_REG_SCP, ///< save pc
  43. XCORE_REG_SSR, //< save status
  44. XCORE_REG_ET, //< exception type
  45. XCORE_REG_ED, //< exception data
  46. XCORE_REG_SED, //< save exception data
  47. XCORE_REG_KEP, //< kernel entry pointer
  48. XCORE_REG_KSP, //< kernel stack pointer
  49. XCORE_REG_ID, //< thread ID
  50. XCORE_REG_ENDING, // <-- mark the end of the list of registers
  51. } xcore_reg;
  52. /// Instruction's operand referring to memory
  53. /// This is associated with XCORE_OP_MEM operand type above
  54. typedef struct xcore_op_mem {
  55. uint8_t base; ///< base register, can be safely interpreted as
  56. ///< a value of type `xcore_reg`, but it is only
  57. ///< one byte wide
  58. uint8_t index; ///< index register, same conditions apply here
  59. int32_t disp; ///< displacement/offset value
  60. int direct; ///< +1: forward, -1: backward
  61. } xcore_op_mem;
  62. /// Instruction operand
  63. typedef struct cs_xcore_op {
  64. xcore_op_type type; ///< operand type
  65. union {
  66. xcore_reg reg; ///< register value for REG operand
  67. int32_t imm; ///< immediate value for IMM operand
  68. xcore_op_mem mem; ///< base/disp value for MEM operand
  69. };
  70. } cs_xcore_op;
  71. /// Instruction structure
  72. typedef struct cs_xcore {
  73. /// Number of operands of this instruction,
  74. /// or 0 when instruction has no operand.
  75. uint8_t op_count;
  76. cs_xcore_op operands[8]; ///< operands for this instruction.
  77. } cs_xcore;
  78. /// XCore instruction
  79. typedef enum xcore_insn {
  80. XCORE_INS_INVALID = 0,
  81. XCORE_INS_ADD,
  82. XCORE_INS_ANDNOT,
  83. XCORE_INS_AND,
  84. XCORE_INS_ASHR,
  85. XCORE_INS_BAU,
  86. XCORE_INS_BITREV,
  87. XCORE_INS_BLA,
  88. XCORE_INS_BLAT,
  89. XCORE_INS_BL,
  90. XCORE_INS_BF,
  91. XCORE_INS_BT,
  92. XCORE_INS_BU,
  93. XCORE_INS_BRU,
  94. XCORE_INS_BYTEREV,
  95. XCORE_INS_CHKCT,
  96. XCORE_INS_CLRE,
  97. XCORE_INS_CLRPT,
  98. XCORE_INS_CLRSR,
  99. XCORE_INS_CLZ,
  100. XCORE_INS_CRC8,
  101. XCORE_INS_CRC32,
  102. XCORE_INS_DCALL,
  103. XCORE_INS_DENTSP,
  104. XCORE_INS_DGETREG,
  105. XCORE_INS_DIVS,
  106. XCORE_INS_DIVU,
  107. XCORE_INS_DRESTSP,
  108. XCORE_INS_DRET,
  109. XCORE_INS_ECALLF,
  110. XCORE_INS_ECALLT,
  111. XCORE_INS_EDU,
  112. XCORE_INS_EEF,
  113. XCORE_INS_EET,
  114. XCORE_INS_EEU,
  115. XCORE_INS_ENDIN,
  116. XCORE_INS_ENTSP,
  117. XCORE_INS_EQ,
  118. XCORE_INS_EXTDP,
  119. XCORE_INS_EXTSP,
  120. XCORE_INS_FREER,
  121. XCORE_INS_FREET,
  122. XCORE_INS_GETD,
  123. XCORE_INS_GET,
  124. XCORE_INS_GETN,
  125. XCORE_INS_GETR,
  126. XCORE_INS_GETSR,
  127. XCORE_INS_GETST,
  128. XCORE_INS_GETTS,
  129. XCORE_INS_INCT,
  130. XCORE_INS_INIT,
  131. XCORE_INS_INPW,
  132. XCORE_INS_INSHR,
  133. XCORE_INS_INT,
  134. XCORE_INS_IN,
  135. XCORE_INS_KCALL,
  136. XCORE_INS_KENTSP,
  137. XCORE_INS_KRESTSP,
  138. XCORE_INS_KRET,
  139. XCORE_INS_LADD,
  140. XCORE_INS_LD16S,
  141. XCORE_INS_LD8U,
  142. XCORE_INS_LDA16,
  143. XCORE_INS_LDAP,
  144. XCORE_INS_LDAW,
  145. XCORE_INS_LDC,
  146. XCORE_INS_LDW,
  147. XCORE_INS_LDIVU,
  148. XCORE_INS_LMUL,
  149. XCORE_INS_LSS,
  150. XCORE_INS_LSUB,
  151. XCORE_INS_LSU,
  152. XCORE_INS_MACCS,
  153. XCORE_INS_MACCU,
  154. XCORE_INS_MJOIN,
  155. XCORE_INS_MKMSK,
  156. XCORE_INS_MSYNC,
  157. XCORE_INS_MUL,
  158. XCORE_INS_NEG,
  159. XCORE_INS_NOT,
  160. XCORE_INS_OR,
  161. XCORE_INS_OUTCT,
  162. XCORE_INS_OUTPW,
  163. XCORE_INS_OUTSHR,
  164. XCORE_INS_OUTT,
  165. XCORE_INS_OUT,
  166. XCORE_INS_PEEK,
  167. XCORE_INS_REMS,
  168. XCORE_INS_REMU,
  169. XCORE_INS_RETSP,
  170. XCORE_INS_SETCLK,
  171. XCORE_INS_SET,
  172. XCORE_INS_SETC,
  173. XCORE_INS_SETD,
  174. XCORE_INS_SETEV,
  175. XCORE_INS_SETN,
  176. XCORE_INS_SETPSC,
  177. XCORE_INS_SETPT,
  178. XCORE_INS_SETRDY,
  179. XCORE_INS_SETSR,
  180. XCORE_INS_SETTW,
  181. XCORE_INS_SETV,
  182. XCORE_INS_SEXT,
  183. XCORE_INS_SHL,
  184. XCORE_INS_SHR,
  185. XCORE_INS_SSYNC,
  186. XCORE_INS_ST16,
  187. XCORE_INS_ST8,
  188. XCORE_INS_STW,
  189. XCORE_INS_SUB,
  190. XCORE_INS_SYNCR,
  191. XCORE_INS_TESTCT,
  192. XCORE_INS_TESTLCL,
  193. XCORE_INS_TESTWCT,
  194. XCORE_INS_TSETMR,
  195. XCORE_INS_START,
  196. XCORE_INS_WAITEF,
  197. XCORE_INS_WAITET,
  198. XCORE_INS_WAITEU,
  199. XCORE_INS_XOR,
  200. XCORE_INS_ZEXT,
  201. XCORE_INS_ENDING, // <-- mark the end of the list of instructions
  202. } xcore_insn;
  203. /// Group of XCore instructions
  204. typedef enum xcore_insn_group {
  205. XCORE_GRP_INVALID = 0, ///< = CS_GRP_INVALID
  206. // Generic groups
  207. // all jump instructions (conditional+direct+indirect jumps)
  208. XCORE_GRP_JUMP, ///< = CS_GRP_JUMP
  209. XCORE_GRP_ENDING, // <-- mark the end of the list of groups
  210. } xcore_insn_group;
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214. #endif