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.
29 printf("ILL_ED: %04X - %02X\n", (dbyte
) (PC
-1), DANM(mem
)[(dbyte
) (PC
-1)]);
35 #define IN_R_IC(rn, r, n) \
36 OPDEF(in_ ## rn ## _ic, 0x40+8*n) \
38 register byte res, flag; \
41 flag = (RF & ~(ABUTCF)) | \
57 #define OUT_IC_R(rn, r, n) \
58 OPDEF(out_ic_ ## rn, 0x41+8*n) \
75 #define SBC_HL_RR(rrn, rr, n) \
76 OPDEF(sbc_hl_ ## rrn, 0x42+0x10*n) \
79 register int idx, flag; \
81 res = HL - rr - (flag & CF); \
82 idx = DIDXCALC(HL, rr, res); \
84 flag = (RF & ~(ALLF)) | \
85 (TAB(subf_tbl)[idx] & ALLF); \
86 if(!res) flag |= ZF; \
96 #define ADC_HL_RR(rrn, rr, n) \
97 OPDEF(adc_hl_ ## rrn, 0x4A+0x10*n) \
100 register int idx, flag; \
102 res = HL + rr + (flag & CF); \
103 idx = DIDXCALC(HL, rr, res); \
105 flag = (RF & ~(ALLF)) | \
106 (TAB(addf_tbl)[idx] & ALLF); \
107 if(!res) flag |= ZF; \
119 #define LD_INN_RR(rrn, pf, rr, n) \
120 OPDEF(ld_inn_ ## rrn ## pf, 0x43+0x10*n) \
122 register dbyte dtmp; \
129 LD_INN_RR(bc
, , BC
, 0)
130 LD_INN_RR(de
, , DE
, 1)
131 LD_INN_RR(hl
, _ed
, HL
, 2)
132 LD_INN_RR(sp
, , SP
, 3)
135 #define LD_RR_INN(rrn, pf, rr, n) \
136 OPDEF(ld_## rrn ## _inn ## pf, 0x4B+0x10*n) \
138 register dbyte dtmp; \
145 LD_RR_INN(bc
, , BC
, 0)
146 LD_RR_INN(de
, , DE
, 1)
147 LD_RR_INN(hl
, _ed
, HL
, 2)
148 LD_RR_INN(sp
, , SP
, 3)
150 OPDEF(neg
, 0x44 0x4C 0x54 0x5C 0x64 0x6C 0x74 0x7C)
157 idx
= IDXCALC(0, RA
, res
);
159 flag
= (RF
& ~(AALLF
)) | TAB(subf_tbl
)[idx
];
165 OPDEF(retn
, 0x45 0x55 0x5D 0x65 0x6D 0x75 0x7D)
167 DANM(iff1
) = DANM(iff2
);
179 OPDEF(im_0
, 0x46 0x4E 0x56 0x5E)
186 OPDEF(im_1
, 0x56 0x76)
193 OPDEF(im_2
, 0x5E 0x7E)
207 DANM(rl7
) = RA
& 0x80;
217 flag
= (RF
& ~(BUTCF
)) | (RA
& SF
);
219 if(DANM(iff2
)) flag
|= PVF
;
229 RA
= (RR
& 0x7F) | DANM(rl7
);
230 flag
= (RF
& ~(BUTCF
)) | (RA
& SF
);
232 if(DANM(iff2
)) flag
|= PVF
;
242 dtmp
= *HLP
| (RA
<< 8);
243 RA
= (RA
& 0xF0) | (dtmp
& 0x0F);
244 SETFLAGS(ABUTCF
, TAB(orf_tbl
)[RA
]);
246 PUTMEM(HL
, HLP
, (byte
) dtmp
);
255 dtmp
= (*HLP
<< 4) | (RA
& 0x0F);
256 RA
= (RA
& 0xF0) | ((dtmp
>> 8) & 0x0F);
257 SETFLAGS(ABUTCF
, TAB(orf_tbl
)[RA
]);
258 PUTMEM(HL
, HLP
, (byte
) dtmp
);
281 PUTMEM(DE, DEP, res); \
283 RF = RF & ~(HF | PVF | NF); \
325 idx = IDXCALC(RA, *HLP, res); \
326 RF = (RF & ~BUTCF) | \
327 (TAB(subf_tbl)[idx] & \
328 (SF | HF | NF | B3F | B5F)); \
374 idx = IDXCALC(RB, 1, res); \
375 RF = (RF & ~BUTCF) | \
376 (TAB(subf_tbl)[idx] & \
377 (SF | HF | PVF | NF | B3F | B5F)); \
381 PUTMEM(HL, HLP, res); \
415 idx = IDXCALC(RB, 1, res); \
416 RF = (RF & ~BUTCF) | \
417 (TAB(subf_tbl)[idx] & \
418 (SF | HF | PVF | NF )); \