Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc-extra / emu / rrz80 / cpu / z80_def.h
blob15b39cced5a57b7bb01156833370f285b7e2517b
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 #include "z80.h"
23 #ifdef PROCP
25 typedef Z80 *z80t;
27 #define OPDEF(name, num) z80t z80op_ ## name (z80t z80p)
28 #define ENDOP() return z80p
29 #undef DANM
30 #define DANM(x) z80p->x
32 #define TAB(t) DANM(t)
33 #define PORT(t) DANM(t)
34 #define SPECP(t) DANM(t)
36 #else
38 typedef void z80t;
40 #define OPDEF(name, num) void z80op_ ## name (z80t)
41 #define ENDOP()
43 #define TAB(t) z80c_ ## t
44 #define PORT(t) PRNM(t)
45 #define SPECP(t) SPNM(t)
47 #endif
50 typedef z80t (*op_f)(z80t);
51 extern op_f z80c_op_tab[];
52 extern op_f z80c_op_tab_cb[];
53 extern op_f z80c_op_tab_dd[];
54 extern op_f z80c_op_tab_ed[];
55 extern op_f z80c_op_tab_fd[];
57 #define TIME(x) DANM(tc) -= (x)
59 #define ENTIME(x) { TIME(x); ENDOP(); }
61 #define READ(addr) (DANM(mem)[addr])
62 #define WRITE(addr, val) PUTMEM(addr, DANM(mem) + (dbyte) (addr), val)
64 #define DREAD(addr) (DANM(mem)[addr] | (DANM(mem)[(dbyte)(addr+1)] << 8))
65 #define DWRITE(addr, x) WRITE(addr, (byte) x); \
66 WRITE((dbyte) (addr+1), (byte) (x >> 8))
68 #define IPCS ((sbyte) *PCP)
71 #define MODMEM(func) \
72 { \
73 register byte bdef; \
74 bdef = *HLP; \
75 func(bdef); \
76 PUTMEM(HL, HLP, bdef); \
79 #define MODMEMADDR(func, addr) \
80 { \
81 register byte bdef; \
82 bdef = READ(addr); \
83 func(bdef); \
84 WRITE(addr, bdef); \
87 #define IXDGET(ixy, addr) addr = ((dbyte) (ixy + IPCS)), PC++
89 #define FETCHD(x) \
90 { \
91 register dbyte ddef; \
92 ddef = PC; \
93 x = DREAD(ddef); \
94 PC = ddef+2; \
97 #define POP(x) \
98 { \
99 register dbyte ddef; \
100 ddef = SP; \
101 x = DREAD(ddef); \
102 SP = ddef+2; \
105 #define PUSH(x) \
107 register dbyte ddef, dval; \
108 dval = x; \
109 ddef = SP-2; \
110 DWRITE(ddef, dval); \
111 SP = ddef; \
114 #ifdef SPECT_MEM
115 #include "sp_def.h"
116 #else
118 #define PUTMEM(addr, ptr, val) *(ptr) = (val)
119 #define IN(porth, portl, dest) dest = PORT(inports)[portl]
120 #define OUT(porth, portl, source) PORT(outports)[portl] = (source)
121 #define DI_CHECK
123 #endif
126 #define SF 0x80
127 #define ZF 0x40
128 #define B5F 0x20
129 #define HF 0x10
130 #define B3F 0x08
131 #define PVF 0x04
132 #define NF 0x02
133 #define CF 0x01
135 #define ALLF (SF | ZF | HF | PVF | NF | CF)
136 #define BUTCF (SF | ZF | HF | PVF | NF)
138 #define AALLF 0xff
139 #define ABUTCF 0xfe
141 #define SETFLAGS(mask, val) (RF = (RF & ~(mask)) | (val))
142 #define SET_FL(x) (RF |= (x))
143 #define CLR_FL(x) (RF &= ~(x))
146 #define TESTZF (RF & ZF)
147 #define TESTCF (RF & CF)
148 #define TESTSF (RF & SF)
149 #define TESTPF (RF & PVF)
150 #define TESTHF (RF & HF)
151 #define TESTNF (RF & NF)
154 #define IDXCALC(v1, v2, res) \
155 ((res & 0xA8) | ((v1 & 0x88) >> 1) | ((v2 & 0x88) >> 3))
157 #define DIDXCALC(v1, v2, res) \
158 (((res & 0x8800) >> 8) | ((v1 & 0x8800) >> 9) | ((v2 & 0x8800) >> 11))
161 extern byte z80c_incf_tbl[];
162 extern byte z80c_decf_tbl[];
163 extern byte z80c_addf_tbl[];
164 extern byte z80c_subf_tbl[];
165 extern byte z80c_orf_tbl[];