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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestEnter.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, EnterNoNestNoAlloc)
24
{
25
    write_reg(SP, 0x0100);
26
    write_reg(BP, 0x0200);
27
 
28
    set_instruction({0xc8, 0x00, 0x00, 0x00});
29
 
30
    emulate();
31
 
32
    EXPECT_EQ(0x00fe, read_reg(BP));
33
    EXPECT_EQ(0x00fe, read_reg(SP));
34
}
35
 
36
TEST_F(EmulateFixture, EnterNoNestAlloc10)
37
{
38
    write_reg(SP, 0x0100);
39
    write_reg(BP, 0x0200);
40
 
41
    set_instruction({0xc8, 0x10, 0x00, 0x00});
42
 
43
    emulate();
44
 
45
    EXPECT_EQ(0x00fe, read_reg(BP));
46
    EXPECT_EQ(0x00fe - 0x10, read_reg(SP));
47
}
48
 
49
TEST_F(EmulateFixture, EnterNest4)
50
{
51
    write_reg(SP, 0x0100);
52
    write_reg(BP, 0x0200);
53
 
54
    for (int i = 0; i < 3; ++i)
55
        write_mem16(0x200 - (i + 1) * sizeof(uint16_t), i + 1, SS);
56
 
57
    set_instruction({0xc8, 0x00, 0x00, 0x04});
58
 
59
    emulate();
60
 
61
    auto addr = 0x0100 - 2;
62
    EXPECT_EQ(0x0200, read_mem16(addr, SS));
63
    for (int i = 0; i < 3; ++i) {
64
        addr -= 2;
65
        EXPECT_EQ(i + 1, read_mem16(addr, SS));
66
    }
67
 
68
    addr -= 2;
69
    EXPECT_EQ(0x00fe, read_mem16(addr, SS));
70
 
71
    EXPECT_EQ(read_reg(BP), 0x0fe);
72
    EXPECT_EQ(read_reg(SP), addr);
73
}
74
 
75
TEST_F(EmulateFixture, EnterNestMask32)
76
{
77
    write_reg(SP, 0x0100);
78
    write_reg(BP, 0x0200);
79
 
80
    for (int i = 0; i < 128; ++i)
81
        write_mem16(0x200 - (i + 1) * sizeof(uint16_t), 0xa5a5, SS);
82
 
83
    set_instruction({0xc8, 0x00, 0x00, 0xff});
84
 
85
    emulate();
86
 
87
    auto addr = 0x0100 - 2;
88
    int count = 0;
89
    for (int i = 0; i < 128; ++i) {
90
        addr -= 2;
91
 
92
        if (read_mem16(addr, SS) != 0xa5a5)
93
            break;
94
 
95
        ++count;
96
        EXPECT_LT(i, 32);
97
    }
98
 
99
    EXPECT_EQ(count, 30);
100
}

powered by: WebSVN 2.1.0

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