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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestTest.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>> test8_tests = {
27
    {0, 0, 0, PF | ZF, false}, {0xf, 0xf, 0x0f, PF, false},
28
        {0x0f, 0xf0, 0x0f, PF | ZF, false}, {0x0f, 0x01, 0x0f, 0, false},
29
};
30
 
31
static const std::vector<struct ArithmeticTest<uint16_t>> test16_tests = {
32
    {0, 0, 0, PF | ZF, false}, {0xf, 0xf, 0x0f, PF, false},
33
        {0x000f, 0xf000, 0xf, PF | ZF, false},
34
        {0xf00f, 0xf000, 0xf00f, PF | SF, false}, {0x0f, 0x01, 0x0f, 0, false},
35
};
36
 
37
INSTANTIATE_TEST_CASE_P(Test,
38
                        ArithmeticRegReg8Test,
39
                        ::testing::Values(
40
                            // test al, bl
41
                            Arith8Params({0x84, 0xd8}, test8_tests)));
42
 
43
INSTANTIATE_TEST_CASE_P(Test,
44
                        ArithmeticMemReg8Test,
45
                        ::testing::Values(
46
                            // test [bx], al
47
                            Arith8Params({0x84, 0x07}, test8_tests)));
48
 
49
INSTANTIATE_TEST_CASE_P(Test,
50
                        ArithmeticRegReg16Test,
51
                        ::testing::Values(
52
                            // test ax, bx
53
                            Arith16Params({0x85, 0xd8}, test16_tests)));
54
 
55
INSTANTIATE_TEST_CASE_P(Test,
56
                        ArithmeticRegMem16Test,
57
                        ::testing::Values(
58
                            // adc [bx], ax
59
                            Arith16Params({0x85, 0x07}, test16_tests)));
60
 
61
INSTANTIATE_TEST_CASE_P(Test,
62
                        ArithmeticRegImmed8Test,
63
                        ::testing::Values(
64
                            // test bl, 1
65
                            ArithImmed8Params(std::vector<uint8_t>{0xf6, 0xc3,
66
                                                                   0x01},
67
                                              {1, 1, 0, false})));
68
 
69
INSTANTIATE_TEST_CASE_P(
70
    Test,
71
    ArithmeticMemImmed8Test,
72
    ::testing::Values(
73
        // test byte [bx], 1
74
        ArithImmed8Params(std::vector<uint8_t>{0xf6, 0x07, 0x01},
75
                          {1, 1, 0, false}),
76
        // test byte [bx], 1
77
        ArithImmed8Params(std::vector<uint8_t>{0xf6, 0x0f, 0x01},
78
                          {1, 1, 0, false})));
79
 
80
INSTANTIATE_TEST_CASE_P(
81
    Test,
82
    ArithmeticRegImmed16Test,
83
    ::testing::Values(
84
        // test bx, 1
85
        ArithImmed16Params(std::vector<uint8_t>{0xf7, 0xc3, 0x01, 0x0},
86
                           {1, 1, 0, false}),
87
        // test bx, 1
88
        ArithImmed16Params(std::vector<uint8_t>{0xf7, 0xcb, 0x01, 0x0},
89
                           {1, 1, 0, false})));
90
 
91
INSTANTIATE_TEST_CASE_P(
92
    Test,
93
    ArithmeticMemImmed16Test,
94
    ::testing::Values(
95
        // test word [bx], 1
96
        ArithImmed16Params(std::vector<uint8_t>{0xf7, 0x07, 0x01, 0x00},
97
                           {1, 1, 0, false}),
98
        // test word [bx], 1
99
        ArithImmed16Params(std::vector<uint8_t>{0xf7, 0x0f, 0x01, 0x00},
100
                           {1, 1, 0, false})));
101
 
102
INSTANTIATE_TEST_CASE_P(Test,
103
                        ArithmeticAlImmedTest,
104
                        ::testing::Values(
105
                            // test al, 1
106
                            ArithImmed8Params(std::vector<uint8_t>{0xa8, 0x01},
107
                                              {1, 1, 0, false})));
108
 
109
INSTANTIATE_TEST_CASE_P(Test,
110
                        ArithmeticAxImmedTest,
111
                        ::testing::Values(
112
                            // test ax, 1
113
                            ArithImmed16Params(std::vector<uint8_t>{0xa9, 0x01,
114
                                                                    0x0},
115
                                               {1, 1, 0, false})));

powered by: WebSVN 2.1.0

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