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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestCall.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, CallDirectIntra)
24
{
25
    write_reg(CS, 0x2000);
26
    write_reg(IP, 0x0030);
27
    write_reg(SP, 0x0100);
28
    set_instruction({0xe8, 0x10, 0x20});
29
 
30
    emulate();
31
 
32
    ASSERT_EQ(0x00fe, read_reg(SP));
33
    ASSERT_EQ(0x0033, read_mem16(0x00fe, SS));
34
    ASSERT_EQ(0x2000, read_reg(CS));
35
    ASSERT_EQ(0x2043, read_reg(IP));
36
}
37
 
38
TEST_F(EmulateFixture, CallIndirectIntraReg)
39
{
40
    write_reg(CS, 0x2000);
41
    write_reg(IP, 0x0030);
42
    write_reg(SP, 0x0100);
43
 
44
    write_reg(BX, 0x2010);
45
 
46
    // call near bx
47
    set_instruction({0xff, 0xd3});
48
 
49
    emulate();
50
 
51
    ASSERT_EQ(0x00fe, read_reg(SP));
52
    ASSERT_EQ(0x0032, read_mem16(0x00fe, SS));
53
    ASSERT_EQ(0x2000, read_reg(CS));
54
    ASSERT_EQ(0x2010, read_reg(IP));
55
}
56
 
57
TEST_F(EmulateFixture, CallIndirectIntraMem)
58
{
59
    write_reg(CS, 0x2000);
60
    write_reg(IP, 0x0030);
61
    write_reg(SP, 0x0100);
62
 
63
    write_reg(BX, 0x0200);
64
    write_mem16(0x0200, 0x2010);
65
 
66
    // call near [bx]
67
    set_instruction({0xff, 0x17});
68
 
69
    emulate();
70
 
71
    ASSERT_EQ(0x00fe, read_reg(SP));
72
    ASSERT_EQ(0x0032, read_mem16(0x00fe, SS));
73
    ASSERT_EQ(0x2000, read_reg(CS));
74
    ASSERT_EQ(0x2010, read_reg(IP));
75
}
76
 
77
TEST_F(EmulateFixture, CallDirectInter)
78
{
79
    write_reg(CS, 0x2000);
80
    write_reg(IP, 0x0030);
81
    write_reg(SP, 0x0100);
82
    set_instruction({0x9a, 0x10, 0x20, 0x00, 0x80});
83
 
84
    emulate();
85
 
86
    ASSERT_EQ(0x00fc, read_reg(SP));
87
    ASSERT_EQ(0x2000, read_mem16(0x00fe, SS));
88
    ASSERT_EQ(0x0035, read_mem16(0x00fc, SS));
89
    ASSERT_EQ(0x8000, read_reg(CS));
90
    ASSERT_EQ(0x2010, read_reg(IP));
91
}
92
 
93
TEST_F(EmulateFixture, CallIndirectInter)
94
{
95
    write_reg(CS, 0x2000);
96
    write_reg(IP, 0x0030);
97
    write_reg(SP, 0x0100);
98
 
99
    write_reg(BX, 0x0200);
100
    write_mem16(0x0202, 0x8000);
101
    write_mem16(0x0200, 0x2010);
102
 
103
    // call far [bx]
104
    set_instruction({0xff, 0x1f});
105
 
106
    emulate();
107
 
108
    ASSERT_EQ(0x00fc, read_reg(SP));
109
    ASSERT_EQ(0x2000, read_mem16(0x00fe, SS));
110
    ASSERT_EQ(0x0032, read_mem16(0x00fc, SS));
111
    EXPECT_EQ(0x8000, read_reg(CS));
112
    EXPECT_EQ(0x2010, read_reg(IP));
113
}

powered by: WebSVN 2.1.0

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