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>> rcr8_shift1_tests = {
|
27 |
|
|
{1, 0, 0, 0, 0}, {1, 0x80, 0x40, 0, OF}, {1, 0, 0x80, CF, OF},
|
28 |
|
|
{1, 2, 1, 0, 0}, {1, 0x80, 0xc0, CF, 0},
|
29 |
|
|
};
|
30 |
|
|
|
31 |
|
|
static const std::vector<struct ShiftTest<uint16_t>> rcr16_shift1_tests = {
|
32 |
|
|
{1, 0, 0, 0, 0}, {1, 0x8000, 0x4000, 0, OF}, {1, 0, 0x8000, CF, OF},
|
33 |
|
|
{1, 2, 1, 0, 0}, {1, 0x8000, 0xc000, CF, 0},
|
34 |
|
|
};
|
35 |
|
|
|
36 |
|
|
INSTANTIATE_TEST_CASE_P(Rcrg1,
|
37 |
|
|
ShiftReg8Test,
|
38 |
|
|
::testing::Values(
|
39 |
|
|
// rcr al, 1
|
40 |
|
|
Shift8Params({0xd0, 0xd8}, rcr8_shift1_tests)));
|
41 |
|
|
|
42 |
|
|
INSTANTIATE_TEST_CASE_P(Rcrg1,
|
43 |
|
|
ShiftMem8Test,
|
44 |
|
|
::testing::Values(
|
45 |
|
|
// rcr byte [bx], 1
|
46 |
|
|
Shift8Params({0xd0, 0x1f}, rcr8_shift1_tests)));
|
47 |
|
|
|
48 |
|
|
INSTANTIATE_TEST_CASE_P(Rcrg1,
|
49 |
|
|
ShiftReg16Test,
|
50 |
|
|
::testing::Values(
|
51 |
|
|
// rcr ax, 1
|
52 |
|
|
Shift16Params({0xd1, 0xd8}, rcr16_shift1_tests)));
|
53 |
|
|
|
54 |
|
|
INSTANTIATE_TEST_CASE_P(Rcrg1,
|
55 |
|
|
ShiftMem16Test,
|
56 |
|
|
::testing::Values(
|
57 |
|
|
// rcr word [bx], 1
|
58 |
|
|
Shift16Params({0xd1, 0x1f}, rcr16_shift1_tests)));
|
59 |
|
|
|
60 |
|
|
static const std::vector<struct ShiftTest<uint8_t>> rcr8_shiftN_tests = {
|
61 |
|
|
{0, 1, 1, 0, 0}, {1, 0, 0, 0, 0}, {1, 0x80, 0x40, 0, 0},
|
62 |
|
|
{1, 0, 0x80, CF, 0}, {1, 2, 1, 0, 0}, {1, 0x80, 0xc0, CF, 0},
|
63 |
|
|
{8, 0, 0, 0, 0}, {7, 0x80, 0x1, 0, 0}, {8, 0x80, 0x00, 0, CF},
|
64 |
|
|
};
|
65 |
|
|
|
66 |
|
|
static const std::vector<struct ShiftTest<uint16_t>> rcr16_shiftN_tests = {
|
67 |
|
|
{0, 1, 1, 0, 0}, {1, 0, 0, 0, 0}, {1, 0x8000, 0x4000, 0, 0},
|
68 |
|
|
{1, 0, 0x8000, CF, 0}, {1, 2, 1, 0, 0}, {1, 0x8000, 0xc000, CF, 0},
|
69 |
|
|
{16, 0, 0, 0, 0}, {15, 0x8000, 0x1, 0, 0}, {16, 0x8000, 0x00, 0, CF},
|
70 |
|
|
};
|
71 |
|
|
|
72 |
|
|
INSTANTIATE_TEST_CASE_P(RcrgN,
|
73 |
|
|
ShiftReg8Test,
|
74 |
|
|
::testing::Values(
|
75 |
|
|
// rcr al, N
|
76 |
|
|
Shift8Params({0xd2, 0xd8}, rcr8_shiftN_tests)));
|
77 |
|
|
|
78 |
|
|
INSTANTIATE_TEST_CASE_P(RcrgN,
|
79 |
|
|
ShiftMem8Test,
|
80 |
|
|
::testing::Values(
|
81 |
|
|
// rcr byte [bx], N
|
82 |
|
|
Shift8Params({0xd2, 0x1f}, rcr8_shiftN_tests)));
|
83 |
|
|
|
84 |
|
|
INSTANTIATE_TEST_CASE_P(RcrgN,
|
85 |
|
|
ShiftReg16Test,
|
86 |
|
|
::testing::Values(
|
87 |
|
|
// rcr ax, N
|
88 |
|
|
Shift16Params({0xd3, 0xd8}, rcr16_shiftN_tests)));
|
89 |
|
|
|
90 |
|
|
INSTANTIATE_TEST_CASE_P(RcrgN,
|
91 |
|
|
ShiftMem16Test,
|
92 |
|
|
::testing::Values(
|
93 |
|
|
// rcr word [bx], N
|
94 |
|
|
Shift16Params({0xd3, 0x1f}, rcr16_shiftN_tests)));
|
95 |
|
|
|
96 |
|
|
INSTANTIATE_TEST_CASE_P(RcrN,
|
97 |
|
|
ShiftRegImm8Test,
|
98 |
|
|
::testing::Values(
|
99 |
|
|
// rcr ax, imm8
|
100 |
|
|
Shift8Params({0xc0, 0xd8}, rcr8_shiftN_tests)));
|
101 |
|
|
|
102 |
|
|
INSTANTIATE_TEST_CASE_P(RcrN,
|
103 |
|
|
ShiftMemImm8Test,
|
104 |
|
|
::testing::Values(
|
105 |
|
|
// rcr word [bx], imm8
|
106 |
|
|
Shift8Params({0xc0, 0x1f}, rcr8_shiftN_tests)));
|
107 |
|
|
|
108 |
|
|
INSTANTIATE_TEST_CASE_P(RcrN,
|
109 |
|
|
ShiftRegImm16Test,
|
110 |
|
|
::testing::Values(
|
111 |
|
|
// rcr ax, imm16
|
112 |
|
|
Shift16Params({0xc1, 0xd8}, rcr16_shiftN_tests)));
|
113 |
|
|
|
114 |
|
|
INSTANTIATE_TEST_CASE_P(RcrN,
|
115 |
|
|
ShiftMemImm16Test,
|
116 |
|
|
::testing::Values(
|
117 |
|
|
// rcr word [bx], imm16
|
118 |
|
|
Shift16Params({0xc1, 0x1f}, rcr16_shiftN_tests)));
|
119 |
|
|
|
120 |
|
|
INSTANTIATE_TEST_CASE_P(
|
121 |
|
|
RcrgCL,
|
122 |
|
|
ShiftCLTest,
|
123 |
|
|
::testing::Values(ShiftCLTestParams{4, 0x40, {0xd2, 0xd1}}));
|