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

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

// #######################################################################################################################
//                                 IIII I       S S
// ADD_S b,b,h                     0111 0bbb hhh0 0HHH
// ADD_S b,b,limm                  0111 0bbb 1100 0111 (+ Limm)
// #######################################################################################################################

uint32_t arcompact_device::handleop_ADD_S_b_b_h_or_limm(uint16_t op) // ADD_s b, b, h
{
	uint8_t h = group_0e_get_h(op);
	uint8_t breg = common16_get_and_expand_breg(op);
	int size = check_limm16(h);
	m_regs[breg] = m_regs[breg] + m_regs[h];
	return m_pc + size;
}

// #######################################################################################################################
//                                 IIII I       S S
// MOV_S b,h                       0111 0bbb hhh0 1HHH
// MOV_S b,limm                    0111 0bbb 1100 1111 (+ Limm)
// #######################################################################################################################

// 16-bit MOV with extended register range
uint32_t arcompact_device::handleop_MOV_S_b_h_or_limm(uint16_t op) // MOV_S b <- h
{
	uint8_t h = group_0e_get_h(op);
	uint8_t breg = common16_get_and_expand_breg(op);
	int size = check_limm16(h);
	m_regs[breg] = m_regs[h];
	return m_pc + size;
}

// #######################################################################################################################
//                                 IIII I       S S
// CMP_S b,h                       0111 0bbb hhh1 0HHH
// CMP_S b,limm                    0111 0bbb 1101 0111 (+ Limm)
// #######################################################################################################################

uint32_t arcompact_device::handleop_CMP_S_b_h_or_limm(uint16_t op)
{
	uint8_t breg = common16_get_and_expand_breg(op);
	uint8_t h = group_0e_get_h(op);
	int size = check_limm16(h);
	// flag setting ALWAYS occurs on CMP operations, even 16-bit ones even without a .F opcode type
	uint32_t result = m_regs[breg] - m_regs[h];
	do_flags_sub(result, m_regs[breg], m_regs[h]);
	return m_pc + size;
}

// #######################################################################################################################
//                                 IIII I       S S
// MOV_S h,b                       0111 0bbb hhh1 1HHH
// #######################################################################################################################

uint32_t arcompact_device::handleop_MOV_S_h_b(uint16_t op) // MOV_S h <- b
{
	uint8_t h = group_0e_get_h(op);
	uint8_t breg = common16_get_and_expand_breg(op);
	m_regs[h] = m_regs[breg];
	return m_pc + 2;
}