summaryrefslogtreecommitdiff
path: root/apps/plugins/zxbox/z80_op3.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/zxbox/z80_op3.c')
-rw-r--r--apps/plugins/zxbox/z80_op3.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/apps/plugins/zxbox/z80_op3.c b/apps/plugins/zxbox/z80_op3.c
new file mode 100644
index 0000000000..dd0d43ad02
--- /dev/null
+++ b/apps/plugins/zxbox/z80_op3.c
@@ -0,0 +1,142 @@
1/*
2 * Copyright (C) 1996-1998 Szeredi Miklos
3 * Email: mszeredi@inf.bme.hu
4 *
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.
9 *
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.
14 *
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.
18 *
19 */
20
21#ifndef NO_OPDEF
22#include "z80_def.h"
23#include "z80_op3.h"
24#include "z80_ari.h"
25#endif
26
27#define ARIR(arin, func, an, rn, r, n) \
28OPDEF(arin ## _ ## rn, 0x80+an*8+n) \
29{ \
30 func(r); \
31 ENTIME(4); \
32}
33
34#define ARIIHL(arin, func, an) \
35OPDEF(arin ## _ihl, 0x86+an*8) \
36{ \
37 func(*HLP); \
38 ENTIME(7); \
39}
40
41#define ARIID(arin, func, an, ixyn, ixy) \
42OPDEF(arin ## _i ## ixyn ## d, 0x86+an*8)\
43{ \
44 register dbyte addr; \
45 register byte val; \
46 IXDGET(ixy, addr); \
47 val = READ(addr); \
48 func(val); \
49 ENTIME(15); \
50}
51
52
53#define ADD_A_R(rn, r, n) ARIR(add_a, ADD, 0, rn, r, n)
54#define ADC_A_R(rn, r, n) ARIR(adc_a, ADC, 1, rn, r, n)
55#define SUB_R(rn, r, n) ARIR(sub, SUB, 2, rn, r, n)
56#define SBC_A_R(rn, r, n) ARIR(sbc_a, SBC, 3, rn, r, n)
57#define AND_R(rn, r, n) ARIR(and, AND, 4, rn, r, n)
58#define XOR_R(rn, r, n) ARIR(xor, XOR, 5, rn, r, n)
59#define OR_R(rn, r, n) ARIR(or, OR, 6, rn, r, n)
60#define CP_R(rn, r, n) ARIR(cp, CP, 7, rn, r, n)
61
62ADD_A_R(b, RB, 0)
63ADD_A_R(c, RC, 1)
64ADD_A_R(d, RD, 2)
65ADD_A_R(e, RE, 3)
66ADD_A_R(h, RH, 4)
67ADD_A_R(l, RL, 5)
68ADD_A_R(a, RA, 7)
69
70ADC_A_R(b, RB, 0)
71ADC_A_R(c, RC, 1)
72ADC_A_R(d, RD, 2)
73ADC_A_R(e, RE, 3)
74ADC_A_R(h, RH, 4)
75ADC_A_R(l, RL, 5)
76ADC_A_R(a, RA, 7)
77
78SUB_R(b, RB, 0)
79SUB_R(c, RC, 1)
80SUB_R(d, RD, 2)
81SUB_R(e, RE, 3)
82SUB_R(h, RH, 4)
83SUB_R(l, RL, 5)
84SUB_R(a, RA, 7)
85
86SBC_A_R(b, RB, 0)
87SBC_A_R(c, RC, 1)
88SBC_A_R(d, RD, 2)
89SBC_A_R(e, RE, 3)
90SBC_A_R(h, RH, 4)
91SBC_A_R(l, RL, 5)
92SBC_A_R(a, RA, 7)
93
94AND_R(b, RB, 0)
95AND_R(c, RC, 1)
96AND_R(d, RD, 2)
97AND_R(e, RE, 3)
98AND_R(h, RH, 4)
99AND_R(l, RL, 5)
100AND_R(a, RA, 7)
101
102XOR_R(b, RB, 0)
103XOR_R(c, RC, 1)
104XOR_R(d, RD, 2)
105XOR_R(e, RE, 3)
106XOR_R(h, RH, 4)
107XOR_R(l, RL, 5)
108/* XOR_R(a, RA, 7) */
109
110OPDEF(xor_a, 0xAF)
111{
112 RA = 0;
113 RF = (RF & ~(ALLF)) | (ZF | PVF);
114 ENTIME(4);
115}
116
117OR_R(b, RB, 0)
118OR_R(c, RC, 1)
119OR_R(d, RD, 2)
120OR_R(e, RE, 3)
121OR_R(h, RH, 4)
122OR_R(l, RL, 5)
123OR_R(a, RA, 7)
124
125CP_R(b, RB, 0)
126CP_R(c, RC, 1)
127CP_R(d, RD, 2)
128CP_R(e, RE, 3)
129CP_R(h, RH, 4)
130CP_R(l, RL, 5)
131CP_R(a, RA, 7)
132
133ARIIHL(add_a, ADD, 0)
134ARIIHL(adc_a, ADC, 1)
135ARIIHL(sub, SUB, 2)
136ARIIHL(sbc_a, SBC, 3)
137ARIIHL(and, AND, 4)
138ARIIHL(xor, XOR, 5)
139ARIIHL(or, OR, 6)
140ARIIHL(cp, CP, 7)
141
142#include "z80_op3x.c"