-
Notifications
You must be signed in to change notification settings - Fork 0
/
instr_main_q1.cpp
38 lines (33 loc) · 1.08 KB
/
instr_main_q1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "instr_decoder.h"
#include "z80emu.h"
#include <assert.h>
using namespace llz80emu;
void z80_instr_decoder::exec_main_q1() {
_regs.Q = 0; // we don't modify flags here
if(_regs.instr == 0x76) {
if (_mod == Z80_MOD_NONE) {
// HALT
// _regs.REG_PC--;
reset(true);
return;
}
else {
// undefined opcode
reset();
return;
}
}
/* decode source and destination register */
const uint8_t* src = reg8(_z); uint8_t* dst = reg8(_y);
assert(src || dst); // at least one must be non-null
if (!src || !dst) {
/* two-step operation: initiate memory read/write on step=0, then return to fetching on step=1 */
if (!_step) {
if (!process_hlptr()) return; // _hl_ptr isn't ready yet
if(!src) _ctx.start_mem_read_cycle(_hl_ptr, *reg8_nomod(_y)); // read from (HL) - if (HL) is already used then L/H won't be replaced with IXL/IXH or IYL/IYH
else _ctx.start_mem_write_cycle(_hl_ptr, *reg8_nomod(_z)); // write to (HL)
return;
}
} else *dst = *src; // copy from source to destination (normal business, takes a single step)
reset(); // return to fetching
}