summaryrefslogtreecommitdiffstats
path: root/src/emu/opc.h
blob: 179f7b2024f070d30d817d18a80396d833d381b1 (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
#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|
 *  comparison:
 *     |010|xxx|aaaaa|bbbbb|0000000000000000|
 *  load & store:
 *     |011|xxx|aaaaa|bbbbb|cccccccccccccccc|
 *  jump:
 *     |100|xxx|aaaaa|00000|cccccccccccccccc|
 *  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

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

#endif