forked from wargio/libvle
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvle.h
More file actions
96 lines (81 loc) · 1.37 KB
/
vle.h
File metadata and controls
96 lines (81 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* LGPL - Copyright 2017-2018 - wargio */
#ifndef LIB_PPCVLE
#define LIB_PPCVLE
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
enum field_type {
TYPE_NONE = 0,
TYPE_REG = 1,
TYPE_IMM = 2,
TYPE_MEM = 3,
TYPE_JMP = 4,
TYPE_CR = 5
};
enum op_type {
OP_TYPE_ILL,
OP_TYPE_ADD,
OP_TYPE_SUB,
OP_TYPE_MUL,
OP_TYPE_DIV,
OP_TYPE_SHR,
OP_TYPE_SHL,
OP_TYPE_ROR,
OP_TYPE_AND,
OP_TYPE_OR,
OP_TYPE_XOR,
OP_TYPE_NOR,
OP_TYPE_NOT,
OP_TYPE_IO,
OP_TYPE_LOAD,
OP_TYPE_STORE,
OP_TYPE_MOV,
OP_TYPE_CMP,
OP_TYPE_JMP,
OP_TYPE_CJMP,
OP_TYPE_CALL,
OP_TYPE_CCALL,
OP_TYPE_RJMP,
OP_TYPE_RCALL,
OP_TYPE_RET,
OP_TYPE_SYNC,
OP_TYPE_SWI,
OP_TYPE_TRAP
};
enum op_condition {
COND_AL,
COND_GE,
COND_LE,
COND_NE,
COND_VC,
COND_LT,
COND_GT,
COND_EQ,
COND_VS,
COND_NV
};
typedef struct {
const uint8_t* end;
const uint8_t* pos;
uint16_t inc;
} vle_handle;
typedef struct {
uint32_t value;
enum field_type type;
} vle_field_t;
typedef struct {
const char* name;
vle_field_t fields[10];
uint16_t n;
uint16_t size;
enum op_type op_type;
enum op_condition cond;
} vle_t;
int vle_init(vle_handle* handle, const uint8_t* buffer, const uint32_t size);
int vle_next(vle_handle* handle, vle_t* out);
void vle_snprint(char* str, int size, uint64_t addr, vle_t* instr);
#ifdef __cplusplus
}
#endif
#endif