summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/cpu/arcompact/arcompact.c
blob: 703ab5bf94f117df50f793148d321651154863b2 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*********************************\

 ARCompact Core

 The following procesors use the ARCompact instruction set

  - ARCtangent-A5
  - ARC 600
  - ARC 700

 (this is a skeleton core)

 ARCompact is a 32-bit CPU that freely mixes 32-bit and 16-bit instructions
 various user customizations could be made as with the ARC A4 based processors
 these include custom instructions and registers.

\*********************************/

#include "emu.h"
#include "debugger.h"
#include "arcompact.h"


const device_type ARCA5 = &device_creator<arcompact_device>;


arcompact_device::arcompact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: cpu_device(mconfig, ARCA5, "ARCtangent-A5", tag, owner, clock, "arca5", __FILE__)
	, m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0) // some docs describe these as 'middle endian'?!
{
}


offs_t arcompact_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
{
	extern CPU_DISASSEMBLE( arcompact );
	return CPU_DISASSEMBLE_NAME(arcompact)(this, buffer, pc, oprom, opram, options);
}


/*****************************************************************************/

/*****************************************************************************/

void arcompact_device::unimplemented_opcode(UINT16 op)
{
	fatalerror("ARCOMPACT: unknown opcode %04x at %04x\n", op, m_pc << 2);
}

/*****************************************************************************/

UINT32 arcompact_device::READ32(UINT32 address)
{
	return m_program->read_dword(address << 2);
}

void arcompact_device::WRITE32(UINT32 address, UINT32 data)
{
	m_program->write_dword(address << 2, data);
}

UINT16 arcompact_device::READ16(UINT32 address)
{
	return m_program->read_word(address << 1);
}

void arcompact_device::WRITE16(UINT32 address, UINT16 data)
{
	m_program->write_word(address << 1, data);
}


/*****************************************************************************/

void arcompact_device::device_start()
{
	m_pc = 0;

	m_debugger_temp = 0;

	m_program = &space(AS_PROGRAM);

	state_add( 0,  "PC", m_debugger_temp).callimport().callexport().formatstr("%08X");
	state_add(STATE_GENPC, "GENPC", m_debugger_temp).callexport().noshow();

	m_icountptr = &m_icount;
}

void arcompact_device::state_export(const device_state_entry &entry)
{
	switch (entry.index())
	{
		case 0:
			m_debugger_temp = m_pc << 1;
			break;

		case STATE_GENPC:
			m_debugger_temp = m_pc << 1;
			break;
	}
}

void arcompact_device::state_import(const device_state_entry &entry)
{
	switch (entry.index())
	{
		case 0:
			m_pc = (m_debugger_temp & 0xfffffffe) >> 1;
			break;
	}
}

void arcompact_device::device_reset()
{
	m_pc = 0x00000000;
}

/*****************************************************************************/

void arcompact_device::execute_set_input(int irqline, int state)
{

}


void arcompact_device::execute_run()
{
	//UINT32 lres;
	//lres = 0;

	while (m_icount > 0)
	{
		debugger_instruction_hook(this, m_pc<<2);

		//UINT32 op = READ32(m_pc);


		m_pc++;

		m_icount--;
	}

}