diff options
Diffstat (limited to 'src/tools/unidasm.cpp')
-rw-r--r-- | src/tools/unidasm.cpp | 141 |
1 files changed, 89 insertions, 52 deletions
diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 08dad29b6d7..f45dafcc9b3 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -52,6 +52,7 @@ using util::BIT; #include "cpu/f8/f8dasm.h" #include "cpu/fr/frdasm.h" #include "cpu/g65816/g65816ds.h" +#include "cpu/gigatron/gigatrondasm.h" #include "cpu/h6280/6280dasm.h" #include "cpu/h8/h8d.h" #include "cpu/h8/h8hd.h" @@ -370,6 +371,7 @@ static const dasm_table_entry dasm_table[] = { "f8", be, 0, []() -> util::disasm_interface * { return new f8_disassembler; } }, { "fr", be, 0, []() -> util::disasm_interface * { return new fr_disassembler; } }, { "g65816", le, 0, []() -> util::disasm_interface * { return new g65816_disassembler(&g65816_unidasm); } }, + { "gigatron", be, -1, []() -> util::disasm_interface * { return new gigatron_disassembler; } }, { "h6280", le, 0, []() -> util::disasm_interface * { return new h6280_disassembler; } }, { "h8", be, 0, []() -> util::disasm_interface * { return new h8_disassembler; } }, { "h8h", be, 0, []() -> util::disasm_interface * { return new h8h_disassembler; } }, @@ -602,18 +604,17 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const switch(entry->pcshift) { case -1: lr8 = [](offs_t pc) -> u8 { throw std::logic_error("debug_disasm_buffer::debug_data_buffer: r8 access on 16-bits granularity bus\n"); }; - lr16 = [this](offs_t pc) -> u16 { - const u16 *src = get_ptr<u16>(pc); - return src[0]; - }; - switch(entry->endian) { case le: + lr16 = [this](offs_t pc) -> u16 { + const u16 *src = get_ptr<u16>(pc); + return little_endianize_int16(src[0]); + }; lr32 = [this, page_mask](offs_t pc) -> u32 { offs_t lpc = disasm->pc_real_to_linear(pc); u32 r = 0; for(int j=0; j != 2; j++) { - r |= get<u16>(disasm->pc_linear_to_real(lpc)) << (j*16); + r |= little_endianize_int16(get<u16>(disasm->pc_linear_to_real(lpc))) << (j*16); lpc = (lpc & ~page_mask) | ((lpc + 1) & page_mask); } return r; @@ -622,7 +623,7 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const offs_t lpc = disasm->pc_real_to_linear(pc); u64 r = 0; for(int j=0; j != 4; j++) { - r |= u64(get<u16>(disasm->pc_linear_to_real(lpc))) << (j*16); + r |= u64(little_endianize_int16(get<u16>(disasm->pc_linear_to_real(lpc)))) << (j*16); lpc = (lpc & ~page_mask) | ((lpc + 1) & page_mask); } return r; @@ -630,11 +631,15 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const break; case be: + lr16 = [this](offs_t pc) -> u16 { + const u16 *src = get_ptr<u16>(pc); + return big_endianize_int16(src[0]); + }; lr32 = [this, page_mask](offs_t pc) -> u32 { offs_t lpc = disasm->pc_real_to_linear(pc); u32 r = 0; for(int j=0; j != 2; j++) { - r |= get<u16>(disasm->pc_linear_to_real(lpc)) << ((1-j)*16); + r |= big_endianize_int16(get<u16>(disasm->pc_linear_to_real(lpc))) << ((1-j)*16); lpc = (lpc & ~page_mask) | ((lpc + 1) & page_mask); } return r; @@ -643,7 +648,7 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const offs_t lpc = disasm->pc_real_to_linear(pc); u64 r = 0; for(int j=0; j != 4; j++) { - r |= u64(get<u16>(disasm->pc_linear_to_real(lpc))) << ((3-j)*16); + r |= u64(big_endianize_int16(get<u16>(disasm->pc_linear_to_real(lpc)))) << ((3-j)*16); lpc = (lpc & ~page_mask) | ((lpc + 1) & page_mask); } return r; @@ -796,46 +801,52 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const case -1: lr8 = [](offs_t pc) -> u8 { abort(); }; - lr16 = [this](offs_t pc) -> u16 { - const u16 *p = get_ptr<u16>(pc); - return p ? - p[0] - : 0x0000; - }; switch(entry->endian) { case le: + lr16 = [this](offs_t pc) -> u16 { + const u16 *p = get_ptr<u16>(pc); + return p ? + little_endianize_int16(p[0]) + : 0x0000; + }; lr32 = [this](offs_t pc) -> u32 { const u16 *p = get_ptr<u16>(pc); return p ? - p[0] | - (p[1] << 16) + little_endianize_int16(p[0]) | + (little_endianize_int16(p[1]) << 16) : 0x00000000; }; lr64 = [this](offs_t pc) -> u64 { const u16 *p = get_ptr<u16>(pc); return p ? - p[0] | - (p[1] << 16) | - (u64(p[2]) << 32) | - (u64(p[3]) << 48) + little_endianize_int16(p[0]) | + (little_endianize_int16(p[1]) << 16) | + (u64(little_endianize_int16(p[2])) << 32) | + (u64(little_endianize_int16(p[3])) << 48) : 0x0000000000000000; }; break; case be: + lr16 = [this](offs_t pc) -> u16 { + const u16 *p = get_ptr<u16>(pc); + return p ? + big_endianize_int16(p[0]) + : 0x0000; + }; lr32 = [this](offs_t pc) -> u32 { const u16 *p = get_ptr<u16>(pc); return p ? - (p[0] << 16)| - p[1] + (big_endianize_int16(p[0]) << 16)| + big_endianize_int16(p[1]) : 0x00000000; }; lr64 = [this](offs_t pc) -> u64 { const u16 *p = get_ptr<u16>(pc); return p ? - (u64(p[0]) << 48) | - (u64(p[1]) << 32) | - (p[2] << 16) | - p[3] + (u64(big_endianize_int16(p[0])) << 48) | + (u64(big_endianize_int16(p[1])) << 32) | + (big_endianize_int16(p[2]) << 16) | + big_endianize_int16(p[3]) : 0x0000000000000000; }; break; @@ -845,28 +856,34 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const case -2: lr8 = [](offs_t pc) -> u8 { abort(); }; lr16 = [](offs_t pc) -> u16 { abort(); }; - lr32 = [this](offs_t pc) -> u32 { - const u32 *p = get_ptr<u32>(pc); - return p ? - p[0] - : 0x00000000; - }; switch(entry->endian) { case le: + lr32 = [this](offs_t pc) -> u32 { + const u32 *p = get_ptr<u32>(pc); + return p ? + little_endianize_int32(p[0]) + : 0x00000000; + }; lr64 = [this](offs_t pc) -> u64 { const u32 *p = get_ptr<u32>(pc); return p ? - p[0] | - (u64(p[1]) << 32) + little_endianize_int32(p[0]) | + (u64(little_endianize_int32(p[1])) << 32) : 0x0000000000000000; }; break; case be: + lr32 = [this](offs_t pc) -> u32 { + const u32 *p = get_ptr<u32>(pc); + return p ? + big_endianize_int32(p[0]) + : 0x00000000; + }; lr64 = [this](offs_t pc) -> u64 { const u32 *p = get_ptr<u32>(pc); return p ? - (u64(p[0]) << 32) | - p[1] + (u64(big_endianize_int32(p[0])) << 32) | + big_endianize_int32(p[1]) : 0x0000000000000000; }; break; @@ -877,26 +894,38 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const lr8 = [](offs_t pc) -> u8 { abort(); }; lr16 = [](offs_t pc) -> u16 { abort(); }; lr32 = [](offs_t pc) -> u32 { abort(); }; - lr64 = [this](offs_t pc) -> u64 { - const u64 *p = get_ptr<u64>(pc); - return p ? - p[0] - : 0x0000000000000000; + switch(entry->endian) { + case le: + lr64 = [this](offs_t pc) -> u64 { + const u64 *p = get_ptr<u64>(pc); + return p ? + little_endianize_int64(p[0]) + : 0x0000000000000000; + }; + break; + case be: + lr64 = [this](offs_t pc) -> u64 { + const u64 *p = get_ptr<u64>(pc); + return p ? + big_endianize_int64(p[0]) + : 0x0000000000000000; + }; + break; }; break; case 3: lr8 = [](offs_t pc) -> u8 { abort(); }; - lr16 = [this](offs_t pc) -> u16 { - if(pc < base_pc) - return 0x0000; - offs_t delta = (pc - base_pc) >> 3; - if(delta >= size) - return 0x0000; - return reinterpret_cast<const u16 *>(&data[delta])[0]; - }; switch(entry->endian) { case le: + lr16 = [this](offs_t pc) -> u16 { + if(pc < base_pc) + return 0x0000; + offs_t delta = (pc - base_pc) >> 3; + if(delta >= size) + return 0x0000; + return little_endianize_int16(reinterpret_cast<const u16 *>(&data[delta])[0]); + }; lr32 = [this](offs_t pc) -> u32 { if(pc < base_pc) return 0x00000000; @@ -904,10 +933,18 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const if(delta >= size + 2) return 0x00000000; auto p = reinterpret_cast<const u16 *>(&data[delta]); - return p[0] | (u32(p[1]) << 16); + return little_endianize_int16(p[0]) | (u32(little_endianize_int16(p[1])) << 16); }; break; case be: + lr16 = [this](offs_t pc) -> u16 { + if(pc < base_pc) + return 0x0000; + offs_t delta = (pc - base_pc) >> 3; + if(delta >= size) + return 0x0000; + return big_endianize_int16(reinterpret_cast<const u16 *>(&data[delta])[0]); + }; lr32 = [this](offs_t pc) -> u32 { if(pc < base_pc) return 0x00000000; @@ -915,7 +952,7 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const if(delta >= size + 2) return 0x00000000; auto p = reinterpret_cast<const u16 *>(&data[delta]); - return (u32(p[0]) << 16) | p[1]; + return (u32(big_endianize_int16(p[0])) << 16) | big_endianize_int16(p[1]); }; break; } |