-
Notifications
You must be signed in to change notification settings - Fork 1
/
flagmaip.cpp
77 lines (72 loc) · 2.07 KB
/
flagmaip.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "internal8085.h"
void Internal8085::setFlagC(bool val){
F.setBit(7, val);
emit F.regEditedInternally_SIG(F.toString());
}
void Internal8085::setFlagP(bool val){
F.setBit(5, val);
emit F.regEditedInternally_SIG(F.toString());
}
void Internal8085::setFlagAC(bool val){
F.setBit(3, val);
emit F.regEditedInternally_SIG(F.toString());
}
void Internal8085::setFlagZ(bool val){
F.setBit(1, val);
emit F.regEditedInternally_SIG(F.toString());
}
void Internal8085::setFlagS(bool val){
F.setBit(0, val);
emit F.regEditedInternally_SIG(F.toString());
}
void Internal8085::setFlagCFromOutside(QString val){
bool bitVal = (((val == tr(""))|(val == tr("0")))?0:1);
F.setBit(7, bitVal);
emit F.regFEditedFromRegDockFlags_SIG(F.toString());
}
void Internal8085::setFlagPFromOutside(QString val){
bool bitVal = (((val == tr(""))|(val == tr("0")))?0:1);
F.setBit(5, bitVal);
emit F.regFEditedFromRegDockFlags_SIG(F.toString());
}
void Internal8085::setFlagACFromOutside(QString val){
bool bitVal = (((val == tr(""))|(val == tr("0")))?0:1);
F.setBit(3, bitVal);
emit F.regFEditedFromRegDockFlags_SIG(F.toString());
}
void Internal8085::setFlagZFromOutside(QString val){
bool bitVal = (((val == tr(""))|(val == tr("0")))?0:1);
F.setBit(1, bitVal);
emit F.regFEditedFromRegDockFlags_SIG(F.toString());
}
void Internal8085::setFlagSFromOutside(QString val){
bool bitVal = (((val == tr(""))|(val == tr("0")))?0:1);
F.setBit(0, bitVal);
emit F.regFEditedFromRegDockFlags_SIG(F.toString());
}
bool Internal8085::getFlagC(){
return F.testBit(7);
}
bool Internal8085::getFlagP(){
return F.testBit(5);
}
bool Internal8085::getFlagAC(){
return F.testBit(3);
}
bool Internal8085::getFlagZ(){
return F.testBit(1);
}
bool Internal8085::getFlagS(){
return F.testBit(0);
}
void Internal8085::updateFlags(){
bool isZero = true;
bool xr = false;
for(int i = 0;i < 8;++i){
isZero &= (!A.testBit(i));
xr ^= A.testBit(i);
}
setFlagS(A.testBit(0));
setFlagP(!xr);
setFlagZ(isZero);
}