aboutsummaryrefslogtreecommitdiff
path: root/tools/wasm.h
blob: 07252fc913cec4b2bcbec908bbf43cf092c6cc7d (plain)
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
#define SECTION_CUSTOM   0
#define SECTION_TYPE     1
#define SECTION_IMPORT   2
#define SECTION_FUNCTION 3
#define SECTION_TABLE    4
#define SECTION_MEMORY   5
#define SECTION_GLOBAL   6
#define SECTION_EXPORT   7
#define SECTION_START    8
#define SECTION_ELEMENT  9
#define SECTION_CODE     10
#define SECTION_DATA     11

#define VALTYPE_I32 0x7F
#define VALTYPE_I64 0x7E
#define VALTYPE_F32 0x7D
#define VALTYPE_F64 0x7C

#define EXPORT_FUNCIDX   0x00
#define EXPORT_TABLEIDX  0x01
#define EXPORT_MEMIDX    0x02
#define EXPORT_GLOBALIDX 0x03

/* WebAssembly opcodes */
#define WASM_END           0x0B
#define WASM_CALL          0x10

#define WASM_LOCAL_GET     0x20

#define WASM_I32_LOAD      0x28
#define WASM_I32_LOAD8_S   0x2C
#define WASM_I32_LOAD8_U   0x2D
#define WASM_I32_LOAD16_S  0x2E
#define WASM_I32_LOAD16_U  0x2F
#define WASM_I32_STORE     0x36
#define WASM_I32_STORE8    0x3A
#define WASM_I32_STORE16   0x3B
#define WASM_I64_STORE32   0x3E

#define WASM_I32_CONST     0x41

#define WASM_I32_ADD       0x6A
#define WASM_I32_SUB       0x6B
#define WASM_I32_MUL       0x6C
#define WASM_I32_DIV_U     0x6E