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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [sim/] [common/] [RegisterFile.h] - 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
#pragma once
19
 
20
#include <stdint.h>
21
 
22
enum GPR {
23
    AX,
24
    CX,
25
    DX,
26
    BX,
27
    SP,
28
    BP,
29
    SI,
30
    DI,
31
    ES,
32
    CS,
33
    SS,
34
    DS,
35
    IP,
36
    NUM_16BIT_REGS,
37
    AL = NUM_16BIT_REGS,
38
    CL,
39
    DL,
40
    BL,
41
    AH,
42
    CH,
43
    DH,
44
    BH,
45
    NUM_REGS
46
};
47
 
48
enum FlagBitPos {
49
    CF_OFFS = 0,
50
    PF_OFFS = 2,
51
    AF_OFFS = 4,
52
    ZF_OFFS = 6,
53
    SF_OFFS = 7,
54
    TF_OFFS = 8,
55
    IF_OFFS = 9,
56
    DF_OFFS = 10,
57
    OF_OFFS = 11
58
};
59
 
60
enum Flag {
61
    CF = (1 << CF_OFFS),
62
    PF = (1 << PF_OFFS),
63
    AF = (1 << AF_OFFS),
64
    ZF = (1 << ZF_OFFS),
65
    SF = (1 << SF_OFFS),
66
    TF = (1 << TF_OFFS),
67
    IF = (1 << IF_OFFS),
68
    DF = (1 << DF_OFFS),
69
    OF = (1 << OF_OFFS),
70
};
71
 
72
enum { FLAGS_STUCK_BITS = 0xf000 | (1 << 1) };
73
 
74
class RegisterFile
75
{
76
public:
77
    RegisterFile();
78
    virtual void reset();
79
    virtual void set(GPR regnum, uint16_t value);
80
    virtual uint16_t get(GPR regnum) const;
81
    virtual uint16_t get_flags() const;
82
    virtual bool get_flag(enum Flag f) const;
83
    virtual void set_flags(uint16_t val, uint16_t mask = 0xffff);
84
    virtual bool has_written() const;
85
    virtual void clear_has_written();
86
 
87
private:
88
    uint16_t registers[NUM_16BIT_REGS];
89
    uint16_t flags;
90
    bool written;
91
};

powered by: WebSVN 2.1.0

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