50 std::span<const byte*, CacheLine::NUM>
read;
51 std::span< byte*, CacheLine::NUM>
write;
54template<
typename CPU_POLICY>
67 void doReset(EmuTime::param time);
83 void warp(EmuTime::param time);
85 void wait(EmuTime::param time);
86 EmuTime
waitCycles(EmuTime::param time,
unsigned cycles);
89 return {readCacheLine, writeCacheLine};
91 [[nodiscard]]
bool isM1Cycle(
unsigned address)
const;
94 std::span<const TclObject> tokens,
126 template<
typename Archive>
127 void serialize(Archive& ar,
unsigned version);
130 void execute2(
bool fastForward);
131 [[nodiscard]]
bool needExitCPULoop();
132 void setSlowInstructions();
140 std::array<const byte*, CacheLine::NUM> readCacheLine;
141 std::array< byte*, CacheLine::NUM> writeCacheLine;
159 int slowInstructions;
167 bool nmiEdge =
false;
169 std::atomic<bool> exitLoop =
false;
178 inline void cpuTracePre();
179 inline void cpuTracePost();
180 void cpuTracePost_slow();
182 inline byte READ_PORT(
word port,
unsigned cc);
183 inline void WRITE_PORT(
word port,
byte value,
unsigned cc);
185 template<
bool PRE_PB,
bool POST_PB>
186 byte RDMEMslow(
unsigned address,
unsigned cc);
187 template<
bool PRE_PB,
bool POST_PB>
188 inline byte RDMEM_impl2(
unsigned address,
unsigned cc);
189 template<
bool PRE_PB,
bool POST_PB>
190 inline byte RDMEM_impl (
unsigned address,
unsigned cc);
191 template<
unsigned PC_OFFSET>
192 inline byte RDMEM_OPCODE(
unsigned cc);
193 inline byte RDMEM(
unsigned address,
unsigned cc);
195 template<
bool PRE_PB,
bool POST_PB>
196 word RD_WORD_slow(
unsigned address,
unsigned cc);
197 template<
bool PRE_PB,
bool POST_PB>
198 inline word RD_WORD_impl2(
unsigned address,
unsigned cc);
199 template<
bool PRE_PB,
bool POST_PB>
200 inline word RD_WORD_impl (
unsigned address,
unsigned cc);
201 template<
unsigned PC_OFFSET>
202 inline word RD_WORD_PC(
unsigned cc);
203 inline word RD_WORD(
unsigned address,
unsigned cc);
205 template<
bool PRE_PB,
bool POST_PB>
206 void WRMEMslow(
unsigned address,
byte value,
unsigned cc);
207 template<
bool PRE_PB,
bool POST_PB>
208 inline void WRMEM_impl2(
unsigned address,
byte value,
unsigned cc);
209 template<
bool PRE_PB,
bool POST_PB>
210 inline void WRMEM_impl (
unsigned address,
byte value,
unsigned cc);
211 inline void WRMEM(
unsigned address,
byte value,
unsigned cc);
213 void WR_WORD_slow(
unsigned address,
word value,
unsigned cc);
214 inline void WR_WORD(
unsigned address,
word value,
unsigned cc);
216 template<
bool PRE_PB,
bool POST_PB>
217 void WR_WORD_rev_slow(
unsigned address,
word value,
unsigned cc);
218 template<
bool PRE_PB,
bool POST_PB>
219 inline void WR_WORD_rev2(
unsigned address,
word value,
unsigned cc);
220 template<
bool PRE_PB,
bool POST_PB>
221 inline void WR_WORD_rev (
unsigned address,
word value,
unsigned cc);
223 void executeInstructions();
228 [[nodiscard]]
ExecIRQ getExecIRQ()
const;
229 void executeSlow(
ExecIRQ execIRQ);
231 template<Reg8> [[nodiscard]]
inline byte get8()
const;
232 template<Reg16> [[nodiscard]]
inline word get16()
const;
233 template<Reg8>
inline void set8 (
byte x);
234 template<Reg16>
inline void set16(
word x);
236 template<Reg8 DST, Reg8 SRC,
int EE>
inline II ld_R_R();
237 template<Reg16 REG,
int EE>
inline II ld_sp_SS();
238 template<Reg16 REG>
inline II ld_SS_a();
239 template<Reg8 SRC>
inline II ld_xhl_R();
240 template<Reg16 IXY, Reg8 SRC>
inline II ld_xix_R();
242 inline II ld_xhl_byte();
243 template<Reg16 IXY>
inline II ld_xix_byte();
245 template<
int EE>
inline II WR_NN_Y(
word reg);
246 template<Reg16 REG,
int EE>
inline II ld_xword_SS();
247 template<Reg16 REG>
inline II ld_xword_SS_ED();
248 template<Reg16 REG>
inline II ld_a_SS();
250 inline II ld_xbyte_a();
251 inline II ld_a_xbyte();
253 template<Reg8 DST,
int EE>
inline II ld_R_byte();
254 template<Reg8 DST>
inline II ld_R_xhl();
255 template<Reg8 DST, Reg16 IXY>
inline II ld_R_xix();
257 template<
int EE>
inline word RD_P_XX();
258 template<Reg16 REG,
int EE>
inline II ld_SS_xword();
259 template<Reg16 REG>
inline II ld_SS_xword_ED();
261 template<Reg16 REG,
int EE>
inline II ld_SS_word();
263 inline void ADC(
byte reg);
265 template<Reg8 SRC,
int EE>
inline II adc_a_R();
266 inline II adc_a_byte();
267 inline II adc_a_xhl();
268 template<Reg16 IXY>
inline II adc_a_xix();
270 inline void ADD(
byte reg);
272 template<Reg8 SRC,
int EE>
inline II add_a_R();
273 inline II add_a_byte();
274 inline II add_a_xhl();
275 template<Reg16 IXY>
inline II add_a_xix();
277 inline void AND(
byte reg);
279 template<Reg8 SRC,
int EE>
inline II and_R();
280 inline II and_byte();
282 template<Reg16 IXY>
inline II and_xix();
284 inline void CP(
byte reg);
286 template<Reg8 SRC,
int EE>
inline II cp_R();
289 template<Reg16 IXY>
inline II cp_xix();
291 inline void OR(
byte reg);
293 template<Reg8 SRC,
int EE>
inline II or_R();
296 template<Reg16 IXY>
inline II or_xix();
298 inline void SBC(
byte reg);
300 template<Reg8 SRC,
int EE>
inline II sbc_a_R();
301 inline II sbc_a_byte();
302 inline II sbc_a_xhl();
303 template<Reg16 IXY>
inline II sbc_a_xix();
305 inline void SUB(
byte reg);
307 template<Reg8 SRC,
int EE>
inline II sub_R();
308 inline II sub_byte();
310 template<Reg16 IXY>
inline II sub_xix();
312 inline void XOR(
byte reg);
314 template<Reg8 SRC,
int EE>
inline II xor_R();
315 inline II xor_byte();
317 template<Reg16 IXY>
inline II xor_xix();
319 inline byte DEC(
byte reg);
320 template<Reg8 REG,
int EE>
inline II dec_R();
321 template<
int EE>
inline void DEC_X(
unsigned x);
323 template<Reg16 IXY>
inline II dec_xix();
325 inline byte INC(
byte reg);
326 template<Reg8 REG,
int EE>
inline II inc_R();
327 template<
int EE>
inline void INC_X(
unsigned x);
329 template<Reg16 IXY>
inline II inc_xix();
331 template<Reg16 REG>
inline II adc_hl_SS();
332 inline II adc_hl_hl();
333 template<Reg16 REG1, Reg16 REG2,
int EE>
inline II add_SS_TT();
334 template<Reg16 REG,
int EE>
inline II add_SS_SS();
335 template<Reg16 REG>
inline II sbc_hl_SS();
336 inline II sbc_hl_hl();
338 template<Reg16 REG,
int EE>
inline II dec_SS();
339 template<Reg16 REG,
int EE>
inline II inc_SS();
341 template<
unsigned N, Reg8 REG>
inline II bit_N_R();
342 template<
unsigned N>
inline II bit_N_xhl();
343 template<
unsigned N>
inline II bit_N_xix(
unsigned a);
345 template<
unsigned N, Reg8 REG>
inline II res_N_R();
346 template<
int EE>
inline byte RES_X(
unsigned bit,
unsigned addr);
347 template<
unsigned N>
inline II res_N_xhl();
348 template<
unsigned N, Reg8 REG>
inline II res_N_xix_R(
unsigned a);
350 template<
unsigned N, Reg8 REG>
inline II set_N_R();
351 template<
int EE>
inline byte SET_X(
unsigned bit,
unsigned addr);
352 template<
unsigned N>
inline II set_N_xhl();
353 template<
unsigned N, Reg8 REG>
inline II set_N_xix_R(
unsigned a);
355 inline byte RL(
byte reg);
356 template<
int EE>
inline byte RL_X(
unsigned x);
357 template<Reg8 REG>
inline II rl_R();
359 template<Reg8 REG>
inline II rl_xix_R(
unsigned a);
361 inline byte RLC(
byte reg);
362 template<
int EE>
inline byte RLC_X(
unsigned x);
363 template<Reg8 REG>
inline II rlc_R();
365 template<Reg8 REG>
inline II rlc_xix_R(
unsigned a);
367 inline byte RR(
byte reg);
368 template<
int EE>
inline byte RR_X(
unsigned x);
369 template<Reg8 REG>
inline II rr_R();
371 template<Reg8 REG>
inline II rr_xix_R(
unsigned a);
373 inline byte RRC(
byte reg);
374 template<
int EE>
inline byte RRC_X(
unsigned x);
375 template<Reg8 REG>
inline II rrc_R();
377 template<Reg8 REG>
inline II rrc_xix_R(
unsigned a);
379 inline byte SLA(
byte reg);
380 template<
int EE>
inline byte SLA_X(
unsigned x);
381 template<Reg8 REG>
inline II sla_R();
383 template<Reg8 REG>
inline II sla_xix_R(
unsigned a);
385 inline byte SLL(
byte reg);
386 template<
int EE>
inline byte SLL_X(
unsigned x);
387 template<Reg8 REG>
inline II sll_R();
389 template<Reg8 REG>
inline II sll_xix_R(
unsigned a);
392 inline byte SRA(
byte reg);
393 template<
int EE>
inline byte SRA_X(
unsigned x);
394 template<Reg8 REG>
inline II sra_R();
396 template<Reg8 REG>
inline II sra_xix_R(
unsigned a);
398 inline byte SRL(
byte reg);
399 template<
int EE>
inline byte SRL_X(
unsigned x);
400 template<Reg8 REG>
inline II srl_R();
402 template<Reg8 REG>
inline II srl_xix_R(
unsigned a);
412 template<
int EE>
inline void PUSH(
word reg);
413 template<Reg16 REG,
int EE>
inline II push_SS();
414 template<
int EE>
inline word POP();
415 template<Reg16 REG,
int EE>
inline II pop_SS();
417 template<
typename COND>
inline II call(COND cond);
418 template<
unsigned ADDR>
inline II rst();
420 template<
int EE,
typename COND>
inline II RET(COND cond);
421 template<
typename COND>
inline II ret(COND cond);
425 template<Reg16 REG,
int EE>
inline II jp_SS();
426 template<
typename COND>
inline II jp(COND cond);
427 template<
typename COND>
inline II jr(COND cond);
430 template<Reg16 REG,
int EE>
inline II ex_xsp_SS();
432 template<Reg8 REG>
inline II in_R_c();
433 inline II in_a_byte();
434 template<Reg8 REG>
inline II out_c_R();
436 inline II out_byte_a();
438 inline II BLOCK_CP(
int increase,
bool repeat);
444 inline II BLOCK_LD(
int increase,
bool repeat);
450 inline II BLOCK_IN(
int increase,
bool repeat);
456 inline II BLOCK_OUT(
int increase,
bool repeat);
462 template<
int EE = 0>
inline II nop();
468 inline II ex_af_af();
469 inline II ex_de_hl();
474 template<
unsigned N>
inline II im_N();
476 template<Reg8 REG>
inline II ld_a_IR();
480 template<Reg8 REG>
inline II mulub_a_R();
481 template<Reg16 REG>
inline II muluw_hl_SS();
void setInterface(MSXCPUInterface *interface_)
void lowerIRQ()
Lowers the maskable interrupt count.
void setNextSyncPoint(EmuTime::param time)
void disasmCommand(Interpreter &interp, std::span< const TclObject > tokens, TclObject &result) const
void setFreq(unsigned freq)
Change the clock freq.
void execute(bool fastForward)
void warp(EmuTime::param time)
CPUCore(MSXMotherBoard &motherboard, const std::string &name, const BooleanSetting &traceSetting, TclCallback &diHaltCallback, EmuTime::param time)
void lowerNMI()
Lowers the non-maskable interrupt count.
void exitCPULoopSync()
Request to exit the main CPU emulation loop.
EmuTime::param getCurrentTime() const
void exitCPULoopAsync()
Similar to exitCPULoopSync(), but this method may be called from any thread.
void raiseNMI()
Raises the non-maskable interrupt count.
void serialize(Archive &ar, unsigned version)
void doReset(EmuTime::param time)
Reset the CPU.
void wait(EmuTime::param time)
EmuTime waitCycles(EmuTime::param time, unsigned cycles)
bool isM1Cycle(unsigned address) const
CacheLines getCacheLines()
void raiseIRQ()
Raises the maskable interrupt count.
A Setting with an integer value.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
std::span< const byte *, CacheLine::NUM > read
std::span< byte *, CacheLine::NUM > write
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.