1 |
2 |
jamieiles |
// Copyright Jamie Iles, 2017
|
2 |
|
|
//
|
3 |
|
|
// This file is part of s80x86.
|
4 |
|
|
//
|
5 |
|
|
// s80x86 is free software: you can redistribute it and/or modify
|
6 |
|
|
// it under the terms of the GNU General Public License as published by
|
7 |
|
|
// the Free Software Foundation, either version 3 of the License, or
|
8 |
|
|
// (at your option) any later version.
|
9 |
|
|
//
|
10 |
|
|
// s80x86 is distributed in the hope that it will be useful,
|
11 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
// GNU General Public License for more details.
|
14 |
|
|
//
|
15 |
|
|
// You should have received a copy of the GNU General Public License
|
16 |
|
|
// along with s80x86. If not, see <http://www.gnu.org/licenses/>.
|
17 |
|
|
|
18 |
|
|
#include <sstream>
|
19 |
|
|
#include <vector>
|
20 |
|
|
#include <gtest/gtest.h>
|
21 |
|
|
|
22 |
|
|
#include "EmulateFixture.h"
|
23 |
|
|
#include "Flags.h"
|
24 |
|
|
#include "Shift.h"
|
25 |
|
|
|
26 |
|
|
static const std::vector<struct ShiftTest<uint8_t>> rcl8_shift1_tests = {
|
27 |
|
|
{1, 0, 0, 0, 0}, {1, 0, 1, CF, 0}, {1, 1, 2, 0, 0},
|
28 |
|
|
{1, 0x80, 0x00, 0, CF | OF}, {1, 0x80, 0x01, CF, CF | OF},
|
29 |
|
|
{1, 0x80, 0x00, 0, CF | OF}, {1, 0xc0, 0x81, CF, CF},
|
30 |
|
|
};
|
31 |
|
|
|
32 |
|
|
static const std::vector<struct ShiftTest<uint16_t>> rcl16_shift1_tests = {
|
33 |
|
|
{1, 0, 0, 0, 0}, {1, 0, 1, CF, 0}, {1, 1, 2, 0, 0},
|
34 |
|
|
{1, 0x8000, 0x0000, 0, CF | OF}, {1, 0x8000, 0x0001, CF, CF | OF},
|
35 |
|
|
{1, 0x8000, 0x0000, 0, CF | OF}, {1, 0xc000, 0x8001, CF, CF},
|
36 |
|
|
};
|
37 |
|
|
|
38 |
|
|
INSTANTIATE_TEST_CASE_P(Rclg1,
|
39 |
|
|
ShiftReg8Test,
|
40 |
|
|
::testing::Values(
|
41 |
|
|
// rcl al, 1
|
42 |
|
|
Shift8Params({0xd0, 0xd0}, rcl8_shift1_tests)));
|
43 |
|
|
|
44 |
|
|
INSTANTIATE_TEST_CASE_P(Rclg1,
|
45 |
|
|
ShiftMem8Test,
|
46 |
|
|
::testing::Values(
|
47 |
|
|
// rcl byte [bx], 1
|
48 |
|
|
Shift8Params({0xd0, 0x17}, rcl8_shift1_tests)));
|
49 |
|
|
|
50 |
|
|
INSTANTIATE_TEST_CASE_P(Rclg1,
|
51 |
|
|
ShiftReg16Test,
|
52 |
|
|
::testing::Values(
|
53 |
|
|
// rcl ax, 1
|
54 |
|
|
Shift16Params({0xd1, 0xd0}, rcl16_shift1_tests)));
|
55 |
|
|
|
56 |
|
|
INSTANTIATE_TEST_CASE_P(Rclg1,
|
57 |
|
|
ShiftMem16Test,
|
58 |
|
|
::testing::Values(
|
59 |
|
|
// rcl word [bx], 1
|
60 |
|
|
Shift16Params({0xd1, 0x17}, rcl16_shift1_tests)));
|
61 |
|
|
|
62 |
|
|
static const std::vector<struct ShiftTest<uint8_t>> rcl8_shiftN_tests = {
|
63 |
|
|
{0, 1, 1, 0, 0}, {1, 0, 0, 0, 0}, {1, 0, 1, CF, 0}, {1, 1, 2, 0, 0},
|
64 |
|
|
{1, 0x80, 0x00, 0, CF}, {1, 0x80, 0x01, CF, CF}, {1, 0x80, 0x00, 0, CF},
|
65 |
|
|
{1, 0xc0, 0x81, CF, CF}, {8, 0, 0, 0, 0}, {7, 1, 0x80, 0, 0},
|
66 |
|
|
{8, 1, 0x00, 0, CF},
|
67 |
|
|
};
|
68 |
|
|
|
69 |
|
|
static const std::vector<struct ShiftTest<uint16_t>> rcl16_shiftN_tests = {
|
70 |
|
|
{0, 1, 1, 0, 0}, {1, 0, 0, 0, 0}, {1, 0, 1, CF, 0}, {1, 1, 2, 0, 0},
|
71 |
|
|
{1, 0x8000, 0x0000, 0, CF}, {1, 0x8000, 0x0001, CF, CF},
|
72 |
|
|
{1, 0x8000, 0x0000, 0, CF}, {1, 0xc000, 0x8001, CF, CF},
|
73 |
|
|
{16, 0, 0, 0, 0}, {16, 0, 0x8000, CF, 0}, {15, 1, 0x8000, 0, 0},
|
74 |
|
|
{16, 1, 0x0000, 0, CF},
|
75 |
|
|
};
|
76 |
|
|
|
77 |
|
|
INSTANTIATE_TEST_CASE_P(RclgN,
|
78 |
|
|
ShiftReg8Test,
|
79 |
|
|
::testing::Values(
|
80 |
|
|
// rcl al, N
|
81 |
|
|
Shift8Params({0xd2, 0xd0}, rcl8_shiftN_tests)));
|
82 |
|
|
|
83 |
|
|
INSTANTIATE_TEST_CASE_P(RclgN,
|
84 |
|
|
ShiftMem8Test,
|
85 |
|
|
::testing::Values(
|
86 |
|
|
// rcl byte [bx], N
|
87 |
|
|
Shift8Params({0xd2, 0x17}, rcl8_shiftN_tests)));
|
88 |
|
|
|
89 |
|
|
INSTANTIATE_TEST_CASE_P(RclgN,
|
90 |
|
|
ShiftReg16Test,
|
91 |
|
|
::testing::Values(
|
92 |
|
|
// rcl ax, N
|
93 |
|
|
Shift16Params({0xd3, 0xd0}, rcl16_shiftN_tests)));
|
94 |
|
|
|
95 |
|
|
INSTANTIATE_TEST_CASE_P(RclgN,
|
96 |
|
|
ShiftMem16Test,
|
97 |
|
|
::testing::Values(
|
98 |
|
|
// rcl word [bx], N
|
99 |
|
|
Shift16Params({0xd3, 0x17}, rcl16_shiftN_tests)));
|
100 |
|
|
|
101 |
|
|
INSTANTIATE_TEST_CASE_P(RclN,
|
102 |
|
|
ShiftRegImm8Test,
|
103 |
|
|
::testing::Values(
|
104 |
|
|
// rcl ax, imm8
|
105 |
|
|
Shift8Params({0xc0, 0xd0}, rcl8_shiftN_tests)));
|
106 |
|
|
|
107 |
|
|
INSTANTIATE_TEST_CASE_P(RclN,
|
108 |
|
|
ShiftMemImm8Test,
|
109 |
|
|
::testing::Values(
|
110 |
|
|
// rcl word [bx], imm8
|
111 |
|
|
Shift8Params({0xc0, 0x17}, rcl8_shiftN_tests)));
|
112 |
|
|
|
113 |
|
|
INSTANTIATE_TEST_CASE_P(RclN,
|
114 |
|
|
ShiftRegImm16Test,
|
115 |
|
|
::testing::Values(
|
116 |
|
|
// rcl ax, imm16
|
117 |
|
|
Shift16Params({0xc1, 0xd0}, rcl16_shiftN_tests)));
|
118 |
|
|
|
119 |
|
|
INSTANTIATE_TEST_CASE_P(RclN,
|
120 |
|
|
ShiftMemImm16Test,
|
121 |
|
|
::testing::Values(
|
122 |
|
|
// rcl word [bx], imm16
|
123 |
|
|
Shift16Params({0xc1, 0x17}, rcl16_shiftN_tests)));
|
124 |
|
|
|
125 |
|
|
INSTANTIATE_TEST_CASE_P(
|
126 |
|
|
RclgCL,
|
127 |
|
|
ShiftCLTest,
|
128 |
|
|
::testing::Values(ShiftCLTestParams{4, 64, {0xd2, 0xc1}}));
|