blob: 8720958301041fa86f84b1577a82faad172367b2 (
plain) (
blame)
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
|
#ifndef _OPC_H
#define _OPC_H
#include <stdint.h>
/* instructions formats:
* ---------------------
*
* arithmetic:
* |000|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|ccccccccccccc|0000000000000000000|
* logic:
* |001|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|ccccccccccccc|0000000000000000000|
* comparison:
* |010|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|00000000000000000000000000000000|
* load & store:
* |011|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|cccccccccccccccccccccccccccccccc|
* jump:
* |100|xxx|aaaaaaaaaaaaa|0000000000000|cccccccccccccccccccccccccccccccc|
* misc:
* |111|xxx|??????????????????????????????????????????????????????????|
*
*/
/* arithmetic */
#define OPC_ADD 000
#define OPC_SUB 001
#define OPC_MUL 002
#define OPC_DIV 003
#define OPC_MOD 004
/* logic */
#define OPC_AND 010
#define OPC_OR 011
/* comparison */
#define OPC_CMP 020
#define OPC_EQ 021
#define OPC_NE 022
#define OPC_LT 023
#define OPC_LE 024
#define OPC_GE 025
#define OPC_GT 026
/* load & store */
#define OPC_MOV 030
#define OPC_LW 031
#define OPC_SW 032
#define OPC_PUSH 033
#define OPC_POP 034
/* jump instructions */
#define OPC_BEZ 040
#define OPC_JMP 041
#define OPC_CALL 042
#define OPC_RET 043
/* misc */
#define OPC_SYS 070
/* one instruction is 64 bit */
typedef uint64_t inst_t;
/* conversion functions */
inst_t mnemonic2opc(const char *mnemonic);
const char *opc2mnemonic(inst_t IR);
#endif
|