-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathz80inst.h
148 lines (138 loc) · 1.89 KB
/
z80inst.h
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
Copyright 2013 Michael Pavone
This file is part of BlastEm.
BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
*/
#ifndef Z80INST_H_
#define Z80INST_H_
#include <stdint.h>
enum {
Z80_LD,
Z80_PUSH,
Z80_POP,
Z80_EX,
Z80_EXX,
Z80_LDI,
Z80_LDIR,
Z80_LDD,
Z80_LDDR,
Z80_CPI,
Z80_CPIR,
Z80_CPD,
Z80_CPDR,
Z80_ADD,
Z80_ADC,
Z80_SUB,
Z80_SBC,
Z80_AND,
Z80_OR,
Z80_XOR,
Z80_CP,
Z80_INC,
Z80_DEC,
Z80_DAA,
Z80_CPL,
Z80_NEG,
Z80_CCF,
Z80_SCF,
Z80_NOP,
Z80_HALT,
Z80_DI,
Z80_EI,
Z80_IM,
Z80_RLC,
Z80_RL,
Z80_RRC,
Z80_RR,
Z80_SLA,
Z80_SRA,
Z80_SLL,
Z80_SRL,
Z80_RLD,
Z80_RRD,
Z80_BIT,
Z80_SET,
Z80_RES,
Z80_JP,
Z80_JPCC,
Z80_JR,
Z80_JRCC,
Z80_DJNZ,
Z80_CALL,
Z80_CALLCC,
Z80_RET,
Z80_RETCC,
Z80_RETI,
Z80_RETN,
Z80_RST,
Z80_IN,
Z80_INI,
Z80_INIR,
Z80_IND,
Z80_INDR,
Z80_OUT,
Z80_OUTI,
Z80_OTIR,
Z80_OUTD,
Z80_OTDR,
Z80_USE_MAIN
};
enum {
Z80_C=0,
Z80_B,
Z80_E,
Z80_D,
Z80_L,
Z80_H,
Z80_IXL,
Z80_IXH,
Z80_IYL,
Z80_IYH,
Z80_I,
Z80_R,
Z80_A,
Z80_BC,
Z80_DE,
Z80_HL,
Z80_SP,
Z80_AF,
Z80_IX,
Z80_IY,
Z80_UNUSED
};
#define Z80_IMMED_FLAG 0x80
#define Z80_USE_IMMED (Z80_IMMED_FLAG|Z80_UNUSED)
enum {
Z80_CC_NZ,
Z80_CC_Z,
Z80_CC_NC,
Z80_CC_C,
Z80_CC_PO,
Z80_CC_PE,
Z80_CC_P,
Z80_CC_M
};
enum {
Z80_REG,
Z80_REG_INDIRECT,
Z80_IMMED,
Z80_IMMED_INDIRECT,
Z80_IX_DISPLACE,
Z80_IY_DISPLACE
};
#define Z80_DIR 0x80
typedef struct {
uint8_t op;
uint8_t reg;
uint8_t addr_mode;
uint8_t ea_reg;
uint16_t immed;
uint16_t opcode_bytes;
} z80inst;
uint8_t * z80_decode(uint8_t * istream, z80inst * decoded);
int z80_disasm(z80inst * decoded, char * dst, uint16_t address);
uint8_t z80_high_reg(uint8_t reg);
uint8_t z80_low_reg(uint8_t reg);
uint8_t z80_word_reg(uint8_t reg);
uint8_t z80_is_terminal(z80inst * inst);
#endif //Z80INST_H_