crabstone 4.0.4 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +6 -0
  3. data/README.md +24 -8
  4. data/lib/crabstone/arch/3/constants.rb +86 -0
  5. data/lib/crabstone/arch/4/constants.rb +116 -0
  6. data/lib/crabstone/arch/5/arm.rb +111 -0
  7. data/lib/crabstone/arch/5/arm64.rb +131 -0
  8. data/lib/crabstone/arch/5/arm64_const.rb +3015 -0
  9. data/lib/crabstone/arch/5/arm_const.rb +840 -0
  10. data/lib/crabstone/arch/5/bpf.rb +81 -0
  11. data/lib/crabstone/arch/5/bpf_const.rb +124 -0
  12. data/lib/crabstone/arch/5/constants.rb +155 -0
  13. data/lib/crabstone/arch/5/evm.rb +20 -0
  14. data/lib/crabstone/arch/5/evm_const.rb +161 -0
  15. data/lib/crabstone/arch/5/m680x.rb +106 -0
  16. data/lib/crabstone/arch/5/m680x_const.rb +426 -0
  17. data/lib/crabstone/arch/5/m68k.rb +129 -0
  18. data/lib/crabstone/arch/5/m68k_const.rb +496 -0
  19. data/lib/crabstone/arch/5/mips.rb +57 -0
  20. data/lib/crabstone/arch/5/mips_const.rb +869 -0
  21. data/lib/crabstone/arch/5/mos65xx.rb +52 -0
  22. data/lib/crabstone/arch/5/mos65xx_const.rb +162 -0
  23. data/lib/crabstone/arch/5/ppc.rb +69 -0
  24. data/lib/crabstone/arch/5/ppc_const.rb +2024 -0
  25. data/lib/crabstone/arch/5/riscv.rb +58 -0
  26. data/lib/crabstone/arch/5/riscv_const.rb +455 -0
  27. data/lib/crabstone/arch/5/sh.rb +72 -0
  28. data/lib/crabstone/arch/5/sh_const.rb +376 -0
  29. data/lib/crabstone/arch/5/sparc.rb +60 -0
  30. data/lib/crabstone/arch/5/sparc_const.rb +439 -0
  31. data/lib/crabstone/arch/5/sysz.rb +60 -0
  32. data/lib/crabstone/arch/5/sysz_const.rb +2532 -0
  33. data/lib/crabstone/arch/5/tms320c64x.rb +87 -0
  34. data/lib/crabstone/arch/5/tms320c64x_const.rb +287 -0
  35. data/lib/crabstone/arch/5/tricore.rb +59 -0
  36. data/lib/crabstone/arch/5/tricore_const.rb +488 -0
  37. data/lib/crabstone/arch/5/wasm.rb +81 -0
  38. data/lib/crabstone/arch/5/wasm_const.rb +201 -0
  39. data/lib/crabstone/arch/5/x86.rb +98 -0
  40. data/lib/crabstone/arch/5/x86_const.rb +1999 -0
  41. data/lib/crabstone/arch/5/xcore.rb +59 -0
  42. data/lib/crabstone/arch/5/xcore_const.rb +171 -0
  43. data/lib/crabstone/arch/extension.rb +2 -1
  44. data/lib/crabstone/arch/register.rb +1 -1
  45. data/lib/crabstone/arch.rb +6 -0
  46. data/lib/crabstone/binding/5/detail.rb +47 -0
  47. data/lib/crabstone/binding/5/instruction.rb +23 -0
  48. data/lib/crabstone/binding.rb +2 -2
  49. data/lib/crabstone/constants.rb +2 -107
  50. data/lib/crabstone/cs_version.rb +2 -3
  51. data/lib/crabstone/disassembler.rb +2 -3
  52. data/lib/crabstone/instruction.rb +0 -1
  53. data/lib/crabstone/version.rb +1 -1
  54. metadata +45 -4
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
4
+
5
+ require 'ffi'
6
+
7
+ require 'crabstone/arch/extension'
8
+ require_relative 'riscv_const'
9
+
10
+ module Crabstone
11
+ module RISCV
12
+ class OperandMemory < FFI::Struct
13
+ layout(
14
+ :base, :uint,
15
+ :disp, :long
16
+ )
17
+ end
18
+
19
+ class OperandValue < FFI::Union
20
+ layout(
21
+ :reg, :uint,
22
+ :imm, :long,
23
+ :mem, OperandMemory
24
+ )
25
+ end
26
+
27
+ class Operand < FFI::Struct
28
+ layout(
29
+ :type, :uint,
30
+ :value, OperandValue
31
+ )
32
+
33
+ include Crabstone::Extension::Operand
34
+
35
+ def reg?
36
+ self[:type] == OP_REG
37
+ end
38
+
39
+ def imm?
40
+ self[:type] == OP_IMM
41
+ end
42
+
43
+ def mem?
44
+ self[:type] == OP_MEM
45
+ end
46
+ end
47
+
48
+ class Instruction < FFI::Struct
49
+ layout(
50
+ :need_effective_addr, :bool,
51
+ :op_count, :uint8,
52
+ :operands, [Operand, 8]
53
+ )
54
+
55
+ include Crabstone::Extension::Instruction
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,455 @@
1
+ # frozen_string_literal: true
2
+
3
+ # THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
4
+
5
+ require 'crabstone/arch/register'
6
+
7
+ module Crabstone
8
+ module RISCV
9
+ OP_INVALID = 0
10
+ OP_REG = 1
11
+ OP_IMM = 2
12
+ OP_MEM = 3
13
+
14
+ REG_INVALID = 0
15
+
16
+ REG_X0 = 1
17
+ REG_ZERO = REG_X0
18
+ REG_X1 = 2
19
+ REG_RA = REG_X1
20
+ REG_X2 = 3
21
+ REG_SP = REG_X2
22
+ REG_X3 = 4
23
+ REG_GP = REG_X3
24
+ REG_X4 = 5
25
+ REG_TP = REG_X4
26
+ REG_X5 = 6
27
+ REG_T0 = REG_X5
28
+ REG_X6 = 7
29
+ REG_T1 = REG_X6
30
+ REG_X7 = 8
31
+ REG_T2 = REG_X7
32
+ REG_X8 = 9
33
+ REG_S0 = REG_X8
34
+ REG_FP = REG_X8
35
+ REG_X9 = 10
36
+ REG_S1 = REG_X9
37
+ REG_X10 = 11
38
+ REG_A0 = REG_X10
39
+ REG_X11 = 12
40
+ REG_A1 = REG_X11
41
+ REG_X12 = 13
42
+ REG_A2 = REG_X12
43
+ REG_X13 = 14
44
+ REG_A3 = REG_X13
45
+ REG_X14 = 15
46
+ REG_A4 = REG_X14
47
+ REG_X15 = 16
48
+ REG_A5 = REG_X15
49
+ REG_X16 = 17
50
+ REG_A6 = REG_X16
51
+ REG_X17 = 18
52
+ REG_A7 = REG_X17
53
+ REG_X18 = 19
54
+ REG_S2 = REG_X18
55
+ REG_X19 = 20
56
+ REG_S3 = REG_X19
57
+ REG_X20 = 21
58
+ REG_S4 = REG_X20
59
+ REG_X21 = 22
60
+ REG_S5 = REG_X21
61
+ REG_X22 = 23
62
+ REG_S6 = REG_X22
63
+ REG_X23 = 24
64
+ REG_S7 = REG_X23
65
+ REG_X24 = 25
66
+ REG_S8 = REG_X24
67
+ REG_X25 = 26
68
+ REG_S9 = REG_X25
69
+ REG_X26 = 27
70
+ REG_S10 = REG_X26
71
+ REG_X27 = 28
72
+ REG_S11 = REG_X27
73
+ REG_X28 = 29
74
+ REG_T3 = REG_X28
75
+ REG_X29 = 30
76
+ REG_T4 = REG_X29
77
+ REG_X30 = 31
78
+ REG_T5 = REG_X30
79
+ REG_X31 = 32
80
+ REG_T6 = REG_X31
81
+
82
+ REG_F0_32 = 33
83
+ REG_F0_64 = 34
84
+ REG_F1_32 = 35
85
+ REG_F1_64 = 36
86
+ REG_F2_32 = 37
87
+ REG_F2_64 = 38
88
+ REG_F3_32 = 39
89
+ REG_F3_64 = 40
90
+ REG_F4_32 = 41
91
+ REG_F4_64 = 42
92
+ REG_F5_32 = 43
93
+ REG_F5_64 = 44
94
+ REG_F6_32 = 45
95
+ REG_F6_64 = 46
96
+ REG_F7_32 = 47
97
+ REG_F7_64 = 48
98
+ REG_F8_32 = 49
99
+ REG_F8_64 = 50
100
+ REG_F9_32 = 51
101
+ REG_F9_64 = 52
102
+ REG_F10_32 = 53
103
+ REG_F10_64 = 54
104
+ REG_F11_32 = 55
105
+ REG_F11_64 = 56
106
+ REG_F12_32 = 57
107
+ REG_F12_64 = 58
108
+ REG_F13_32 = 59
109
+ REG_F13_64 = 60
110
+ REG_F14_32 = 61
111
+ REG_F14_64 = 62
112
+ REG_F15_32 = 63
113
+ REG_F15_64 = 64
114
+ REG_F16_32 = 65
115
+ REG_F16_64 = 66
116
+ REG_F17_32 = 67
117
+ REG_F17_64 = 68
118
+ REG_F18_32 = 69
119
+ REG_F18_64 = 70
120
+ REG_F19_32 = 71
121
+ REG_F19_64 = 72
122
+ REG_F20_32 = 73
123
+ REG_F20_64 = 74
124
+ REG_F21_32 = 75
125
+ REG_F21_64 = 76
126
+ REG_F22_32 = 77
127
+ REG_F22_64 = 78
128
+ REG_F23_32 = 79
129
+ REG_F23_64 = 80
130
+ REG_F24_32 = 81
131
+ REG_F24_64 = 82
132
+ REG_F25_32 = 83
133
+ REG_F25_64 = 84
134
+ REG_F26_32 = 85
135
+ REG_F26_64 = 86
136
+ REG_F27_32 = 87
137
+ REG_F27_64 = 88
138
+ REG_F28_32 = 89
139
+ REG_F28_64 = 90
140
+ REG_F29_32 = 91
141
+ REG_F29_64 = 92
142
+ REG_F30_32 = 93
143
+ REG_F30_64 = 94
144
+ REG_F31_32 = 95
145
+ REG_F31_64 = 96
146
+ REG_ENDING = 97
147
+
148
+ INS_INVALID = 0
149
+ INS_ADD = 1
150
+ INS_ADDI = 2
151
+ INS_ADDIW = 3
152
+ INS_ADDW = 4
153
+ INS_AMOADD_D = 5
154
+ INS_AMOADD_D_AQ = 6
155
+ INS_AMOADD_D_AQ_RL = 7
156
+ INS_AMOADD_D_RL = 8
157
+ INS_AMOADD_W = 9
158
+ INS_AMOADD_W_AQ = 10
159
+ INS_AMOADD_W_AQ_RL = 11
160
+ INS_AMOADD_W_RL = 12
161
+ INS_AMOAND_D = 13
162
+ INS_AMOAND_D_AQ = 14
163
+ INS_AMOAND_D_AQ_RL = 15
164
+ INS_AMOAND_D_RL = 16
165
+ INS_AMOAND_W = 17
166
+ INS_AMOAND_W_AQ = 18
167
+ INS_AMOAND_W_AQ_RL = 19
168
+ INS_AMOAND_W_RL = 20
169
+ INS_AMOMAXU_D = 21
170
+ INS_AMOMAXU_D_AQ = 22
171
+ INS_AMOMAXU_D_AQ_RL = 23
172
+ INS_AMOMAXU_D_RL = 24
173
+ INS_AMOMAXU_W = 25
174
+ INS_AMOMAXU_W_AQ = 26
175
+ INS_AMOMAXU_W_AQ_RL = 27
176
+ INS_AMOMAXU_W_RL = 28
177
+ INS_AMOMAX_D = 29
178
+ INS_AMOMAX_D_AQ = 30
179
+ INS_AMOMAX_D_AQ_RL = 31
180
+ INS_AMOMAX_D_RL = 32
181
+ INS_AMOMAX_W = 33
182
+ INS_AMOMAX_W_AQ = 34
183
+ INS_AMOMAX_W_AQ_RL = 35
184
+ INS_AMOMAX_W_RL = 36
185
+ INS_AMOMINU_D = 37
186
+ INS_AMOMINU_D_AQ = 38
187
+ INS_AMOMINU_D_AQ_RL = 39
188
+ INS_AMOMINU_D_RL = 40
189
+ INS_AMOMINU_W = 41
190
+ INS_AMOMINU_W_AQ = 42
191
+ INS_AMOMINU_W_AQ_RL = 43
192
+ INS_AMOMINU_W_RL = 44
193
+ INS_AMOMIN_D = 45
194
+ INS_AMOMIN_D_AQ = 46
195
+ INS_AMOMIN_D_AQ_RL = 47
196
+ INS_AMOMIN_D_RL = 48
197
+ INS_AMOMIN_W = 49
198
+ INS_AMOMIN_W_AQ = 50
199
+ INS_AMOMIN_W_AQ_RL = 51
200
+ INS_AMOMIN_W_RL = 52
201
+ INS_AMOOR_D = 53
202
+ INS_AMOOR_D_AQ = 54
203
+ INS_AMOOR_D_AQ_RL = 55
204
+ INS_AMOOR_D_RL = 56
205
+ INS_AMOOR_W = 57
206
+ INS_AMOOR_W_AQ = 58
207
+ INS_AMOOR_W_AQ_RL = 59
208
+ INS_AMOOR_W_RL = 60
209
+ INS_AMOSWAP_D = 61
210
+ INS_AMOSWAP_D_AQ = 62
211
+ INS_AMOSWAP_D_AQ_RL = 63
212
+ INS_AMOSWAP_D_RL = 64
213
+ INS_AMOSWAP_W = 65
214
+ INS_AMOSWAP_W_AQ = 66
215
+ INS_AMOSWAP_W_AQ_RL = 67
216
+ INS_AMOSWAP_W_RL = 68
217
+ INS_AMOXOR_D = 69
218
+ INS_AMOXOR_D_AQ = 70
219
+ INS_AMOXOR_D_AQ_RL = 71
220
+ INS_AMOXOR_D_RL = 72
221
+ INS_AMOXOR_W = 73
222
+ INS_AMOXOR_W_AQ = 74
223
+ INS_AMOXOR_W_AQ_RL = 75
224
+ INS_AMOXOR_W_RL = 76
225
+ INS_AND = 77
226
+ INS_ANDI = 78
227
+ INS_AUIPC = 79
228
+ INS_BEQ = 80
229
+ INS_BGE = 81
230
+ INS_BGEU = 82
231
+ INS_BLT = 83
232
+ INS_BLTU = 84
233
+ INS_BNE = 85
234
+ INS_CSRRC = 86
235
+ INS_CSRRCI = 87
236
+ INS_CSRRS = 88
237
+ INS_CSRRSI = 89
238
+ INS_CSRRW = 90
239
+ INS_CSRRWI = 91
240
+ INS_C_ADD = 92
241
+ INS_C_ADDI = 93
242
+ INS_C_ADDI16SP = 94
243
+ INS_C_ADDI4SPN = 95
244
+ INS_C_ADDIW = 96
245
+ INS_C_ADDW = 97
246
+ INS_C_AND = 98
247
+ INS_C_ANDI = 99
248
+ INS_C_BEQZ = 100
249
+ INS_C_BNEZ = 101
250
+ INS_C_EBREAK = 102
251
+ INS_C_FLD = 103
252
+ INS_C_FLDSP = 104
253
+ INS_C_FLW = 105
254
+ INS_C_FLWSP = 106
255
+ INS_C_FSD = 107
256
+ INS_C_FSDSP = 108
257
+ INS_C_FSW = 109
258
+ INS_C_FSWSP = 110
259
+ INS_C_J = 111
260
+ INS_C_JAL = 112
261
+ INS_C_JALR = 113
262
+ INS_C_JR = 114
263
+ INS_C_LD = 115
264
+ INS_C_LDSP = 116
265
+ INS_C_LI = 117
266
+ INS_C_LUI = 118
267
+ INS_C_LW = 119
268
+ INS_C_LWSP = 120
269
+ INS_C_MV = 121
270
+ INS_C_NOP = 122
271
+ INS_C_OR = 123
272
+ INS_C_SD = 124
273
+ INS_C_SDSP = 125
274
+ INS_C_SLLI = 126
275
+ INS_C_SRAI = 127
276
+ INS_C_SRLI = 128
277
+ INS_C_SUB = 129
278
+ INS_C_SUBW = 130
279
+ INS_C_SW = 131
280
+ INS_C_SWSP = 132
281
+ INS_C_UNIMP = 133
282
+ INS_C_XOR = 134
283
+ INS_DIV = 135
284
+ INS_DIVU = 136
285
+ INS_DIVUW = 137
286
+ INS_DIVW = 138
287
+ INS_EBREAK = 139
288
+ INS_ECALL = 140
289
+ INS_FADD_D = 141
290
+ INS_FADD_S = 142
291
+ INS_FCLASS_D = 143
292
+ INS_FCLASS_S = 144
293
+ INS_FCVT_D_L = 145
294
+ INS_FCVT_D_LU = 146
295
+ INS_FCVT_D_S = 147
296
+ INS_FCVT_D_W = 148
297
+ INS_FCVT_D_WU = 149
298
+ INS_FCVT_LU_D = 150
299
+ INS_FCVT_LU_S = 151
300
+ INS_FCVT_L_D = 152
301
+ INS_FCVT_L_S = 153
302
+ INS_FCVT_S_D = 154
303
+ INS_FCVT_S_L = 155
304
+ INS_FCVT_S_LU = 156
305
+ INS_FCVT_S_W = 157
306
+ INS_FCVT_S_WU = 158
307
+ INS_FCVT_WU_D = 159
308
+ INS_FCVT_WU_S = 160
309
+ INS_FCVT_W_D = 161
310
+ INS_FCVT_W_S = 162
311
+ INS_FDIV_D = 163
312
+ INS_FDIV_S = 164
313
+ INS_FENCE = 165
314
+ INS_FENCE_I = 166
315
+ INS_FENCE_TSO = 167
316
+ INS_FEQ_D = 168
317
+ INS_FEQ_S = 169
318
+ INS_FLD = 170
319
+ INS_FLE_D = 171
320
+ INS_FLE_S = 172
321
+ INS_FLT_D = 173
322
+ INS_FLT_S = 174
323
+ INS_FLW = 175
324
+ INS_FMADD_D = 176
325
+ INS_FMADD_S = 177
326
+ INS_FMAX_D = 178
327
+ INS_FMAX_S = 179
328
+ INS_FMIN_D = 180
329
+ INS_FMIN_S = 181
330
+ INS_FMSUB_D = 182
331
+ INS_FMSUB_S = 183
332
+ INS_FMUL_D = 184
333
+ INS_FMUL_S = 185
334
+ INS_FMV_D_X = 186
335
+ INS_FMV_W_X = 187
336
+ INS_FMV_X_D = 188
337
+ INS_FMV_X_W = 189
338
+ INS_FNMADD_D = 190
339
+ INS_FNMADD_S = 191
340
+ INS_FNMSUB_D = 192
341
+ INS_FNMSUB_S = 193
342
+ INS_FSD = 194
343
+ INS_FSGNJN_D = 195
344
+ INS_FSGNJN_S = 196
345
+ INS_FSGNJX_D = 197
346
+ INS_FSGNJX_S = 198
347
+ INS_FSGNJ_D = 199
348
+ INS_FSGNJ_S = 200
349
+ INS_FSQRT_D = 201
350
+ INS_FSQRT_S = 202
351
+ INS_FSUB_D = 203
352
+ INS_FSUB_S = 204
353
+ INS_FSW = 205
354
+ INS_JAL = 206
355
+ INS_JALR = 207
356
+ INS_LB = 208
357
+ INS_LBU = 209
358
+ INS_LD = 210
359
+ INS_LH = 211
360
+ INS_LHU = 212
361
+ INS_LR_D = 213
362
+ INS_LR_D_AQ = 214
363
+ INS_LR_D_AQ_RL = 215
364
+ INS_LR_D_RL = 216
365
+ INS_LR_W = 217
366
+ INS_LR_W_AQ = 218
367
+ INS_LR_W_AQ_RL = 219
368
+ INS_LR_W_RL = 220
369
+ INS_LUI = 221
370
+ INS_LW = 222
371
+ INS_LWU = 223
372
+ INS_MRET = 224
373
+ INS_MUL = 225
374
+ INS_MULH = 226
375
+ INS_MULHSU = 227
376
+ INS_MULHU = 228
377
+ INS_MULW = 229
378
+ INS_OR = 230
379
+ INS_ORI = 231
380
+ INS_REM = 232
381
+ INS_REMU = 233
382
+ INS_REMUW = 234
383
+ INS_REMW = 235
384
+ INS_SB = 236
385
+ INS_SC_D = 237
386
+ INS_SC_D_AQ = 238
387
+ INS_SC_D_AQ_RL = 239
388
+ INS_SC_D_RL = 240
389
+ INS_SC_W = 241
390
+ INS_SC_W_AQ = 242
391
+ INS_SC_W_AQ_RL = 243
392
+ INS_SC_W_RL = 244
393
+ INS_SD = 245
394
+ INS_SFENCE_VMA = 246
395
+ INS_SH = 247
396
+ INS_SLL = 248
397
+ INS_SLLI = 249
398
+ INS_SLLIW = 250
399
+ INS_SLLW = 251
400
+ INS_SLT = 252
401
+ INS_SLTI = 253
402
+ INS_SLTIU = 254
403
+ INS_SLTU = 255
404
+ INS_SRA = 256
405
+ INS_SRAI = 257
406
+ INS_SRAIW = 258
407
+ INS_SRAW = 259
408
+ INS_SRET = 260
409
+ INS_SRL = 261
410
+ INS_SRLI = 262
411
+ INS_SRLIW = 263
412
+ INS_SRLW = 264
413
+ INS_SUB = 265
414
+ INS_SUBW = 266
415
+ INS_SW = 267
416
+ INS_UNIMP = 268
417
+ INS_URET = 269
418
+ INS_WFI = 270
419
+ INS_XOR = 271
420
+ INS_XORI = 272
421
+ INS_ENDING = 273
422
+
423
+ GRP_INVALID = 0
424
+ GRP_JUMP = 1
425
+ GRP_CALL = 2
426
+ GRP_RET = 3
427
+ GRP_INT = 4
428
+ GRP_IRET = 5
429
+ GRP_PRIVILEGE = 6
430
+ GRP_BRANCH_RELATIVE = 7
431
+ GRP_ISRV32 = 128
432
+ GRP_ISRV64 = 129
433
+ GRP_HASSTDEXTA = 130
434
+ GRP_HASSTDEXTC = 131
435
+ GRP_HASSTDEXTD = 132
436
+ GRP_HASSTDEXTF = 133
437
+ GRP_HASSTDEXTM = 134
438
+ GRP_ISRVA = 135
439
+ GRP_ISRVC = 136
440
+ GRP_ISRVD = 137
441
+ GRP_ISRVCD = 138
442
+ GRP_ISRVF = 139
443
+ GRP_ISRV32C = 140
444
+ GRP_ISRV32CF = 141
445
+ GRP_ISRVM = 142
446
+ GRP_ISRV64A = 143
447
+ GRP_ISRV64C = 144
448
+ GRP_ISRV64D = 145
449
+ GRP_ISRV64F = 146
450
+ GRP_ISRV64M = 147
451
+ GRP_ENDING = 148
452
+
453
+ extend Register
454
+ end
455
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
4
+
5
+ require 'ffi'
6
+
7
+ require 'crabstone/arch/extension'
8
+ require_relative 'sh_const'
9
+
10
+ module Crabstone
11
+ module SH
12
+ class OperandMemory < FFI::Struct
13
+ layout(
14
+ :address, :uint,
15
+ :reg, :uint,
16
+ :disp, :uint
17
+ )
18
+ end
19
+
20
+ class OperandDsp < FFI::Struct
21
+ layout(
22
+ :insn, :uint,
23
+ :operand, [:uint, 2],
24
+ :r, [:uint, 6],
25
+ :cc, :uint,
26
+ :imm, :uint8,
27
+ :size, :int
28
+ )
29
+ end
30
+
31
+ class OperandValue < FFI::Union
32
+ layout(
33
+ :imm, :long,
34
+ :reg, :uint,
35
+ :mem, OperandMemory,
36
+ :dsp, OperandDsp
37
+ )
38
+ end
39
+
40
+ class Operand < FFI::Struct
41
+ layout(
42
+ :type, :uint,
43
+ :value, OperandValue
44
+ )
45
+
46
+ include Crabstone::Extension::Operand
47
+
48
+ def reg?
49
+ self[:type] == OP_REG
50
+ end
51
+
52
+ def imm?
53
+ self[:type] == OP_IMM
54
+ end
55
+
56
+ def mem?
57
+ self[:type] == OP_MEM
58
+ end
59
+ end
60
+
61
+ class Instruction < FFI::Struct
62
+ layout(
63
+ :insn, :uint,
64
+ :size, :uint8,
65
+ :op_count, :uint8,
66
+ :operands, [Operand, 3]
67
+ )
68
+
69
+ include Crabstone::Extension::Instruction
70
+ end
71
+ end
72
+ end