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

Subversion Repositories s80186

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

powered by: WebSVN 2.1.0

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