Skip to content

Commit 3d5f8a5

Browse files
committed
Merge remote-tracking branch 'origin/GP-4273_ghidorahrex_z80_inc_fix'
into patch (Closes NationalSecurityAgency#2247, Closes NationalSecurityAgency#2277)
2 parents b09dcee + 6b2bcd1 commit 3d5f8a5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Ghidra/Processors/Z80/data/languages/z80.slaspec

+12-4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ macro additionFlags(operand1, operand2) {
111111
$(C_flag) = carry(operand1, operand2);
112112
}
113113

114+
macro additionFlagsNoC(operand1, operand2) {
115+
local AFmask = -1 >> 4;
116+
$(H_flag) = (((operand1 & AFmask) + (operand2 & AFmask)) & (AFmask + 1)) != 0;
117+
$(PV_flag) = scarry(operand1, operand2);
118+
$(N_flag) = 0;
119+
# $(C_flag) is not affected
120+
}
121+
114122
macro additionFlagsNoPV(operand1, operand2) {
115123
local AFmask = -1 >> 4;
116124
$(H_flag) = (((operand1 & AFmask) + (operand2 & AFmask)) & (AFmask + 1)) != 0;
@@ -1021,7 +1029,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; }
10211029

10221030
reg3_3 = reg3_3 + 1;
10231031
setResultFlags(reg3_3);
1024-
additionFlags(r_temp, 1);
1032+
additionFlagsNoC(r_temp, 1);
10251033
}
10261034

10271035
:INC (HL) is op0_8=0x34 & HL {
@@ -1032,7 +1040,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; }
10321040
val = val + 1;
10331041
MemStore(HL,val);
10341042
setResultFlags(val);
1035-
additionFlags(val_temp, 1);
1043+
additionFlagsNoC(val_temp, 1);
10361044
}
10371045

10381046
:INC ixMem8 is op0_8=0xdd; op0_8=0x34; ixMem8 {
@@ -1042,7 +1050,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; }
10421050
val = val + 1;
10431051
ixMem8 = val;
10441052
setResultFlags(val);
1045-
additionFlags(val_temp, 1);
1053+
additionFlagsNoC(val_temp, 1);
10461054
}
10471055

10481056
:INC iyMem8 is op0_8=0xfd; op0_8=0x34; iyMem8 {
@@ -1052,7 +1060,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; }
10521060
val = val + 1;
10531061
iyMem8 = val;
10541062
setResultFlags(val);
1055-
additionFlags(val_temp, 1);
1063+
additionFlagsNoC(val_temp, 1);
10561064
}
10571065

10581066
:DEC reg3_3 is op6_2=0x0 & reg3_3 & bits0_3=0x5 {

0 commit comments

Comments
 (0)