2 * Z80 execution defines
4 * Copyright (c) 2007-2009 Stuart Brady <stuart.brady@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
21 #include "dyngen-exec.h"
23 #define TARGET_LONG_BITS 32
27 /* at least 4 register variables are defined */
28 register struct CPUZ80State
*env
asm(AREG0
);
30 #if TARGET_LONG_BITS > HOST_LONG_BITS
32 /* no registers can be used */
38 /* XXX: use unsigned long instead of target_ulong - better code will
39 be generated for 64 bit CPUs */
40 register target_ulong T0
asm(AREG1
);
41 register target_ulong T1
asm(AREG2
);
43 #endif /* ! (TARGET_LONG_BITS > HOST_LONG_BITS) */
47 #define A (env->regs[R_A])
48 #define F (env->regs[R_F])
49 #define BC (env->regs[R_BC])
50 #define DE (env->regs[R_DE])
51 #define HL (env->regs[R_HL])
52 #define IX (env->regs[R_IX])
53 #define IY (env->regs[R_IY])
54 #define SP (env->regs[R_SP])
55 #define I (env->regs[R_I])
56 #define R (env->regs[R_R])
57 #define AX (env->regs[R_AX])
58 #define FX (env->regs[R_FX])
59 #define BCX (env->regs[R_BCX])
60 #define DEX (env->regs[R_DEX])
61 #define HLX (env->regs[R_HLX])
68 void do_interrupt(CPUZ80State
*env
);
69 void raise_interrupt(int intno
, int is_int
, int error_code
,
71 void raise_exception_err(int exception_index
, int error_code
);
72 void raise_exception(int exception_index
);
74 #if !defined(CONFIG_USER_ONLY)
76 #include "softmmu_exec.h"
78 #endif /* !defined(CONFIG_USER_ONLY) */
80 extern const uint8_t parity_table
[256];
82 static inline void env_to_regs(void)
100 IX
= env
->regs
[R_IX
];
103 IY
= env
->regs
[R_IY
];
106 SP
= env
->regs
[R_SP
];
115 AX
= env
->regs
[R_AX
];
118 FX
= env
->regs
[R_FX
];
121 BCX
= env
->regs
[R_BCX
];
124 DEX
= env
->regs
[R_DEX
];
127 HLX
= env
->regs
[R_HLX
];
131 static inline void regs_to_env(void)
140 env
->regs
[R_BC
] = BC
;
143 env
->regs
[R_DE
] = DE
;
146 env
->regs
[R_HL
] = HL
;
149 env
->regs
[R_IX
] = IX
;
152 env
->regs
[R_IY
] = IY
;
155 env
->regs
[R_SP
] = SP
;
164 env
->regs
[R_AX
] = AX
;
167 env
->regs
[R_FX
] = FX
;
170 env
->regs
[R_BCX
] = BCX
;
173 env
->regs
[R_DEX
] = DEX
;
176 env
->regs
[R_HLX
] = HLX
;
180 static inline int cpu_has_work(CPUState
*env
)
182 return env
->interrupt_request
& CPU_INTERRUPT_HARD
;
185 static inline int cpu_halted(CPUState
*env
)
190 //printf("%s: at PC 0x%x halted == %d, irq %d\n",__FUNCTION__, env->pc, env->halted,env->interrupt_request);
191 if (cpu_has_work(env
)) {