Mercurial > repos > blastem
annotate z80inst.h @ 229:d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 21 Apr 2013 19:12:48 -0700 |
parents | 4d4559b04c59 |
children | d9bf8e61c33c |
rev | line source |
---|---|
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <stdint.h> |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 enum { |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 Z80_LD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 Z80_PUSH, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 Z80_POP, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 Z80_EX, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 Z80_EXX, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 Z80_LDI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 Z80_LDIR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 Z80_LDD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 Z80_LDDR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 Z80_CPI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 Z80_CPIR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 Z80_CPD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 Z80_CPDR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 Z80_ADD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 Z80_ADC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 Z80_SUB, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 Z80_SBC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 Z80_AND, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 Z80_OR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 Z80_XOR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 Z80_CP, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 Z80_INC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 Z80_DEC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 Z80_DAA, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 Z80_CPL, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 Z80_NEG, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 Z80_CCF, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 Z80_SCF, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 Z80_NOP, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 Z80_HALT, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 Z80_DI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 Z80_EI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 Z80_IM, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 Z80_RLC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 Z80_RL, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 Z80_RRC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 Z80_RR, |
201
2d2fa345e1fc
Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
200
diff
changeset
|
41 Z80_SLA, |
2d2fa345e1fc
Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
200
diff
changeset
|
42 Z80_SRA, |
2d2fa345e1fc
Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
200
diff
changeset
|
43 Z80_SLL, |
2d2fa345e1fc
Add support for bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
200
diff
changeset
|
44 Z80_SRL, |
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 Z80_RLD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 Z80_RRD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 Z80_BIT, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 Z80_SET, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 Z80_RES, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 Z80_JP, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 Z80_JPCC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 Z80_JR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 Z80_JRCC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 Z80_DJNZ, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 Z80_CALL, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 Z80_CALLCC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 Z80_RET, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 Z80_RETCC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 Z80_RETI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 Z80_RETN, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 Z80_RST, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 Z80_IN, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 Z80_INI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 Z80_INIR, |
200
d3066ceb29d1
Add support for EXTD group 2-byte Z80 instructions in decoder
Mike Pavone <pavone@retrodev.com>
parents:
199
diff
changeset
|
65 Z80_IND, |
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 Z80_INDR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 Z80_OUT, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 Z80_OUTI, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 Z80_OTIR, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 Z80_OUTD, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 Z80_OTDR |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 }; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 enum { |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 Z80_B=0, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 Z80_C, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 Z80_D, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 Z80_E, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 Z80_H, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 Z80_L, |
203
0ae589d4c3f9
Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
201
diff
changeset
|
81 Z80_IXH, |
0ae589d4c3f9
Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
201
diff
changeset
|
82 Z80_IXL, |
204
02dfa5962522
Add support for 2-byte IY instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
203
diff
changeset
|
83 Z80_IYH, |
02dfa5962522
Add support for 2-byte IY instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
203
diff
changeset
|
84 Z80_IYL, |
200
d3066ceb29d1
Add support for EXTD group 2-byte Z80 instructions in decoder
Mike Pavone <pavone@retrodev.com>
parents:
199
diff
changeset
|
85 Z80_I, |
d3066ceb29d1
Add support for EXTD group 2-byte Z80 instructions in decoder
Mike Pavone <pavone@retrodev.com>
parents:
199
diff
changeset
|
86 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
|
87 Z80_A, |
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 Z80_BC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 Z80_DE, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 Z80_HL, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 Z80_SP, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 Z80_AF, |
203
0ae589d4c3f9
Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
201
diff
changeset
|
93 Z80_IX, |
0ae589d4c3f9
Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
201
diff
changeset
|
94 Z80_IY, |
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 Z80_UNUSED |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 }; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 |
205
19b323614309
Add support for IX bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
204
diff
changeset
|
98 #define Z80_IMMED_FLAG 0x80 |
19b323614309
Add support for IX bit instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
204
diff
changeset
|
99 #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
|
100 |
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 enum { |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 Z80_CC_NZ, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 Z80_CC_Z, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 Z80_CC_NC, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 Z80_CC_C, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 Z80_CC_PO, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 Z80_CC_PE, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 Z80_CC_P, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 Z80_CC_M |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 }; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 enum { |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 Z80_REG, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 Z80_REG_INDIRECT, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 Z80_IMMED, |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 Z80_IMMED_INDIRECT, |
203
0ae589d4c3f9
Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
201
diff
changeset
|
117 Z80_IX_DISPLACE, |
0ae589d4c3f9
Add support for 2-byte IX instructions to decoder
Mike Pavone <pavone@retrodev.com>
parents:
201
diff
changeset
|
118 Z80_IY_DISPLACE |
199
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 }; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 #define Z80_DIR 0x80 |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 typedef struct { |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 uint8_t op; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 uint8_t reg; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 uint8_t addr_mode; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 uint8_t ea_reg; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 uint16_t immed; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 } z80inst; |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 uint8_t * z80_decode(uint8_t * istream, z80inst * decoded); |
69585e7d474f
Add initial stab at Z80 decoder and disassembler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 int z80_disasm(z80inst * decoded, char * dst); |
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 |