struct / union in initializer, RFE #901.
[sdcc.git] / sdcc-extra / emu / rrz80 / cpu / z80.h
blob5851e5abd2a2ea24e5a763a9688bc72dbc21623c
1 /*
2 * Copyright (C) 1996-1998 Szeredi Miklos
3 * Email: mszeredi@inf.bme.hu
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. See the file COPYING.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef Z80_H
22 #define Z80_H
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #elif defined(__BIG_ENDIAN__)
27 /* defined by preprocessor */
28 # define WORDS_BIGENDIAN
29 #elif !defined(__LITTLE_ENDIAN__)
30 /* try with types.h and endian.h */
31 /* Hack: GYGWIN doesn't have endian.h, but we know it is LITTLE ENDIAN */
32 # ifndef __CYGWIN__
33 # include <sys/types.h>
34 # if defined(_BIG_ENDIAN)
35 # define WORDS_BIGENDIAN
36 # elif !defined(_LITTLE_ENDIAN)
37 # include <endian.h>
38 # if BYTE_ORDER == BIG_ENDIAN
39 # define WORDS_BIGENDIAN
40 # endif
41 # endif
42 # endif
43 #endif
45 #ifndef COMPARISON
46 #define PRNM(x) z80_ ## x
47 #else
48 #define PRNM(x) z80x_ ## x
49 #endif
51 #define DANM(x) PRNM(proc).x
53 #include "z80_type.h"
56 #ifndef WORDS_BIGENDIAN
57 union dregp {
58 struct { byte l, h, _b2, _b3; } s;
59 struct { dbyte d, _d1; } d;
60 byte* p;
62 #else
63 union dregp {
64 struct { byte _b3, _b2, h, l; } s;
65 struct { dbyte _d1, d; } d;
66 byte* p;
68 #endif
70 #define NUMDREGS 9
71 #define BACKDREGS 4
73 #define PORTNUM 256
75 /* Do NOT change the order! */
76 typedef struct {
77 union dregp nr[NUMDREGS];
78 union dregp br[BACKDREGS];
80 int haltstate;
81 int it_mode;
82 int iff1, iff2;
84 byte *mem;
86 int tc;
87 int rl7;
89 #ifdef SPECT_MEM /* WARNING: Do NOT change the order!!! */
90 int next_scri;
91 int inport_mask;
92 int ula_inport;
93 int ula_outport;
94 int sound_sam;
95 int sound_change;
96 int imp_change;
97 int pc_speaker;
98 #endif
100 #ifdef Z80C
101 dbyte cbaddr;
103 #ifdef PROCP
104 byte *incf_tbl;
105 byte *decf_tbl;
106 byte *addf_tbl;
107 byte *subf_tbl;
108 byte *orf_tbl;
110 byte *inports;
111 byte *outports;
112 #ifdef SPECT_MEM
113 byte *fe_inport_high;
114 #endif
115 #endif
116 #endif
118 } Z80;
121 extern Z80 PRNM(proc);
123 extern byte PRNM(inports)[];
124 extern byte PRNM(outports)[];
126 #define ZI_BC 0
127 #define ZI_DE 1
128 #define ZI_HL 2
129 #define ZI_AF 3
130 #define ZI_IR 4
131 #define ZI_IX 5
132 #define ZI_IY 6
133 #define ZI_PC 7
134 #define ZI_SP 8
137 #define BC (DANM(nr)[ZI_BC].d.d)
138 #define DE (DANM(nr)[ZI_DE].d.d)
139 #define HL (DANM(nr)[ZI_HL].d.d)
140 #define AF (DANM(nr)[ZI_AF].d.d)
141 #define IR (DANM(nr)[ZI_IR].d.d)
142 #define IX (DANM(nr)[ZI_IX].d.d)
143 #define IY (DANM(nr)[ZI_IY].d.d)
144 #define PC (DANM(nr)[ZI_PC].d.d)
145 #define SP (DANM(nr)[ZI_SP].d.d)
147 #define BCP (DANM(nr)[ZI_BC].p)
148 #define DEP (DANM(nr)[ZI_DE].p)
149 #define HLP (DANM(nr)[ZI_HL].p)
150 #define PCP (DANM(nr)[ZI_PC].p)
151 #define SPP (DANM(nr)[ZI_SP].p)
152 #define IXP (DANM(nr)[ZI_IX].p)
153 #define IYP (DANM(nr)[ZI_IY].p)
156 #define RB (DANM(nr)[ZI_BC].s.h)
157 #define RC (DANM(nr)[ZI_BC].s.l)
158 #define RD (DANM(nr)[ZI_DE].s.h)
159 #define RE (DANM(nr)[ZI_DE].s.l)
160 #define RH (DANM(nr)[ZI_HL].s.h)
161 #define RL (DANM(nr)[ZI_HL].s.l)
162 #define RA (DANM(nr)[ZI_AF].s.h)
163 #define RF (DANM(nr)[ZI_AF].s.l)
164 #define RI (DANM(nr)[ZI_IR].s.h)
165 #define RR (DANM(nr)[ZI_IR].s.l)
166 #define XH (DANM(nr)[ZI_IX].s.h)
167 #define XL (DANM(nr)[ZI_IX].s.l)
168 #define YH (DANM(nr)[ZI_IY].s.h)
169 #define YL (DANM(nr)[ZI_IY].s.l)
170 #define PCH (DANM(nr)[ZI_PC].s.h)
171 #define PCL (DANM(nr)[ZI_PC].s.l)
172 #define SPH (DANM(nr)[ZI_SP].s.h)
173 #define SPL (DANM(nr)[ZI_SP].s.l)
175 #define BCBK (DANM(br)[ZI_BC].d.d)
176 #define DEBK (DANM(br)[ZI_DE].d.d)
177 #define HLBK (DANM(br)[ZI_HL].d.d)
178 #define AFBK (DANM(br)[ZI_AF].d.d)
180 #define BBK (DANM(br)[ZI_BC].s.h)
181 #define CBK (DANM(br)[ZI_BC].s.l)
182 #define DBK (DANM(br)[ZI_DE].s.h)
183 #define EBK (DANM(br)[ZI_DE].s.l)
184 #define HBK (DANM(br)[ZI_HL].s.h)
185 #define LBK (DANM(br)[ZI_HL].s.l)
186 #define ABK (DANM(br)[ZI_AF].s.h)
187 #define FBK (DANM(br)[ZI_AF].s.l)
189 #ifdef __cplusplus
190 extern "C" {
191 #endif
193 extern void PRNM(init)(void);
194 extern int PRNM(step)(int ticknum);
196 extern void PRNM(interrupt)(int data);
197 extern void PRNM(nmi)(void);
198 extern void PRNM(reset)(void);
200 extern void PRNM(pushpc)(void);
201 extern void PRNM(local_init)(void);
203 #ifdef __cplusplus
205 #endif
208 #endif /* Z80_H */