OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestRor.cpp] - Blame information for rev 2

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.