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.
31 OPDEF(ex_af_afb
, 0x08)
35 ptmp
= DANM(br
)[ZI_AF
].p
;
36 DANM(br
)[ZI_AF
].p
= DANM(nr
)[ZI_AF
].p
;
37 DANM(nr
)[ZI_AF
].p
= ptmp
;
60 #define JR_CC_E(ccn, cc, n) \
61 OPDEF(jr_ ## ccn ## _e, 0x20+n*8) \
73 JR_CC_E(nz
, !TESTZF
, 0)
75 JR_CC_E(nc
, !TESTCF
, 2)
79 #define LD_RR_NN(rrn, rr, n) \
80 OPDEF(ld_ ## rrn ## _nn, 0x01+n*0x10) \
91 #define DADD(rr1, rr2) \
92 register dbyte dtmp; \
96 idx = DIDXCALC(dtmp, rr2, rr1); \
97 SETFLAGS(CF | NF | HF, TAB(addf_tbl)[idx] & (CF | HF))
100 #define ADD_RR_RR(rrn1, rr1, rrn2, rr2, n) \
101 OPDEF(add_## rrn1 ## _ ## rrn2, 0x09+n*0x10) \
107 ADD_RR_RR(hl
, HL
, bc
, BC
, 0)
108 ADD_RR_RR(hl
, HL
, de
, DE
, 1)
109 ADD_RR_RR(hl
, HL
, hl
, HL
, 2)
110 ADD_RR_RR(hl
, HL
, sp
, SP
, 3)
112 #define INC_RR(rrn, rr, n) \
113 OPDEF(inc_ ## rrn, 0x03+n*0x10) \
124 #define DEC_RR(rrn, rr, n) \
125 OPDEF(dec_ ## rrn, 0x0B+n*0x10) \
136 OPDEF(ld_ibc_a
, 0x02)
142 OPDEF(ld_ide_a
, 0x12)
148 #define LD_INN_RR(rrn, rr) \
149 OPDEF(ld_inn_ ## rrn, 0x22) \
151 register dbyte dtmp; \
160 OPDEF(ld_inn_a
, 0x32)
168 OPDEF(ld_a_ibc
, 0x0A)
174 OPDEF(ld_a_ide
, 0x1A)
181 #define LD_RR_INN(rrn, rr) \
182 OPDEF(ld_ ## rrn ## _inn, 0x2A) \
184 register dbyte dtmp; \
193 OPDEF(ld_a_inn
, 0x3A)
204 SETFLAGS(SF | ZF | PVF | B3F | B5F, TAB(incf_tbl)[r])
208 #define INC_R(rn, r, n) \
209 OPDEF(inc_ ## rn, 0x04+n*8) \
233 SETFLAGS(SF | ZF | PVF | B3F | B5F, TAB(decf_tbl)[r])
236 #define DEC_R(rn, r, n) \
237 OPDEF(dec_ ## rn, 0x05+n*8) \
258 #define LD_R_N(rn, r, n) \
259 OPDEF(ld_ ## rn ## _n, 0x06+n*8) \
275 OPDEF(ld_ihl_n
, 0x36)
277 PUTMEM(HL
, HLP
, *PCP
);
285 btmp
= (RA
& 0x80) >> 7;
286 SETFLAGS(HF
| NF
| CF
, btmp
);
287 RA
= (RA
<< 1) | btmp
;
295 SETFLAGS(HF
| NF
| CF
, btmp
);
297 RA
= (RA
>> 1) | 0x80;
311 RA
= (RA
<< 1) | (RF
& CF
);
312 SETFLAGS(HF
| NF
| CF
, btmp
>> 7);
320 SETFLAGS(HF
| NF
| CF
, RA
& 0x01);
322 RA
= (RA
>> 1) | 0x80;
337 if(flag
& CF
) RA
+= 0x60;
338 else if(RA
> 0x99) RA
+= 0x60, flag
|= CF
;
340 if(flag
& HF
) RA
+= 0x06;
341 else if((RA
& 0x0F) > 9) RA
+= 0x06, flag
|= HF
;
344 if(flag
& CF
) RA
-= 0x60;
345 else if(RA
> 0x99) RA
-= 0x60, flag
|= CF
;
347 if(flag
& HF
) RA
-= 0x06;
348 else if((RA
& 0x0F) > 9) RA
-= 0x06, flag
|= HF
;
350 flag
= (flag
& ~(SF
| ZF
| PVF
| B3F
| B5F
)) | TAB(orf_tbl
)[RA
];
365 SETFLAGS(HF
| NF
, CF
);
371 RF
= (RF
^ CF
) & ~(NF
);
376 #include "z80_op1x.c"