summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/avr8
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/avr8')
-rw-r--r--src/devices/cpu/avr8/avr8.cpp30
-rw-r--r--src/devices/cpu/avr8/avr8.h6
-rw-r--r--src/devices/cpu/avr8/avr8dasm.cpp41
-rw-r--r--src/devices/cpu/avr8/avr8dasm.h24
4 files changed, 52 insertions, 49 deletions
diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp
index 763cdad799e..2f55b4a0317 100644
--- a/src/devices/cpu/avr8/avr8.cpp
+++ b/src/devices/cpu/avr8/avr8.cpp
@@ -59,6 +59,7 @@
#include "emu.h"
#include "avr8.h"
+#include "avr8dasm.h"
#include "debugger.h"
#define VERBOSE_LEVEL (0)
@@ -911,36 +912,13 @@ void avr8_device::state_string_export(const device_state_entry &entry, std::stri
//-------------------------------------------------
-// disasm_min_opcode_bytes - return the length
-// of the shortest instruction, in bytes
-//-------------------------------------------------
-
-uint32_t avr8_device::disasm_min_opcode_bytes() const
-{
- return 2;
-}
-
-
-//-------------------------------------------------
-// disasm_max_opcode_bytes - return the length
-// of the longest instruction, in bytes
-//-------------------------------------------------
-
-uint32_t avr8_device::disasm_max_opcode_bytes() const
-{
- return 4;
-}
-
-
-//-------------------------------------------------
-// disasm_disassemble - call the disassembly
+// disassemble - call the disassembly
// helper function
//-------------------------------------------------
-offs_t avr8_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *avr8_device::create_disassembler()
{
- extern CPU_DISASSEMBLE( avr8 );
- return CPU_DISASSEMBLE_NAME(avr8)(this, stream, pc, oprom, opram, options);
+ return new avr8_disassembler;
}
diff --git a/src/devices/cpu/avr8/avr8.h b/src/devices/cpu/avr8/avr8.h
index 0da73a4cc1c..f8c953a3aa3 100644
--- a/src/devices/cpu/avr8/avr8.h
+++ b/src/devices/cpu/avr8/avr8.h
@@ -123,9 +123,7 @@ protected:
virtual space_config_vector memory_space_config() const override;
// device_disasm_interface overrides
- virtual uint32_t disasm_min_opcode_bytes() const override;
- virtual uint32_t disasm_max_opcode_bytes() const override;
- virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override;
+ virtual util::disasm_interface *create_disassembler() override;
// device_state_interface overrides
virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
@@ -848,6 +846,4 @@ enum
#define AVR8_SPCR_CPHA_MASK 0x04
#define AVR8_SPCR_SPR_MASK 0x03
-CPU_DISASSEMBLE( avr8 );
-
#endif /* __AVR8_H__ */
diff --git a/src/devices/cpu/avr8/avr8dasm.cpp b/src/devices/cpu/avr8/avr8dasm.cpp
index cfc99b955d3..5f47198c425 100644
--- a/src/devices/cpu/avr8/avr8dasm.cpp
+++ b/src/devices/cpu/avr8/avr8dasm.cpp
@@ -7,7 +7,7 @@
*/
#include "emu.h"
-#include "avr8.h"
+#include "avr8dasm.h"
#define RD2(op) (((op) >> 4) & 0x0003)
#define RD3(op) (((op) >> 4) & 0x0007)
@@ -25,11 +25,16 @@
#define ACONST6(op) ((((op) >> 5) & 0x0030) | ((op) & 0x000f))
#define MULCONST2(op) ((((op) >> 6) & 0x0002) | (((op) >> 3) & 0x0001))
-CPU_DISASSEMBLE(avr8)
+u32 avr8_disassembler::opcode_alignment() const
{
- int pos = 0;
- uint32_t op = oprom[pos++];
- op |= oprom[pos++] << 8;
+ return 2;
+}
+
+offs_t avr8_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
+{
+ offs_t base_pc = pc;
+ uint32_t op = opcodes.r16(pc);
+ pc += 2;
uint32_t addr;
const char* register_names[0x40] = {"PINA", "DDRA", "PORTA", "PINB", "DDRB", "PORTB", "PINC", "DDRC", "PORTC", "PIND", "DDRD", "PORTD", "PINE", "DDRE", "PORTE", "PINF", "DDRF", "PORTF", "PING", "DDRG", "PORTG", "TIFR0", "TIFR1", "TIFR2","TIFR3", "TIFR4", "TIFR5", "PCIFR", "EIFR", "EIMSK", "GPIOR0", "EECR", "EEDR", "EEARL", "EEARH", "GTCCR", "TCCR0A", "TCCR0B", "TCNT0", "OCR0A", "OCR0B", "0x29", "GPIOR1", "GPIOR2", "SPCR", "SPSR", "SPDR", "0x2F", "ACSR", "OCDR", "0x32", "SMCR", "MCUSR", "MCUCR", "0x36", "SPMCSR", "0x38", "0x39", "0x3A", "RAMPZ", "EIND", "SPL", "SPH", "SREG"};
@@ -226,8 +231,8 @@ CPU_DISASSEMBLE(avr8)
{
case 0x0000:
op <<= 16;
- op |= oprom[pos++];
- op |= oprom[pos++] << 8;
+ op |= opcodes.r16(pc);
+ pc += 2;
util::stream_format(stream, "LDS R%d, (0x%04x)", RD5(op >> 16), op & 0x0000ffff);
break;
case 0x0001:
@@ -277,8 +282,8 @@ CPU_DISASSEMBLE(avr8)
{
case 0x0000:
op <<= 16;
- op |= oprom[pos++];
- op |= oprom[pos++] << 8;
+ op |= opcodes.r16(pc);
+ pc += 2;
util::stream_format(stream, "STS (0x%04x), R%d", op & 0x0000ffff, RD5(op >> 16));
break;
case 0x0001:
@@ -410,15 +415,15 @@ CPU_DISASSEMBLE(avr8)
case 0x000c:
case 0x000d:
addr = KCONST22(op) << 16;
- addr |= oprom[pos++];
- addr |= oprom[pos++] << 8;
+ addr |= opcodes.r16(pc);
+ pc += 2;
util::stream_format(stream, "JMP 0x%06x", addr << 1);
break;
case 0x000e:
case 0x000f:
addr = KCONST22(op) << 16;
- addr |= oprom[pos++];
- addr |= oprom[pos++] << 8;
+ addr |= opcodes.r16(pc);
+ pc += 2;
util::stream_format(stream, "CALL 0x%06x", addr << 1);
break;
default:
@@ -505,15 +510,15 @@ CPU_DISASSEMBLE(avr8)
case 0x000c:
case 0x000d:
op <<= 16;
- op |= oprom[pos++];
- op |= oprom[pos++] << 8;
+ op |= opcodes.r16(pc);
+ pc += 2;
util::stream_format(stream, "JMP 0x%06x", KCONST22(op) << 1);
break;
case 0x000e:
case 0x000f:
op <<= 16;
- op |= oprom[pos++];
- op |= oprom[pos++] << 8;
+ op |= opcodes.r16(pc);
+ pc += 2;
util::stream_format(stream, "CALL 0x%06x", KCONST22(op) << 1);
break;
}
@@ -669,5 +674,5 @@ CPU_DISASSEMBLE(avr8)
break;
}
- return pos | DASMFLAG_SUPPORTED;
+ return (pc - base_pc) | SUPPORTED;
}
diff --git a/src/devices/cpu/avr8/avr8dasm.h b/src/devices/cpu/avr8/avr8dasm.h
new file mode 100644
index 00000000000..a7f55fdb86b
--- /dev/null
+++ b/src/devices/cpu/avr8/avr8dasm.h
@@ -0,0 +1,24 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+/*
+ Atmel 8-bit AVR disassembler
+
+ Written by Ryan Holtz
+*/
+
+#ifndef MAME_CPU_AVR8_AVR8DASM_H
+#define MAME_CPU_AVR8_AVR8DASM_H
+
+#pragma once
+
+class avr8_disassembler : public util::disasm_interface
+{
+public:
+ avr8_disassembler() = default;
+ virtual ~avr8_disassembler() = default;
+
+ virtual u32 opcode_alignment() const override;
+ virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
+};
+
+#endif