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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [instructions/] [TestPointer.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
 
22
TEST_F(EmulateFixture, LeaAxBx)
23
{
24
    // lea ax, [bx]
25
    set_instruction({0x8d, 0x07});
26
    write_reg(BX, 0x1234);
27
 
28
    emulate();
29
 
30
    ASSERT_EQ(0x1234, read_reg(AX));
31
}
32
 
33
TEST_F(EmulateFixture, LeaAxBxSiDisplacement)
34
{
35
    // lea ax, [bx+si+0x1234]
36
    set_instruction({0x8d, 0x80, 0x34, 0x12});
37
    write_reg(BX, 0x0400);
38
    write_reg(SI, 0x0100);
39
 
40
    emulate();
41
 
42
    ASSERT_EQ(0x1234 + 0x0400 + 0x0100, read_reg(AX));
43
}
44
 
45
TEST_F(EmulateFixture, Lds)
46
{
47
    // lds si, [0x0100]
48
    set_instruction({0xc5, 0x36, 0x00, 0x01});
49
    write_mem32(0x0100, 0x80001234);
50
    emulate();
51
 
52
    ASSERT_EQ(0x8000, read_reg(DS));
53
    ASSERT_EQ(0x1234, read_reg(SI));
54
}
55
 
56
TEST_F(EmulateFixture, Les)
57
{
58
    // les si, [0x0100]
59
    set_instruction({0xc4, 0x36, 0x00, 0x01});
60
    write_mem32(0x0100, 0x80001234);
61
    emulate();
62
 
63
    ASSERT_EQ(0x8000, read_reg(ES));
64
    ASSERT_EQ(0x1234, read_reg(SI));
65
}

powered by: WebSVN 2.1.0

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