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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestXor.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 "Arithmetic.h"
25
 
26
static const std::vector<struct ArithmeticTest<uint8_t>> xor8_tests = {
27
    {0, 0, 0, PF | ZF, false}, {0xf, 0xf, 0x00, PF | ZF, false},
28
        {0x0f, 0xf0, 0xff, PF | SF, false}, {0x0f, 0x01, 0x0e, 0, false},
29
};
30
 
31
static const std::vector<struct ArithmeticTest<uint16_t>> xor16_tests = {
32
    {0, 0, 0, PF | ZF, false}, {0xf, 0xf, 0x00, PF | ZF, false},
33
        {0x00ff, 0xff00, 0xffff, PF | SF, false}, {0x0f, 0x01, 0x0e, 0, false},
34
};
35
 
36
INSTANTIATE_TEST_CASE_P(Xor,
37
                        ArithmeticRegReg8Test,
38
                        ::testing::Values(
39
                            // xor al, bl
40
                            Arith8Params({0x30, 0xd8}, xor8_tests)));
41
 
42
INSTANTIATE_TEST_CASE_P(Xor,
43
                        ArithmeticMemReg8Test,
44
                        ::testing::Values(
45
                            // xor [bx], al
46
                            Arith8Params({0x30, 0x07}, xor8_tests)));
47
 
48
INSTANTIATE_TEST_CASE_P(Xor,
49
                        ArithmeticRegReg8TestReversed,
50
                        ::testing::Values(
51
                            // xor bl, al
52
                            Arith8Params({0x32, 0xd8}, xor8_tests)));
53
 
54
INSTANTIATE_TEST_CASE_P(Xor,
55
                        ArithmeticMemReg8TestReversed,
56
                        ::testing::Values(
57
                            // xor al, [bx]
58
                            Arith8Params({0x32, 0x07}, xor8_tests)));
59
 
60
INSTANTIATE_TEST_CASE_P(Xor,
61
                        ArithmeticRegReg16Test,
62
                        ::testing::Values(
63
                            // xor ax, bx
64
                            Arith16Params({0x31, 0xd8}, xor16_tests)));
65
 
66
INSTANTIATE_TEST_CASE_P(Xor,
67
                        ArithmeticRegMem16Test,
68
                        ::testing::Values(
69
                            // adc [bx], ax
70
                            Arith16Params({0x31, 0x07}, xor16_tests)));
71
 
72
INSTANTIATE_TEST_CASE_P(Xor,
73
                        ArithmeticRegReg16TestReversed,
74
                        ::testing::Values(
75
                            // xor bx, ax
76
                            Arith16Params({0x33, 0xd8}, xor16_tests)));
77
 
78
INSTANTIATE_TEST_CASE_P(Xor,
79
                        ArithmeticMemReg16TestReversed,
80
                        ::testing::Values(
81
                            // xor ax, bx
82
                            Arith16Params({0x33, 0x07}, xor16_tests)));
83
 
84
INSTANTIATE_TEST_CASE_P(Xor,
85
                        ArithmeticRegImmed8Test,
86
                        ::testing::Values(
87
                            // xor bl, 1
88
                            ArithImmed8Params(std::vector<uint8_t>{0x80, 0xf3,
89
                                                                   0x01},
90
                                              {1, 0, ZF | PF, false})));
91
 
92
INSTANTIATE_TEST_CASE_P(Xor,
93
                        ArithmeticMemImmed8Test,
94
                        ::testing::Values(
95
                            // xor byte [bx], 1
96
                            ArithImmed8Params(std::vector<uint8_t>{0x80, 0x37,
97
                                                                   0x01},
98
                                              {1, 0, ZF | PF, false})));
99
 
100
INSTANTIATE_TEST_CASE_P(Xor,
101
                        ArithmeticRegImmed16Test,
102
                        ::testing::Values(
103
                            // xor bx, 1
104
                            ArithImmed16Params(std::vector<uint8_t>{0x81, 0xf3,
105
                                                                    0x01, 0x0},
106
                                               {1, 0, ZF | PF, false})));
107
 
108
INSTANTIATE_TEST_CASE_P(Xor,
109
                        ArithmeticMemImmed16Test,
110
                        ::testing::Values(
111
                            // xor word [bx], 1
112
                            ArithImmed16Params(std::vector<uint8_t>{0x81, 0x37,
113
                                                                    0x01, 0x00},
114
                                               {1, 0, ZF | PF, false})));
115
 
116
INSTANTIATE_TEST_CASE_P(Xor,
117
                        ArithmeticRegImmed16TestExtend,
118
                        ::testing::Values(
119
                            // xor bx, 1
120
                            ArithImmed16Params(std::vector<uint8_t>{0x83, 0xf3,
121
                                                                    0x01},
122
                                               {1, 0, ZF | PF, false})));
123
 
124
INSTANTIATE_TEST_CASE_P(Xor,
125
                        ArithmeticMemImmed16TestExtend,
126
                        ::testing::Values(
127
                            // xor word [bx], 1
128
                            ArithImmed16Params(std::vector<uint8_t>{0x83, 0x37,
129
                                                                    0x01},
130
                                               {1, 0, ZF | PF, false})));
131
 
132
INSTANTIATE_TEST_CASE_P(Xor,
133
                        ArithmeticAlImmedTest,
134
                        ::testing::Values(
135
                            // xor al, 1
136
                            ArithImmed8Params(std::vector<uint8_t>{0x34, 0x01},
137
                                              {1, 0, ZF | PF, false})));
138
 
139
INSTANTIATE_TEST_CASE_P(Xor,
140
                        ArithmeticAxImmedTest,
141
                        ::testing::Values(
142
                            // xor ax, 1
143
                            ArithImmed16Params(std::vector<uint8_t>{0x35, 0x01,
144
                                                                    0x0},
145
                                               {1, 0, ZF | PF, false})));

powered by: WebSVN 2.1.0

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