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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestShl.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>> shl8_shift1_tests = {
27
    {1, 0, 0, 0, PF | ZF}, {1, 1, 2, 0, 0},
28
        {1, 0x80, 0x00, 0, CF | ZF | OF | PF}, {1, 0xc0, 0x80, 0, CF | SF},
29
        {1, 0x40, 0x80, 0, SF | OF},
30
};
31
 
32
static const std::vector<struct ShiftTest<uint16_t>> shl16_shift1_tests = {
33
    {1, 0, 0, 0, PF | ZF}, {1, 1, 2, 0, 0},
34
        {1, 0x8000, 0x0000, 0, CF | ZF | OF | PF},
35
        {1, 0xc000, 0x8000, 0, CF | SF | PF},
36
        {1, 0x4000, 0x8000, 0, SF | PF | OF},
37
};
38
 
39
INSTANTIATE_TEST_CASE_P(Shl1,
40
                        ShiftReg8Test,
41
                        ::testing::Values(
42
                            // shl al, 1
43
                            Shift8Params({0xd0, 0xe0}, shl8_shift1_tests),
44
                            // sal al, 1
45
                            Shift8Params({0xd0, 0xf0}, shl8_shift1_tests)));
46
 
47
INSTANTIATE_TEST_CASE_P(Shl1,
48
                        ShiftMem8Test,
49
                        ::testing::Values(
50
                            // shl byte [bx], 1
51
                            Shift8Params({0xd0, 0x27}, shl8_shift1_tests),
52
                            // sal byte [bx], 1
53
                            Shift8Params({0xd0, 0x37}, shl8_shift1_tests)));
54
 
55
INSTANTIATE_TEST_CASE_P(Shl1,
56
                        ShiftReg16Test,
57
                        ::testing::Values(
58
                            // shl ax, 1
59
                            Shift16Params({0xd1, 0xe0}, shl16_shift1_tests),
60
                            // sal ax, 1
61
                            Shift16Params({0xd1, 0xf0}, shl16_shift1_tests)));
62
 
63
INSTANTIATE_TEST_CASE_P(Shl1,
64
                        ShiftMem16Test,
65
                        ::testing::Values(
66
                            // shl word [bx], 1
67
                            Shift16Params({0xd1, 0x27}, shl16_shift1_tests),
68
                            // sal word [bx], 1
69
                            Shift16Params({0xd1, 0x37}, shl16_shift1_tests)));
70
 
71
static const std::vector<struct ShiftTest<uint8_t>> shl8_shiftN_tests = {
72
    {0, 1, 1, 0, 0}, {1, 0, 0, 0, PF | ZF}, {1, 1, 2, 0, 0},
73
        {1, 0x80, 0x00, 0, CF | ZF | PF}, {1, 0xc0, 0x80, 0, CF | SF},
74
        {1, 0x40, 0x80, 0, SF}, {8, 0, 0, 0, PF | ZF}, {7, 1, 0x80, 0, SF},
75
        {8, 1, 0x00, 0, CF | PF | ZF},
76
};
77
 
78
static const std::vector<struct ShiftTest<uint16_t>> shl16_shiftN_tests = {
79
    {0, 1, 1, 0, 0}, {1, 0, 0, 0, PF | ZF}, {1, 1, 2, 0, 0},
80
        {1, 0x8000, 0x0000, 0, CF | ZF | PF},
81
        {1, 0xc000, 0x8000, 0, CF | SF | PF}, {1, 0x4000, 0x8000, 0, SF | PF},
82
        {8, 0, 0, 0, PF | ZF}, {15, 1, 0x8000, 0, SF | PF},
83
        {16, 1, 0x0000, 0, CF | PF | ZF},
84
};
85
 
86
INSTANTIATE_TEST_CASE_P(ShlN,
87
                        ShiftReg8Test,
88
                        ::testing::Values(
89
                            // shl al, N
90
                            Shift8Params({0xd2, 0xe0}, shl8_shiftN_tests),
91
                            // sal al, N
92
                            Shift8Params({0xd2, 0xf0}, shl8_shiftN_tests)));
93
 
94
INSTANTIATE_TEST_CASE_P(ShlN,
95
                        ShiftMem8Test,
96
                        ::testing::Values(
97
                            // shl byte [bx], N
98
                            Shift8Params({0xd2, 0x27}, shl8_shiftN_tests),
99
                            // sal byte [bx], N
100
                            Shift8Params({0xd2, 0x37}, shl8_shiftN_tests)));
101
 
102
INSTANTIATE_TEST_CASE_P(ShlN,
103
                        ShiftReg16Test,
104
                        ::testing::Values(
105
                            // shl ax, N
106
                            Shift16Params({0xd3, 0xe0}, shl16_shiftN_tests),
107
                            // sal ax, N
108
                            Shift16Params({0xd3, 0xf0}, shl16_shiftN_tests)));
109
 
110
INSTANTIATE_TEST_CASE_P(ShlN,
111
                        ShiftMem16Test,
112
                        ::testing::Values(
113
                            // shl word [bx], N
114
                            Shift16Params({0xd3, 0x27}, shl16_shiftN_tests),
115
                            // sal word [bx], N
116
                            Shift16Params({0xd3, 0x37}, shl16_shiftN_tests)));
117
 
118
INSTANTIATE_TEST_CASE_P(ShlN,
119
                        ShiftRegImm8Test,
120
                        ::testing::Values(
121
                            // shl ax, imm8
122
                            Shift8Params({0xc0, 0xe0}, shl8_shiftN_tests),
123
                            // sal ax, imm8
124
                            Shift8Params({0xc0, 0xf0}, shl8_shiftN_tests)));
125
 
126
INSTANTIATE_TEST_CASE_P(ShlN,
127
                        ShiftMemImm8Test,
128
                        ::testing::Values(
129
                            // shl word [bx], imm8
130
                            Shift8Params({0xc0, 0x27}, shl8_shiftN_tests),
131
                            // sal word [bx], imm8
132
                            Shift8Params({0xc0, 0x37}, shl8_shiftN_tests)));
133
 
134
INSTANTIATE_TEST_CASE_P(ShlN,
135
                        ShiftRegImm16Test,
136
                        ::testing::Values(
137
                            // shl ax, imm16
138
                            Shift16Params({0xc1, 0xe0}, shl16_shiftN_tests),
139
                            // sal ax, imm16
140
                            Shift16Params({0xc1, 0xf0}, shl16_shiftN_tests)));
141
 
142
INSTANTIATE_TEST_CASE_P(ShlN,
143
                        ShiftMemImm16Test,
144
                        ::testing::Values(
145
                            // shl word [bx], imm16
146
                            Shift16Params({0xc1, 0x27}, shl16_shiftN_tests),
147
                            // sal word [bx], imm16
148
                            Shift16Params({0xc1, 0x37}, shl16_shiftN_tests)));
149
 
150
INSTANTIATE_TEST_CASE_P(
151
    ShlCL,
152
    ShiftCLTest,
153
    ::testing::Values(ShiftCLTestParams{4, 64, {0xd2, 0xe1}}));

powered by: WebSVN 2.1.0

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