summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/arcompact/arcompact_execute_ops_1ato1c_16bit.cpp
blob: 165a4c646ef3e87ba4cde9692814e1c152fa0aa8 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood

#include "emu.h"
#include "arcompact_helper.ipp"

// #######################################################################################################################
//                                 IIII I
// LD_S b,[pcl,u10]                1101 0bbb uuuu uuuu
// #######################################################################################################################

uint32_t arcompact_device::handleop_LD_S_b_pcl_u10(uint16_t op)
{
	uint8_t breg = common16_get_and_expand_breg(op);
	uint32_t u = common16_get_u8(op);
	m_regs[breg] = READ32(m_regs[REG_PCL] + (u << 2));
	return m_pc + 2;
}

// #######################################################################################################################
//                                 IIII I
// MOV_S b,u8                      1101 1bbb uuuu uuuu
// #######################################################################################################################

uint32_t arcompact_device::handleop_MOV_S_b_u8(uint16_t op) // MOV_S b, u8
{
	uint8_t breg = common16_get_and_expand_breg(op);
	uint32_t u = common16_get_u8(op);
	m_regs[breg] = u;
	return m_pc + 2;
}

// #######################################################################################################################
//                                 IIII I    s
// ADD_S b,b,u7                    1110 0bbb 0uuu uuuu
// #######################################################################################################################

uint32_t arcompact_device::handleop_ADD_S_b_b_u7(uint16_t op) // ADD_S b, b, u7
{
	uint8_t breg = common16_get_and_expand_breg(op);
	uint32_t u = common16_get_u7(op);
	m_regs[breg] = m_regs[breg] + u;
	return m_pc + 2;
}

// #######################################################################################################################
//                                 IIII I    s
// CMP_S b,u7                      1110 0bbb 1uuu uuuu
// #######################################################################################################################

uint32_t arcompact_device::handleop_CMP_S_b_u7(uint16_t op) // CMP b, u7
{
	uint8_t breg = common16_get_and_expand_breg(op);
	uint32_t u = common16_get_u7(op);
	// flag setting ALWAYS occurs on CMP operations, even 16-bit ones even without a .F opcode type
	uint32_t result = m_regs[breg] - u;
	do_flags_sub(result, m_regs[breg], u);
	return m_pc + 2;
}