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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestAnd.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>> and8_tests = {
27
    {0, 0, 0, PF | ZF, false}, {0xf, 0xf, 0x0f, PF, false},
28
        {0x0f, 0xf0, 0x0, PF | ZF, false}, {0x0f, 0x01, 0x01, 0, false},
29
};
30
 
31
static const std::vector<struct ArithmeticTest<uint16_t>> and16_tests = {
32
    {0, 0, 0, PF | ZF, false}, {0xf, 0xf, 0x0f, PF, false},
33
        {0x000f, 0xf000, 0x0, PF | ZF, false},
34
        {0xf00f, 0xf000, 0xf000, PF | SF, false}, {0x0f, 0x01, 0x01, 0, false},
35
        {0x0240, 0x3c84, 0x0, PF | ZF, false},
36
};
37
 
38
INSTANTIATE_TEST_CASE_P(And,
39
                        ArithmeticRegReg8Test,
40
                        ::testing::Values(
41
                            // and al, bl
42
                            Arith8Params({0x20, 0xd8}, and8_tests)));
43
 
44
INSTANTIATE_TEST_CASE_P(And,
45
                        ArithmeticMemReg8Test,
46
                        ::testing::Values(
47
                            // and [bx], al
48
                            Arith8Params({0x20, 0x07}, and8_tests)));
49
 
50
INSTANTIATE_TEST_CASE_P(And,
51
                        ArithmeticRegReg8TestReversed,
52
                        ::testing::Values(
53
                            // and bl, al
54
                            Arith8Params({0x22, 0xd8}, and8_tests)));
55
 
56
INSTANTIATE_TEST_CASE_P(And,
57
                        ArithmeticMemReg8TestReversed,
58
                        ::testing::Values(
59
                            // and al, [bx]
60
                            Arith8Params({0x22, 0x07}, and8_tests)));
61
 
62
INSTANTIATE_TEST_CASE_P(And,
63
                        ArithmeticRegReg16Test,
64
                        ::testing::Values(
65
                            // and ax, bx
66
                            Arith16Params({0x21, 0xd8}, and16_tests)));
67
 
68
INSTANTIATE_TEST_CASE_P(And,
69
                        ArithmeticRegMem16Test,
70
                        ::testing::Values(
71
                            // adc [bx], ax
72
                            Arith16Params({0x21, 0x07}, and16_tests)));
73
 
74
INSTANTIATE_TEST_CASE_P(And,
75
                        ArithmeticRegReg16TestReversed,
76
                        ::testing::Values(
77
                            // and bx, ax
78
                            Arith16Params({0x23, 0xd8}, and16_tests)));
79
 
80
INSTANTIATE_TEST_CASE_P(And,
81
                        ArithmeticMemReg16TestReversed,
82
                        ::testing::Values(
83
                            // and ax, bx
84
                            Arith16Params({0x23, 0x07}, and16_tests)));
85
 
86
INSTANTIATE_TEST_CASE_P(And,
87
                        ArithmeticRegImmed8Test,
88
                        ::testing::Values(
89
                            // and bl, 1
90
                            ArithImmed8Params(std::vector<uint8_t>{0x80, 0xe3,
91
                                                                   0x01},
92
                                              {1, 1, 0, false})));
93
 
94
INSTANTIATE_TEST_CASE_P(And,
95
                        ArithmeticMemImmed8Test,
96
                        ::testing::Values(
97
                            // and byte [bx], 1
98
                            ArithImmed8Params(std::vector<uint8_t>{0x80, 0x27,
99
                                                                   0x01},
100
                                              {1, 1, 0, false})));
101
 
102
INSTANTIATE_TEST_CASE_P(And,
103
                        ArithmeticRegImmed16Test,
104
                        ::testing::Values(
105
                            // and bx, 1
106
                            ArithImmed16Params(std::vector<uint8_t>{0x81, 0xe3,
107
                                                                    0x01, 0x0},
108
                                               {1, 1, 0, false})));
109
 
110
INSTANTIATE_TEST_CASE_P(And,
111
                        ArithmeticMemImmed16Test,
112
                        ::testing::Values(
113
                            // and wandd [bx], 1
114
                            ArithImmed16Params(std::vector<uint8_t>{0x81, 0x27,
115
                                                                    0x01, 0x00},
116
                                               {1, 1, 0, false})));
117
 
118
INSTANTIATE_TEST_CASE_P(
119
    And,
120
    ArithmeticRegImmed16TestExtend,
121
    ::testing::Values(
122
        // and bx, 1
123
        ArithImmed16Params(std::vector<uint8_t>{0x83, 0xe3, 0x01},
124
                           {0x0101, 1, 0, false}),
125
        // and bx, -1
126
        ArithImmed16Params(std::vector<uint8_t>{0x83, 0xe3, 0xff},
127
                           {0x0101, 0x0101, 0, false})));
128
 
129
INSTANTIATE_TEST_CASE_P(
130
    And,
131
    ArithmeticMemImmed16TestExtend,
132
    ::testing::Values(
133
        // and [bx], 1
134
        ArithImmed16Params(std::vector<uint8_t>{0x83, 0x27, 0x01},
135
                           {0x0101, 1, 0, false}),
136
        // and [bx], -1
137
        ArithImmed16Params(std::vector<uint8_t>{0x83, 0x27, 0xff},
138
                           {0x0101, 0x0101, 0, false})));
139
 
140
INSTANTIATE_TEST_CASE_P(And,
141
                        ArithmeticAlImmedTest,
142
                        ::testing::Values(
143
                            // and al, 1
144
                            ArithImmed8Params(std::vector<uint8_t>{0x24, 0x01},
145
                                              {1, 1, 0, false})));
146
 
147
INSTANTIATE_TEST_CASE_P(And,
148
                        ArithmeticAxImmedTest,
149
                        ::testing::Values(
150
                            // and ax, 1
151
                            ArithImmed16Params(std::vector<uint8_t>{0x25, 0x01,
152
                                                                    0x0},
153
                                               {1, 1, 0, false})));

powered by: WebSVN 2.1.0

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