8 static constexpr
char sign(
unsigned char a)
10 return (a & 128) ?
'-' :
'+';
13 static constexpr
int abs(
unsigned char a)
15 return (a & 128) ? (256 - a) : a;
19 std::string& dest, EmuTime::param time)
21 const char* r =
nullptr;
23 buf[0] = interf.
peekMem(pc, time);
24 auto [s, i] = [&]() -> std::pair<const char*, unsigned> {
27 buf[1] = interf.
peekMem(pc + 1, time);
30 buf[1] = interf.
peekMem(pc + 1, time);
34 r = (buf[0] == 0xDD) ?
"ix" :
"iy";
35 buf[1] = interf.
peekMem(pc + 1, time);
39 buf[2] = interf.
peekMem(pc + 2, time);
40 buf[3] = interf.
peekMem(pc + 3, time);
48 for (
int j = 0; s[j]; ++j) {
51 buf[i] = interf.
peekMem(pc + i, time);
53 static_cast<uint16_t
>(buf[i])));
57 buf[i] = interf.
peekMem(pc + i, time);
59 pc + 2 +
static_cast<int8_t
>(buf[i])));
63 buf[i + 0] = interf.
peekMem(pc + i + 0, time);
64 buf[i + 1] = interf.
peekMem(pc + i + 1, time);
65 strAppend(dest,
'#', hex_string<4>(buf[i] + buf[i + 1] * 256));
69 buf[i] = interf.
peekMem(pc + i, time);
70 strAppend(dest,
'(', r, sign(buf[i]),
'#',
71 hex_string<2>(abs(buf[i])),
')');
75 strAppend(dest, r, sign(buf[2]),
'#', hex_string<2>(abs(buf[2])));
81 dest =
strCat(
"db #ED,#", hex_string<2>(buf[1]),
85 dest =
strCat(
"db #", hex_string<2>(buf[0]),
89 dest =
strCat(
"db #", hex_string<2>(buf[0]),
90 ",#CB,#", hex_string<2>(buf[2]),
102 dest.resize(19,
' ');
byte peekMem(word address, EmuTime::param time) const
Peek memory location.
This file implemented 3 utility functions:
const char * mnemonic_cb[256]
unsigned dasm(const MSXCPUInterface &interf, word pc, byte buf[4], std::string &dest, EmuTime::param time)
Disassemble.
const char * mnemonic_ed[256]
uint16_t word
16 bit unsigned integer
const char * mnemonic_main[256]
const char * mnemonic_xx[256]
const char * mnemonic_xx_cb[256]
std::string strCat(Ts &&...ts)
void strAppend(std::string &result, Ts &&...ts)