Debian Codegraph @

src/cpu/lazyflags.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #if !defined __LAZYFLAGS_H
20 #define __LAZYFLAGS_H
21
22 //Flag Handling
23 Bit32u get_CF(void);
24 Bit32u get_AF(void);
25 Bit32u get_ZF(void);
26 Bit32u get_SF(void);
27 Bit32u get_OF(void);
28 Bit32u get_PF(void);
29
30 Bitu FillFlags(void);
31 void FillFlagsNoCFOF(void);
32 void DestroyConditionFlags(void);
33
34 #include "regs.h"
35
36 struct LazyFlags {
37 GenReg32 var1,var2,res;
38 Bitu type;
39 Bitu prev_type;
40 Bitu oldcf;
41 };
42
43 extern LazyFlags lfags;
44
45 #define lf_var1b lflags.var1.byte[BL_INDEX]
46 #define lf_var2b lflags.var2.byte[BL_INDEX]
47 #define lf_resb lflags.res.byte[BL_INDEX]
48
49 #define lf_var1w lflags.var1.word[W_INDEX]
50 #define lf_var2w lflags.var2.word[W_INDEX]
51 #define lf_resw lflags.res.word[W_INDEX]
52
53 #define lf_var1d lflags.var1.dword[DW_INDEX]
54 #define lf_var2d lflags.var2.dword[DW_INDEX]
55 #define lf_resd lflags.res.dword[DW_INDEX]
56
57
58 extern LazyFlags lflags;
59
60 #define SETFLAGSb(FLAGB) \
61 { \
62 SETFLAGBIT(OF,get_OF()); \
63 lflags.type=t_UNKNOWN; \
64 CPU_SetFlags(FLAGB,FMASK_NORMAL & 0xff); \
65 }
66
67 #define SETFLAGSw(FLAGW) \
68 { \
69 lflags.type=t_UNKNOWN; \
70 CPU_SetFlagsw(FLAGW); \
71 }
72
73 #define SETFLAGSd(FLAGD) \
74 { \
75 lflags.type=t_UNKNOWN; \
76 CPU_SetFlagsd(FLAGD); \
77 }
78
79 #define LoadCF SETFLAGBIT(CF,get_CF());
80 #define LoadZF SETFLAGBIT(ZF,get_ZF());
81 #define LoadSF SETFLAGBIT(SF,get_SF());
82 #define LoadOF SETFLAGBIT(OF,get_OF());
83 #define LoadAF SETFLAGBIT(AF,get_AF());
84
85 #define TFLG_O (get_OF())
86 #define TFLG_NO (!get_OF())
87 #define TFLG_B (get_CF())
88 #define TFLG_NB (!get_CF())
89 #define TFLG_Z (get_ZF())
90 #define TFLG_NZ (!get_ZF())
91 #define TFLG_BE (get_CF() || get_ZF())
92 #define TFLG_NBE (!get_CF() && !get_ZF())
93 #define TFLG_S (get_SF())
94 #define TFLG_NS (!get_SF())
95 #define TFLG_P (get_PF())
96 #define TFLG_NP (!get_PF())
97 #define TFLG_L ((get_SF()!=0) != (get_OF()!=0))
98 #define TFLG_NL ((get_SF()!=0) == (get_OF()!=0))
99 #define TFLG_LE (get_ZF() || ((get_SF()!=0) != (get_OF()!=0)))
100 #define TFLG_NLE (!get_ZF() && ((get_SF()!=0) == (get_OF()!=0)))
101
102 //Types of Flag changing instructions
103 enum {
104 t_UNKNOWN=0,
105 t_ADDb,t_ADDw,t_ADDd,
106 t_ORb,t_ORw,t_ORd,
107 t_ADCb,t_ADCw,t_ADCd,
108 t_SBBb,t_SBBw,t_SBBd,
109 t_ANDb,t_ANDw,t_ANDd,
110 t_SUBb,t_SUBw,t_SUBd,
111 t_XORb,t_XORw,t_XORd,
112 t_CMPb,t_CMPw,t_CMPd,
113 t_INCb,t_INCw,t_INCd,
114 t_DECb,t_DECw,t_DECd,
115 t_TESTb,t_TESTw,t_TESTd,
116 t_SHLb,t_SHLw,t_SHLd,
117 t_SHRb,t_SHRw,t_SHRd,
118 t_SARb,t_SARw,t_SARd,
119 t_ROLb,t_ROLw,t_ROLd,
120 t_RORb,t_RORw,t_RORd,
121 t_RCLb,t_RCLw,t_RCLd,
122 t_RCRb,t_RCRw,t_RCRd,
123 t_NEGb,t_NEGw,t_NEGd,
124
125 t_DSHLw,t_DSHLd,
126 t_DSHRw,t_DSHRd,
127 t_MUL,t_DIV,
128 t_NOTDONE,
129 t_LASTFLAG
130 };
131
132 #endif