1 /* Header file for the instruction set simulator.
2 Copyright (C) 1995 Frank D. Cringle.
4 This file is part of yaze - yet another Z80 emulator.
6 Yaze is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 typedef unsigned char BYTE
;
25 #error Need to find an 8-bit type for BYTE
28 #if USHRT_MAX == 65535
29 typedef unsigned short WORD
;
31 #error Need to find an 16-bit type for WORD
34 /* FASTREG needs to be at least 16 bits wide and efficient for the
37 typedef unsigned int FASTREG
;
39 typedef unsigned long FASTREG
;
42 /* FASTWORK needs to be wider than 16 bits and efficient for the host
45 typedef unsigned int FASTWORK
;
47 typedef unsigned long FASTWORK
;
50 /* two sets of accumulator / flags */
54 /* two sets of 16-bit registers */
55 extern struct ddregs
{
72 extern BYTE ram
[MEMSIZE
*1024];
74 extern BYTE
*pagetable
[MEMSIZE
/4];
78 extern volatile int stopsim
;
81 extern FASTWORK
simz80(FASTREG PC
, int, int (*)());
90 #define SETFLAG(f,c) AF = (c) ? AF | FLAG_ ## f : AF & ~FLAG_ ## f
91 #define TSTFLAG(f) ((AF & FLAG_ ## f) != 0)
93 #define ldig(x) ((x) & 0xf)
94 #define hdig(x) (((x)>>4)&0xf)
95 #define lreg(x) ((x)&0xff)
96 #define hreg(x) (((x)>>8)&0xff)
98 #define Setlreg(x, v) x = (((x)&0xff00) | ((v)&0xff))
99 #define Sethreg(x, v) x = (((x)&0xff) | (((v)&0xff) << 8))
102 #define RAM(a) *(pagetable[((a)&0xffff)>>12]+((a)&0x0fff))
104 #define RAM(a) ram[(a)&0xffff]
106 #define GetBYTE(a) RAM(a)
108 /* Fast write inside [3K; 64K-8K]
110 NOTICE: This is dependent on the assumption that the 8KB Basic ROM
114 void slow_write(unsigned int a
, unsigned char v
);
115 #define PutBYTE(a,v) \
117 if (((a + 8192) & 0xFFFF) > 11*1024) \
123 /*#define PutBYTE(a, v) RAM(a) = v*/
125 #define GetWORD(a) (RAM(a) | (RAM((a)+1) << 8))
126 #define PutWORD(a, v) \
127 do { PutBYTE(a, ((int)(v)&255)); \
128 PutBYTE((a)+1, (v) >> 8); \
132 extern int in(unsigned int);
133 extern void out(unsigned int, unsigned char);
134 #define Input(port) in(port)
135 #define Output(port, value) out(port,value)
137 /* Define these as macros or functions if you really want to simulate I/O */
138 #define Input(port) 0
139 #define Output(port, value)