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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestRet.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, RetIntra)
24
{
25
    write_reg(CS, 0x2000);
26
    write_reg(IP, 0x0030);
27
    write_reg(SP, 0x00fe);
28
    write_mem16(0x00fe, 0x0100, SS);
29
 
30
    set_instruction({0xc3});
31
 
32
    emulate();
33
 
34
    ASSERT_EQ(0x0100, read_reg(SP));
35
    ASSERT_EQ(0x2000, read_reg(CS));
36
    ASSERT_EQ(0x0100, read_reg(IP));
37
}
38
 
39
TEST_F(EmulateFixture, RetIntraAddSp)
40
{
41
    write_reg(CS, 0x2000);
42
    write_reg(IP, 0x0030);
43
    write_reg(SP, 0x00fe);
44
    write_mem16(0x00fe, 0x0100, SS);
45
 
46
    set_instruction({0xc2, 0x10, 0x00});
47
 
48
    emulate();
49
 
50
    ASSERT_EQ(0x0110, read_reg(SP));
51
    ASSERT_EQ(0x2000, read_reg(CS));
52
    ASSERT_EQ(0x0100, read_reg(IP));
53
}
54
 
55
TEST_F(EmulateFixture, RetInter)
56
{
57
    write_reg(CS, 0x2000);
58
    write_reg(IP, 0x0030);
59
    write_reg(SP, 0x00fc);
60
    write_mem16(0x00fe, 0x8000, SS);
61
    write_mem16(0x00fc, 0x0100, SS);
62
 
63
    set_instruction({0xcb});
64
 
65
    emulate();
66
 
67
    ASSERT_EQ(0x0100, read_reg(SP));
68
    ASSERT_EQ(0x8000, read_reg(CS));
69
    ASSERT_EQ(0x0100, read_reg(IP));
70
}
71
 
72
TEST_F(EmulateFixture, RetInterAddSp)
73
{
74
    write_reg(CS, 0x2000);
75
    write_reg(IP, 0x0030);
76
    write_reg(SP, 0x00fc);
77
    write_mem16(0x00fe, 0x8000, SS);
78
    write_mem16(0x00fc, 0x0100, SS);
79
 
80
    set_instruction({0xca, 0x10, 0x00});
81
 
82
    emulate();
83
 
84
    ASSERT_EQ(0x0110, read_reg(SP));
85
    ASSERT_EQ(0x8000, read_reg(CS));
86
    ASSERT_EQ(0x0100, read_reg(IP));
87
}
88
 
89
TEST_F(EmulateFixture, Iret)
90
{
91
    write_reg(CS, 0x2000);
92
    write_reg(IP, 0x0030);
93
    write_reg(SP, 0x00fa);
94
    write_mem16(0x00fe, FLAGS_STUCK_BITS | CF, SS);
95
    write_mem16(0x00fc, 0x8000, SS);
96
    write_mem16(0x00fa, 0x0100, SS);
97
 
98
    set_instruction({0xcf});
99
 
100
    emulate();
101
 
102
    ASSERT_EQ(0x0100, read_reg(SP));
103
    ASSERT_EQ(0x8000, read_reg(CS));
104
    ASSERT_EQ(0x0100, read_reg(IP));
105
    ASSERT_PRED_FORMAT2(AssertFlagsEqual, read_flags(), FLAGS_STUCK_BITS | CF);
106
}

powered by: WebSVN 2.1.0

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