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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestSar.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>> sar8_shift1_tests = {
27
    {1, 0, 0, 0, PF | ZF}, {1, 1, 0, 0, PF | ZF | CF}, {1, 2, 1, 0, 0},
28
        {1, 0, 0, CF, PF | ZF}, {1, 0x80, 0xc0, CF, PF | SF},
29
        {1, 0x80, 0xc0, 0, PF | SF},
30
};
31
 
32
static const std::vector<struct ShiftTest<uint16_t>> sar16_shift1_tests = {
33
    {1, 0, 0, 0, PF | ZF}, {1, 1, 0, 0, PF | ZF | CF}, {1, 2, 1, 0, 0},
34
        {1, 0, 0, CF, PF | ZF}, {1, 0x8000, 0xc000, CF, PF | SF},
35
        {1, 0x8000, 0xc000, 0, PF | SF},
36
};
37
 
38
INSTANTIATE_TEST_CASE_P(Sar1,
39
                        ShiftReg8Test,
40
                        ::testing::Values(
41
                            // sar al, 1
42
                            Shift8Params({0xd0, 0xf8}, sar8_shift1_tests)));
43
 
44
INSTANTIATE_TEST_CASE_P(Sar1,
45
                        ShiftMem8Test,
46
                        ::testing::Values(
47
                            // sar byte [bx], 1
48
                            Shift8Params({0xd0, 0x3f}, sar8_shift1_tests)));
49
 
50
INSTANTIATE_TEST_CASE_P(Sar1,
51
                        ShiftReg16Test,
52
                        ::testing::Values(
53
                            // sar ax, 1
54
                            Shift16Params({0xd1, 0xf8}, sar16_shift1_tests)));
55
 
56
INSTANTIATE_TEST_CASE_P(Sar1,
57
                        ShiftMem16Test,
58
                        ::testing::Values(
59
                            // sar word [bx], 1
60
                            Shift16Params({0xd1, 0x3f}, sar16_shift1_tests)));
61
 
62
static const std::vector<struct ShiftTest<uint8_t>> sar8_shiftN_tests = {
63
    {0, 1, 1, 0, 0}, {1, 0, 0, 0, PF | ZF}, {1, 1, 0, 0, PF | ZF | CF},
64
        {1, 2, 1, 0, 0}, {1, 0, 0, CF, PF | ZF}, {1, 0x80, 0xc0, CF, PF | SF},
65
        {1, 0x80, 0xc0, 0, PF | SF}, {8, 0, 0, 0, PF | ZF},
66
        {7, 0x80, 0xff, 0, PF | SF},
67
    {
68
        8, 0x80, 0xff, 0, PF | SF | CF
69
    }
70
};
71
 
72
static const std::vector<struct ShiftTest<uint16_t>> sar16_shiftN_tests = {
73
    {0, 1, 1, 0, 0}, {1, 0, 0, 0, PF | ZF}, {1, 1, 0, 0, PF | ZF | CF},
74
        {1, 2, 1, 0, 0}, {1, 0, 0, CF, PF | ZF},
75
        {1, 0x8000, 0xc000, CF, PF | SF}, {1, 0x8000, 0xc000, 0, PF | SF},
76
        {16, 0, 0, 0, PF | ZF}, {15, 0x8000, 0xffff, 0, PF | SF},
77
    {
78
        16, 0x8000, 0xffff, 0, PF | SF | CF
79
    }
80
};
81
 
82
INSTANTIATE_TEST_CASE_P(SarN,
83
                        ShiftReg8Test,
84
                        ::testing::Values(
85
                            // sar al, N
86
                            Shift8Params({0xd2, 0xf8}, sar8_shiftN_tests)));
87
 
88
INSTANTIATE_TEST_CASE_P(SarN,
89
                        ShiftMem8Test,
90
                        ::testing::Values(
91
                            // sar byte [bx], N
92
                            Shift8Params({0xd2, 0x3f}, sar8_shiftN_tests)));
93
 
94
INSTANTIATE_TEST_CASE_P(SarN,
95
                        ShiftReg16Test,
96
                        ::testing::Values(
97
                            // sar ax, N
98
                            Shift16Params({0xd3, 0xf8}, sar16_shiftN_tests)));
99
 
100
INSTANTIATE_TEST_CASE_P(SarN,
101
                        ShiftMem16Test,
102
                        ::testing::Values(
103
                            // sar word [bx], N
104
                            Shift16Params({0xd3, 0x3f}, sar16_shiftN_tests)));
105
 
106
INSTANTIATE_TEST_CASE_P(SarN,
107
                        ShiftRegImm8Test,
108
                        ::testing::Values(
109
                            // sar ax, imm8
110
                            Shift8Params({0xc0, 0xf8}, sar8_shiftN_tests)));
111
 
112
INSTANTIATE_TEST_CASE_P(SarN,
113
                        ShiftMemImm8Test,
114
                        ::testing::Values(
115
                            // sar word [bx], imm8
116
                            Shift8Params({0xc0, 0x3f}, sar8_shiftN_tests)));
117
 
118
INSTANTIATE_TEST_CASE_P(SarN,
119
                        ShiftRegImm16Test,
120
                        ::testing::Values(
121
                            // sar ax, imm16
122
                            Shift16Params({0xc1, 0xf8}, sar16_shiftN_tests)));
123
 
124
INSTANTIATE_TEST_CASE_P(SarN,
125
                        ShiftMemImm16Test,
126
                        ::testing::Values(
127
                            // sar word [bx], imm16
128
                            Shift16Params({0xc1, 0x3f}, sar16_shiftN_tests)));
129
 
130
INSTANTIATE_TEST_CASE_P(
131
    SarCL,
132
    ShiftCLTest,
133
    ::testing::Values(ShiftCLTestParams{4, 0, {0xd2, 0xf9}}));

powered by: WebSVN 2.1.0

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