rockbox/apps/plugins/zxbox/z80_op3.c

143 lines
3.3 KiB
C
Raw Normal View History

/*
* Copyright (C) 1996-1998 Szeredi Miklos
* Email: mszeredi@inf.bme.hu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See the file COPYING.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef NO_OPDEF
#include "z80_def.h"
#include "z80_op3.h"
#include "z80_ari.h"
#endif
#define ARIR(arin, func, an, rn, r, n) \
OPDEF(arin ## _ ## rn, 0x80+an*8+n) \
{ \
func(r); \
ENTIME(4); \
}
#define ARIIHL(arin, func, an) \
OPDEF(arin ## _ihl, 0x86+an*8) \
{ \
func(*HLP); \
ENTIME(7); \
}
#define ARIID(arin, func, an, ixyn, ixy) \
OPDEF(arin ## _i ## ixyn ## d, 0x86+an*8)\
{ \
register dbyte addr; \
register byte val; \
IXDGET(ixy, addr); \
val = READ(addr); \
func(val); \
ENTIME(15); \
}
#define ADD_A_R(rn, r, n) ARIR(add_a, ADD, 0, rn, r, n)
#define ADC_A_R(rn, r, n) ARIR(adc_a, ADC, 1, rn, r, n)
#define SUB_R(rn, r, n) ARIR(sub, SUB, 2, rn, r, n)
#define SBC_A_R(rn, r, n) ARIR(sbc_a, SBC, 3, rn, r, n)
#define AND_R(rn, r, n) ARIR(and, AND, 4, rn, r, n)
#define XOR_R(rn, r, n) ARIR(xor, XOR, 5, rn, r, n)
#define OR_R(rn, r, n) ARIR(or, OR, 6, rn, r, n)
#define CP_R(rn, r, n) ARIR(cp, CP, 7, rn, r, n)
ADD_A_R(b, RB, 0)
ADD_A_R(c, RC, 1)
ADD_A_R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