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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [sim/] [cppmodel/] [instructions/] [cmp.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
// cmp r, r/m, 8-bit
19
void EmulatorPimpl::cmp38()
20
{
21
    modrm_decoder->set_width(OP_WIDTH_8);
22
    modrm_decoder->decode();
23
 
24
    uint8_t v1 = read_data<uint8_t>();
25
    uint8_t v2 = registers->get(modrm_decoder->reg());
26
 
27
    uint8_t result;
28
    uint16_t flags;
29
    std::tie(flags, result) = do_sub<uint8_t>(v1, v2);
30
 
31
    registers->set_flags(flags, OF | SF | ZF | AF | CF | PF);
32
}
33
 
34
// cmp r, r/m, 16-bit
35
void EmulatorPimpl::cmp39()
36
{
37
    modrm_decoder->set_width(OP_WIDTH_16);
38
    modrm_decoder->decode();
39
 
40
    uint16_t v1 = read_data<uint16_t>();
41
    uint16_t v2 = registers->get(modrm_decoder->reg());
42
 
43
    uint16_t result;
44
    uint16_t flags;
45
    std::tie(flags, result) = do_sub<uint16_t>(v1, v2);
46
 
47
    registers->set_flags(flags, OF | SF | ZF | AF | CF | PF);
48
}
49
 
50
// cmp r/m, r, 8-bit
51
void EmulatorPimpl::cmp3a()
52
{
53
    modrm_decoder->set_width(OP_WIDTH_8);
54
    modrm_decoder->decode();
55
 
56
    uint8_t v1 = read_data<uint8_t>();
57
    uint8_t v2 = registers->get(modrm_decoder->reg());
58
 
59
    uint8_t result;
60
    uint16_t flags;
61
    std::tie(flags, result) = do_sub<uint8_t>(v2, v1);
62
 
63
    registers->set_flags(flags, OF | SF | ZF | AF | CF | PF);
64
}
65
 
66
// cmp r/m, r, 16-bit
67
void EmulatorPimpl::cmp3b()
68
{
69
    modrm_decoder->set_width(OP_WIDTH_16);
70
    modrm_decoder->decode();
71
 
72
    uint16_t v1 = read_data<uint16_t>();
73
    uint16_t v2 = registers->get(modrm_decoder->reg());
74
 
75
    uint16_t result;
76
    uint16_t flags;
77
    std::tie(flags, result) = do_sub<uint16_t>(v2, v1);
78
 
79
    registers->set_flags(flags, OF | SF | ZF | AF | CF | PF);
80
}
81
 
82
void EmulatorPimpl::cmp3c()
83
{
84
    auto v1 = registers->get(AL);
85
    auto v2 = fetch_byte();
86
    uint8_t result;
87
    uint16_t flags;
88
    std::tie(flags, result) = do_sub<uint8_t>(v1, v2);
89
 
90
    registers->set_flags(flags, OF | SF | ZF | AF | CF | PF);
91
}
92
 
93
void EmulatorPimpl::cmp3d()
94
{
95
    auto v1 = registers->get(AX);
96
    auto v2 = fetch_16bit();
97
    uint16_t result;
98
    uint16_t flags;
99
    std::tie(flags, result) = do_sub<uint16_t>(v1, v2);
100
 
101
    registers->set_flags(flags, OF | SF | ZF | AF | CF | PF);
102
}

powered by: WebSVN 2.1.0

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