home *** CD-ROM | disk | FTP | other *** search
-
- /* Z80.h : Registers and primitives.
- *
- * Copyright 1996 Rui Fernando Ferreira Ribeiro.
- *
- * 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.
- *
- * 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.
- */
-
- #include "quirks.h"
-
- /* Do not change the order!
- */
- struct Z80word_reg
- {
- USHORT bc, de, hl, af;
- };
-
- struct Z80byte_reg
- {
- #if !defined (M68000)
- UCHAR c, b, e, d, l, h, f, a;
- #else
- UCHAR b, c, d, e, h, l, a, f;
- #endif
- };
-
- union Z80Regs
- {
- struct Z80word_reg x;
- struct Z80byte_reg k;
- USHORT wregs[4];
- UCHAR bregs[8];
- };
-
-
- /*
- * Flags (F) : 7 6 5 4 3 2 1 0
- * ---------------------------------
- * | S | Z | X | H | Y | P | N | C |
- * ---------------------------------
- */
- struct CPU_flags
- {
- USHORT _S; /* Sign */
- USHORT _Z; /* Zero */
- USHORT _X; /* Auxiliary Overflow ? */ /* Undocumented */
- USHORT _H; /* Half carry */
- USHORT _Y; /* Auxliary Half carry ? */ /* Undocumented */
- USHORT _P; /* Parity - overflow - P/V */
- USHORT _N; /* Subtraction */
- USHORT _C; /* Carry */
- };
-
- /* Shortcuts */
-
- #define BC Z80Regs.x.bc /* Z80Wreg(0) -- BC */
- #define DE Z80Regs.x.de /* Z80Wreg(1) -- DE */
- #define HL Z80Regs.x.hl /* Z80Wreg(2) -- HL */
- #define AF Z80Regs.x.af /* Z80Wreg(3) -- AF */
- #define B Z80Regs.k.b /* Z80Breg(0) -- B */
- #define C Z80Regs.k.c /* Z80Breg(1) -- C */
- #define D Z80Regs.k.d /* Z80Breg(2) -- D */
- #define E Z80Regs.k.e /* Z80Breg(3) -- E */
- #define H Z80Regs.k.h /* Z80Breg(4) -- H */
- #define L Z80Regs.k.l /* Z80Breg(5) -- L */
- #define A Z80Regs.k.a /* Z80Breg(6) -- A */
- #define F Z80Regs.k.f /* Z80Breg(7) -- F */
-
- /* Note: to use F or AF, first build_F() must be called
- */
-
- #define Z80Wreg(elem) Z80Regs.wregs[elem]
- #if !defined (M68000)
- #define Z80Breg(elem) Z80Regs.bregs[(elem)^1]
- #else
- #define Z80Breg(elem) Z80Regs.bregs[elem]
- #endif
-
- /* Alternate register set */
- /* In the 'real' Z80 there is no acess to the alternate register set as a bytes
- , but they might be needed to debugging purposes
- */
- #define BC2 Z80Regs2.x.bc /* Z80Wreg2(0) -- BC' */
- #define DE2 Z80Regs2.x.de /* Z80Wreg2(1) -- DE' */
- #define HL2 Z80Regs2.x.hl /* Z80Wreg2(2) -- HL' */
- #define AF2 Z80Regs2.x.af /* Z80Wreg2(3) -- AF' */
- #define B2 Z80Regs2.k.b /* Z80Breg2(0) -- B' */
- #define C2 Z80Regs2.k.c /* Z80Breg2(1) -- C' */
- #define D2 Z80Regs2.k.d /* Z80Breg2(2) -- D' */
- #define E2 Z80Regs2.k.e /* Z80Breg2(3) -- E' */
- #define H2 Z80Regs2.k.h /* Z80Breg2(4) -- H' */
- #define L2 Z80Regs2.k.l /* Z80Breg2(5) -- L' */
- #define A2 Z80Regs2.k.a /* Z80Breg2(6) -- A' */
- #define F2 Z80Regs2.k.f /* Z80Breg2(7) -- F' */
-
- #define Z80Wreg2(elem) Z80Regs2.wregs[elem]
- #if !defined (M68000)
- #define Z80Breg2(elem) Z80Regs2.bregs[(elem)^1]
- #else
- #define Z80Breg2(elem) Z80Regs2.bregs[elem]
- #endif
-
- union Z80IX
- {
- USHORT IX;
- UCHAR bregs[2];
- };
-
- union Z80IY
- {
- USHORT IY;
- UCHAR bregs[2];
- };
-
- #define IX Z80IX.IX
- #define IY Z80IY.IY
-
- #if !defined (M68000)
- #define HX Z80IX.bregs[1]
- #define LX Z80IX.bregs[0]
- #define HY Z80IY.bregs[1]
- #define LY Z80IY.bregs[0]
- #else
- #define HX Z80IX.bregs[0]
- #define LX Z80IX.bregs[1]
- #define HY Z80IY.bregs[0]
- #define LY Z80IY.bregs[1]
- #endif
-
- /* Clock ticks between each interrupt */
- #define INT_TIME 69888L /* Timing provided by Ian Collier */
-
- /*
- Z80 Timings:
-
- Condition test --> 1T
- Inc/Dec 8 bits reg --> 1T
- Inc/Dec 16 bits reg --> 2T
- PC+n --> 5T
- sum IX+n --> 5T
- read a memory byte --> 3T
- read a port byte --> 4T (3T + 1T in Wait)
- Nmi int --> 6T (3T + 3T - push two words in stack)
- Int IM 0 --> 10T (3T + 3T + 4T from data bus read)
- Int IM 1 --> 6T (3T + 3T)
- Int IM 2 --> 16T (3T + 3T + 4T + 3T + 3T -- the last
- 6T being 2 memory acesses to read the pointer
- built by reg I and the data bus value)
- */
-
- /* EOF: Z80.h */
-