diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2019-01-12 14:56:05 -0500 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2019-01-12 14:56:05 -0500 |
commit | 01e459a7119a94475301d397f9c1f8b8487bb58b (patch) | |
tree | bdb39045ead9e5b732486127ad5e9ceb726b66eb /src/tools | |
parent | 830b4608195476c37c6c62de240526a47601fab5 (diff) |
unidasm: Don't blow up when TMS34010 disassembler tries to read 32-bit operands
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/unidasm.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index e811991b872..328527c85ce 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -841,8 +841,6 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const case 3: lr8 = [](offs_t pc) -> u8 { abort(); }; - lr32 = [](offs_t pc) -> u32 { abort(); }; - lr64 = [](offs_t pc) -> u64 { abort(); }; lr16 = [this](offs_t pc) -> u16 { if(pc < base_pc) return 0x0000; @@ -851,6 +849,31 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const return 0x0000; return reinterpret_cast<const u16 *>(&data[delta])[0]; }; + switch(entry->endian) { + case le: + lr32 = [this](offs_t pc) -> u32 { + if(pc < base_pc) + return 0x00000000; + offs_t delta = (pc - base_pc) >> 3; + if(delta >= size + 2) + return 0x00000000; + auto p = reinterpret_cast<const u16 *>(&data[delta]); + return p[0] | (u32(p[1]) << 16); + }; + break; + case be: + lr32 = [this](offs_t pc) -> u32 { + if(pc < base_pc) + return 0x00000000; + offs_t delta = (pc - base_pc) >> 3; + if(delta >= size + 2) + return 0x00000000; + auto p = reinterpret_cast<const u16 *>(&data[delta]); + return (u32(p[0]) << 16) | p[1]; + }; + break; + } + lr64 = [](offs_t pc) -> u64 { abort(); }; break; default: |