annotate z80inst.h @ 361:946ae3749260

Fix deadlock on quit
author Mike Pavone <pavone@retrodev.com>
date Mon, 27 May 2013 20:56:02 -0700
parents 54c0e5f22198
children 140af5509ce7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
235
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
1 #ifndef Z80INST_H_
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
2 #define Z80INST_H_
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
3
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <stdint.h>
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 enum {
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 Z80_LD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 Z80_PUSH,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 Z80_POP,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 Z80_EX,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 Z80_EXX,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 Z80_LDI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 Z80_LDIR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 Z80_LDD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 Z80_LDDR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 Z80_CPI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 Z80_CPIR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 Z80_CPD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 Z80_CPDR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 Z80_ADD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 Z80_ADC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 Z80_SUB,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 Z80_SBC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 Z80_AND,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 Z80_OR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 Z80_XOR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 Z80_CP,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 Z80_INC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 Z80_DEC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 Z80_DAA,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 Z80_CPL,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 Z80_NEG,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 Z80_CCF,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 Z80_SCF,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 Z80_NOP,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 Z80_HALT,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 Z80_DI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 Z80_EI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 Z80_IM,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 Z80_RLC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41 Z80_RL,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 Z80_RRC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 Z80_RR,
201
2d2fa345e1fc Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 200
diff changeset
44 Z80_SLA,
2d2fa345e1fc Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 200
diff changeset
45 Z80_SRA,
2d2fa345e1fc Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 200
diff changeset
46 Z80_SLL,
2d2fa345e1fc Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 200
diff changeset
47 Z80_SRL,
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 Z80_RLD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 Z80_RRD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 Z80_BIT,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 Z80_SET,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 Z80_RES,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 Z80_JP,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 Z80_JPCC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 Z80_JR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 Z80_JRCC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 Z80_DJNZ,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 Z80_CALL,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 Z80_CALLCC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 Z80_RET,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 Z80_RETCC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62 Z80_RETI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 Z80_RETN,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 Z80_RST,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 Z80_IN,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66 Z80_INI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 Z80_INIR,
200
d3066ceb29d1 Add support for EXTD group 2-byte Z80 instructions in decoder
Mike Pavone <pavone@retrodev.com>
parents: 199
diff changeset
68 Z80_IND,
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 Z80_INDR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 Z80_OUT,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71 Z80_OUTI,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 Z80_OTIR,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73 Z80_OUTD,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74 Z80_OTDR
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75 };
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 enum {
235
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
78 Z80_C=0,
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
79 Z80_B,
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
80 Z80_E,
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81 Z80_D,
235
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
82 Z80_L,
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
83 Z80_H,
235
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
84 Z80_IXL,
203
0ae589d4c3f9 Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 201
diff changeset
85 Z80_IXH,
235
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
86 Z80_IYL,
204
02dfa5962522 Add support for 2-byte IY instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 203
diff changeset
87 Z80_IYH,
200
d3066ceb29d1 Add support for EXTD group 2-byte Z80 instructions in decoder
Mike Pavone <pavone@retrodev.com>
parents: 199
diff changeset
88 Z80_I,
d3066ceb29d1 Add support for EXTD group 2-byte Z80 instructions in decoder
Mike Pavone <pavone@retrodev.com>
parents: 199
diff changeset
89 Z80_R,
213
4d4559b04c59 Make reset trigger debug exit to make it easier to test the same cases in blastem and musashi. Fix asl #1 overflow flag.
Mike Pavone <pavone@retrodev.com>
parents: 205
diff changeset
90 Z80_A,
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
91 Z80_BC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
92 Z80_DE,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
93 Z80_HL,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
94 Z80_SP,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
95 Z80_AF,
203
0ae589d4c3f9 Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 201
diff changeset
96 Z80_IX,
0ae589d4c3f9 Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 201
diff changeset
97 Z80_IY,
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 Z80_UNUSED
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
99 };
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
100
205
19b323614309 Add support for IX bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 204
diff changeset
101 #define Z80_IMMED_FLAG 0x80
19b323614309 Add support for IX bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 204
diff changeset
102 #define Z80_USE_IMMED (Z80_IMMED_FLAG|Z80_UNUSED)
19b323614309 Add support for IX bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 204
diff changeset
103
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
104 enum {
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
105 Z80_CC_NZ,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
106 Z80_CC_Z,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
107 Z80_CC_NC,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108 Z80_CC_C,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
109 Z80_CC_PO,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
110 Z80_CC_PE,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
111 Z80_CC_P,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
112 Z80_CC_M
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
113 };
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
114
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
115 enum {
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
116 Z80_REG,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
117 Z80_REG_INDIRECT,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
118 Z80_IMMED,
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
119 Z80_IMMED_INDIRECT,
203
0ae589d4c3f9 Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 201
diff changeset
120 Z80_IX_DISPLACE,
0ae589d4c3f9 Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents: 201
diff changeset
121 Z80_IY_DISPLACE
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
122 };
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
123 #define Z80_DIR 0x80
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
124
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
125 typedef struct {
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
126 uint8_t op;
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
127 uint8_t reg;
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
128 uint8_t addr_mode;
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
129 uint8_t ea_reg;
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
130 uint16_t immed;
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
131 } z80inst;
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
132
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
133 uint8_t * z80_decode(uint8_t * istream, z80inst * decoded);
314
54c0e5f22198 Show absolute addresses for JR, JRCC and DJNZ in Z80 disassembler
Mike Pavone <pavone@retrodev.com>
parents: 313
diff changeset
134 int z80_disasm(z80inst * decoded, char * dst, uint16_t address);
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents: 235
diff changeset
135 uint8_t z80_high_reg(uint8_t reg);
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents: 235
diff changeset
136 uint8_t z80_low_reg(uint8_t reg);
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents: 235
diff changeset
137 uint8_t z80_word_reg(uint8_t reg);
313
a13329645ea3 Fix terminal instruction detection in disassembler
Mike Pavone <pavone@retrodev.com>
parents: 292
diff changeset
138 uint8_t z80_is_terminal(z80inst * inst);
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
139
235
d9bf8e61c33c Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents: 213
diff changeset
140 #endif //Z80INST_H_
199
69585e7d474f Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
141