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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestLoop.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 <gtest/gtest.h>
19
 
20
#include "EmulateFixture.h"
21
#include "Flags.h"
22
 
23
TEST_F(EmulateFixture, LoopNotTaken)
24
{
25
    write_reg(CX, 1);
26
    write_reg(IP, 0x100);
27
 
28
    // loop ip-3
29
    set_instruction({0xe2, 0xfd});
30
 
31
    emulate();
32
 
33
    ASSERT_EQ(0x102, read_reg(IP));
34
}
35
 
36
TEST_F(EmulateFixture, LoopTaken)
37
{
38
    write_reg(CX, 2);
39
    write_reg(IP, 0x100);
40
 
41
    // loop ip-3
42
    set_instruction({0xe2, 0xfd});
43
 
44
    emulate();
45
 
46
    ASSERT_EQ(0x0ff, read_reg(IP));
47
}
48
 
49
TEST_F(EmulateFixture, LoopeNotTakenNonZero)
50
{
51
    write_reg(CX, 2);
52
    write_reg(IP, 0x100);
53
    write_flags(0);
54
 
55
    // loope ip-3
56
    set_instruction({0xe1, 0xfd});
57
 
58
    emulate();
59
 
60
    ASSERT_EQ(0x102, read_reg(IP));
61
}
62
 
63
TEST_F(EmulateFixture, LoopeNotTaken)
64
{
65
    write_reg(CX, 1);
66
    write_reg(IP, 0x100);
67
    write_flags(ZF);
68
 
69
    // loope ip-3
70
    set_instruction({0xe1, 0xfd});
71
 
72
    emulate();
73
 
74
    ASSERT_EQ(0x102, read_reg(IP));
75
}
76
 
77
TEST_F(EmulateFixture, LoopeTaken)
78
{
79
    write_reg(CX, 2);
80
    write_reg(IP, 0x100);
81
    write_flags(ZF);
82
 
83
    // loope ip-3
84
    set_instruction({0xe1, 0xfd});
85
 
86
    emulate();
87
 
88
    ASSERT_EQ(0x0ff, read_reg(IP));
89
}
90
 
91
TEST_F(EmulateFixture, LoopnzNotTakenNonZero)
92
{
93
    write_reg(CX, 1);
94
    write_reg(IP, 0x100);
95
    write_flags(0);
96
 
97
    // loopnz ip-3
98
    set_instruction({0xe0, 0xfd});
99
 
100
    emulate();
101
 
102
    ASSERT_EQ(0x102, read_reg(IP));
103
}
104
 
105
TEST_F(EmulateFixture, LoopnzNotTaken)
106
{
107
    write_reg(CX, 2);
108
    write_reg(IP, 0x100);
109
    write_flags(ZF);
110
 
111
    // loopnz ip-3
112
    set_instruction({0xe0, 0xfd});
113
 
114
    emulate();
115
 
116
    ASSERT_EQ(0x102, read_reg(IP));
117
}
118
 
119
TEST_F(EmulateFixture, LoopnzTaken)
120
{
121
    write_reg(CX, 2);
122
    write_reg(IP, 0x100);
123
    write_flags(0);
124
 
125
    // loopnz ip-3
126
    set_instruction({0xe0, 0xfd});
127
 
128
    emulate();
129
 
130
    ASSERT_EQ(0x0ff, read_reg(IP));
131
}

powered by: WebSVN 2.1.0

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