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.
33 printf("ILL_ED: %04X - %02X\n", (dbyte
) (PC
-1), DANM(mem
)[(dbyte
) (PC
-1)]);
39 #define IN_R_IC(rn, r, n) \
40 OPDEF(in_ ## rn ## _ic, 0x40+8*n) \
42 register byte res, flag; \
45 flag = (RF & ~(ABUTCF)) | \
61 #define OUT_IC_R(rn, r, n) \
62 OPDEF(out_ic_ ## rn, 0x41+8*n) \
79 #define SBC_HL_RR(rrn, rr, n) \
80 OPDEF(sbc_hl_ ## rrn, 0x42+0x10*n) \
83 register int idx, flag; \
85 res = HL - rr - (flag & CF); \
86 idx = DIDXCALC(HL, rr, res); \
88 flag = (RF & ~(ALLF)) | \
89 (TAB(subf_tbl)[idx] & ALLF); \
90 if(!res) flag |= ZF; \
100 #define ADC_HL_RR(rrn, rr, n) \
101 OPDEF(adc_hl_ ## rrn, 0x4A+0x10*n) \
103 register dbyte res; \
104 register int idx, flag; \
106 res = HL + rr + (flag & CF); \
107 idx = DIDXCALC(HL, rr, res); \
109 flag = (RF & ~(ALLF)) | \
110 (TAB(addf_tbl)[idx] & ALLF); \
111 if(!res) flag |= ZF; \
123 #define LD_INN_RR(rrn, pf, rr, n) \
124 OPDEF(ld_inn_ ## rrn ## pf, 0x43+0x10*n) \
126 register dbyte dtmp; \
133 LD_INN_RR(bc
, , BC
, 0)
134 LD_INN_RR(de
, , DE
, 1)
135 LD_INN_RR(hl
, _ed
, HL
, 2)
136 LD_INN_RR(sp
, , SP
, 3)
139 #define LD_RR_INN(rrn, pf, rr, n) \
140 OPDEF(ld_## rrn ## _inn ## pf, 0x4B+0x10*n) \
142 register dbyte dtmp; \
149 LD_RR_INN(bc
, , BC
, 0)
150 LD_RR_INN(de
, , DE
, 1)
151 LD_RR_INN(hl
, _ed
, HL
, 2)
152 LD_RR_INN(sp
, , SP
, 3)
154 OPDEF(neg
, 0x44 0x4C 0x54 0x5C 0x64 0x6C 0x74 0x7C)
161 idx
= IDXCALC(0, RA
, res
);
163 flag
= (RF
& ~(AALLF
)) | TAB(subf_tbl
)[idx
];
169 OPDEF(retn
, 0x45 0x55 0x5D 0x65 0x6D 0x75 0x7D)
171 DANM(iff1
) = DANM(iff2
);
183 OPDEF(im_0
, 0x46 0x4E 0x56 0x5E)
190 OPDEF(im_1
, 0x56 0x76)
197 OPDEF(im_2
, 0x5E 0x7E)
211 DANM(rl7
) = RA
& 0x80;
221 flag
= (RF
& ~(BUTCF
)) | (RA
& SF
);
223 if(DANM(iff2
)) flag
|= PVF
;
233 RA
= (RR
& 0x7F) | DANM(rl7
);
234 flag
= (RF
& ~(BUTCF
)) | (RA
& SF
);
236 if(DANM(iff2
)) flag
|= PVF
;
246 dtmp
= *HLP
| (RA
<< 8);
247 RA
= (RA
& 0xF0) | (dtmp
& 0x0F);
248 SETFLAGS(ABUTCF
, TAB(orf_tbl
)[RA
]);
250 PUTMEM(HL
, HLP
, (byte
) dtmp
);
259 dtmp
= (*HLP
<< 4) | (RA
& 0x0F);
260 RA
= (RA
& 0xF0) | ((dtmp
>> 8) & 0x0F);
261 SETFLAGS(ABUTCF
, TAB(orf_tbl
)[RA
]);
262 PUTMEM(HL
, HLP
, (byte
) dtmp
);
285 PUTMEM(DE, DEP, res); \
287 RF = RF & ~(HF | PVF | NF); \
329 idx = IDXCALC(RA, *HLP, res); \
330 RF = (RF & ~BUTCF) | \
331 (TAB(subf_tbl)[idx] & \
332 (SF | HF | NF | B3F | B5F)); \
378 idx = IDXCALC(RB, 1, res); \
379 RF = (RF & ~BUTCF) | \
380 (TAB(subf_tbl)[idx] & \
381 (SF | HF | PVF | NF | B3F | B5F)); \
385 PUTMEM(HL, HLP, res); \
419 idx = IDXCALC(RB, 1, res); \
420 RF = (RF & ~BUTCF) | \
421 (TAB(subf_tbl)[idx] & \
422 (SF | HF | PVF | NF )); \