summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/dsp56156/opcode.cpp
blob: b4e81ad791210718ed46544db645d4a812a12007 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
#include "opcode.h"

#include <cstdio>


namespace DSP_56156 {

Opcode::Opcode(uint16_t w0, uint16_t w1) : m_word0(w0)/*, m_word1(w1)*/
{
	m_instruction = Instruction::decodeInstruction(this, w0, w1);
	m_parallelMove = ParallelMove::decodeParallelMove(this, w0, w1);
}


Opcode::~Opcode()
{
}


std::string Opcode::disassemble() const
{
	// Duck out early if there isn't a valid op
	if (!m_instruction)
		return dcString();

	// Duck out if either has had an explicit error.
	if (m_instruction && !m_instruction->valid())
		return dcString();
	if (m_parallelMove && !m_parallelMove->valid())
		return dcString();

	// Disassemble what you can.
	auto opString = m_instruction ? m_instruction->disassemble() : "";
	auto pmString = m_parallelMove ? m_parallelMove->disassemble() : "";

	return opString + " " + pmString;
}


size_t Opcode::size() const
{
	if (m_instruction && m_instruction->valid())
		return m_instruction->size() + m_instruction->sizeIncrement();

	// Opcode failed to decode, so push it past dc
	return 1;
}


const reg_id& Opcode::instSource() const { return m_instruction->source(); }
const reg_id& Opcode::instDestination() const { return m_instruction->destination(); }
size_t Opcode::instAccumulatorBitsModified() const { return m_instruction->accumulatorBitsModified(); }

std::string Opcode::dcString() const
{
	return util::string_format("dc $%x", m_word0);
}

} // namespace DSP_56156