summaryrefslogtreecommitdiffstats
path: root/src/emu/opc.h
blob: 45d21a81439f7a2496f8841140b91c8daa16b015 (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
68
#ifndef _OPC_H
#define _OPC_H

#include <stdint.h>

/* instructions formats:
 * ---------------------
 *
 *  arithmetic:
 *     |000|xxx|aaaaa|bbbbb|ccccc|00000000000|
 *  logic:
 *     |001|xxx|aaaaa|bbbbb|ccccc|00000000000|
 *  load & store:
 *     |010|xxx|aaaaa|bbbbb|cccccccccccccccc|
 *  branch:
 *     |011|xxx|aaaaa|bbbbb|cccccccccccccccc|
 *  jump:
 *     |100|xxx|aaaaa|000000000000000000000|
 *  misc:
 *     |111|xxx|??????????????????????????|
 *
 */

/* arithmetic */
#define OPC_ADD  000
#define OPC_SUB  001
#define OPC_MUL  002
#define OPC_DIV  003
#define OPC_MOD  004
#define OPC_SHL  005
#define OPC_SHR  006

/* logic */
#define OPC_AND  010
#define OPC_OR   011
#define OPC_XOR  012
#define OPC_NOR  013

/* load & store */
#define OPC_MOV  020
#define OPC_LB   021
#define OPC_LH   022
#define OPC_LW   023
#define OPC_SB   024
#define OPC_SH   025
#define OPC_SW   026

/* branch instructions */
#define OPC_CMP  030
#define OPC_BEQ  031
#define OPC_BNE  032
#define OPC_BLT  033
#define OPC_BGE  034
#define OPC_BLE  035
#define OPC_BGT  036

/* jump instructions */
#define OPC_J    040
#define OPC_JAL  041

/* misc */
#define OPC_SYS  070

/* conversion functions */
uint32_t mnemonic2opc(const char *mnemonic);
const char *opc2mnemonic(uint32_t IR);

#endif