9static constexpr char sign(
unsigned char a)
11 return (a & 128) ?
'-' :
'+';
14static constexpr int abs(
unsigned char a)
16 return (a & 128) ? (256 - a) : a;
20 std::string& dest, EmuTime::param time)
22 const char* r =
nullptr;
24 buf[0] = interface.
peekMem(pc, time);
25 auto [s, i] = [&]() -> std::pair<const char*, unsigned> {
28 buf[1] = interface.
peekMem(pc + 1, time);
31 buf[1] = interface.
peekMem(pc + 1, time);
35 r = (buf[0] == 0xDD) ?
"ix" :
"iy";
36 buf[1] = interface.
peekMem(pc + 1, time);
40 buf[2] = interface.
peekMem(pc + 2, time);
41 buf[3] = interface.
peekMem(pc + 3, time);
49 for (
int j = 0; s[j]; ++j) {
52 buf[i] = interface.
peekMem(narrow_cast<word>(pc + i), time);
54 static_cast<uint16_t
>(buf[i])));
58 buf[i] = interface.
peekMem(narrow_cast<word>(pc + i), time);
60 pc + 2 +
static_cast<int8_t
>(buf[i])));
64 buf[i + 0] = interface.
peekMem(narrow_cast<word>(pc + i + 0), time);
65 buf[i + 1] = interface.
peekMem(narrow_cast<word>(pc + i + 1), time);
66 strAppend(dest,
'#', hex_string<4>(buf[i] + buf[i + 1] * 256));
70 buf[i] = interface.
peekMem(narrow_cast<word>(pc + i), time);
71 strAppend(dest,
'(', r, sign(buf[i]),
'#',
72 hex_string<2>(abs(buf[i])),
')');
76 strAppend(dest, r, sign(buf[2]),
'#', hex_string<2>(abs(buf[2])));
82 dest =
strCat(
"db #ED,#", hex_string<2>(buf[1]),
86 dest =
strCat(
"db #", hex_string<2>(buf[0]),
90 dest =
strCat(
"db #", hex_string<2>(buf[0]),
91 ",#CB,#", hex_string<2>(buf[2]),
103 dest.resize(19,
' ');
byte peekMem(word address, EmuTime::param time) const
Peek memory location.
This file implemented 3 utility functions:
const std::array< const char *, 256 > mnemonic_xx
unsigned dasm(const MSXCPUInterface &interface, word pc, std::span< byte, 4 > buf, std::string &dest, EmuTime::param time)
Disassemble.
const std::array< const char *, 256 > mnemonic_ed
const std::array< const char *, 256 > mnemonic_xx_cb
const std::array< const char *, 256 > mnemonic_cb
const std::array< const char *, 256 > mnemonic_main
uint16_t word
16 bit unsigned integer
std::string strCat(Ts &&...ts)
void strAppend(std::string &result, Ts &&...ts)