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

Subversion Repositories s80186

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

powered by: WebSVN 2.1.0

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