diff --git a/Ghidra/Processors/Z80/data/languages/z80.slaspec b/Ghidra/Processors/Z80/data/languages/z80.slaspec index b5071b9711..2c5c98fa14 100644 --- a/Ghidra/Processors/Z80/data/languages/z80.slaspec +++ b/Ghidra/Processors/Z80/data/languages/z80.slaspec @@ -17,7 +17,7 @@ define space register type=register_space size=1; define register offset=0x00 size=1 [ F A C B E D L H I R ]; define register offset=0x00 size=2 [ AF BC DE HL ]; -define register offset=0x20 size=1 [ A_ F_ B_ C_ D_ E_ H_ L_ ]; # Alternate registers +define register offset=0x20 size=1 [ F_ A_ C_ B_ E_ D_ L_ H_ ]; # Alternate registers define register offset=0x20 size=2 [ AF_ BC_ DE_ HL_ ]; # Alternate registers define register offset=0x40 size=2 [ _ PC SP IX IY ]; @@ -34,12 +34,12 @@ define register offset=0xf0 size=4 contextreg; assume8bitIOSpace =(0,0) # only applies to Z180 ; # Flag bits (?? manual is very confusing - could be typos!) -@define C_flag "F[0,1]" # C: Carry -@define N_flag "F[1,1]" # N: Add/Subtract - used by DAA to distinguish between ADD and SUB instructions (0=ADD,1=SUB) +@define C_flag "F[0,1]" # C: Carry +@define N_flag "F[1,1]" # N: Add/Subtract - used by DAA to distinguish between ADD and SUB instructions (0=ADD,1=SUB) @define PV_flag "F[2,1]" # PV: Parity/Overflow -@define H_flag "F[4,1]" # H: Half Carry -@define Z_flag "F[6,1]" # Z: Zero -@define S_flag "F[7,1]" # S: Sign +@define H_flag "F[4,1]" # H: Half Carry +@define Z_flag "F[6,1]" # Z: Zero +@define S_flag "F[7,1]" # S: Sign define token opbyte (8) op0_8 = (0,7) @@ -48,8 +48,6 @@ define token opbyte (8) pRegPair4_2 = (4,5) sRegPair4_2 = (4,5) qRegPair4_2 = (4,5) - qRegPair4_2a = (4,5) - qRegPair4_2b = (4,5) rRegPair4_2 = (4,5) reg3_3 = (3,5) bits3_3 = (3,5) @@ -76,8 +74,6 @@ attach variables [ reg0_3 reg3_3 ] [ B C D E H L _ A ]; attach variables [ sRegPair4_2 dRegPair4_2 ] [ BC DE HL SP ]; attach variables [ qRegPair4_2 ] [ BC DE HL AF ]; -attach variables [ qRegPair4_2a ] [ B D H A ]; -attach variables [ qRegPair4_2b ] [ C E L F ]; attach variables [ pRegPair4_2 ] [ BC DE IX SP ]; attach variables [ rRegPair4_2 ] [ BC DE IY SP ]; @@ -107,61 +103,61 @@ macro setResultFlags(result) { $(S_flag) = (result s< 0); } -macro additionFlags( operand1, operand2 ) { +macro additionFlags(operand1, operand2) { local AFmask = -1 >> 4; $(H_flag) = (((operand1 & AFmask) + (operand2 & AFmask)) & (AFmask + 1)) != 0; - $(PV_flag) = scarry( operand1, operand2 ); + $(PV_flag) = scarry(operand1, operand2); $(N_flag) = 0; - $(C_flag) = carry(operand1, operand2 ); + $(C_flag) = carry(operand1, operand2); } -macro additionFlagsNoPV( operand1, operand2 ) { +macro additionFlagsNoPV(operand1, operand2) { local AFmask = -1 >> 4; $(H_flag) = (((operand1 & AFmask) + (operand2 & AFmask)) & (AFmask + 1)) != 0; # $(PV_flag) is not affected $(N_flag) = 0; - $(C_flag) = carry(operand1, operand2 ); + $(C_flag) = carry(operand1, operand2); } -macro additionWithCarry( operand1, operand2, result ) { - local Ccopy = zext( $(C_flag) ); +macro additionWithCarry(operand1, operand2, result) { + local Ccopy = zext($(C_flag)); local AFmask = -1 >> 4; $(H_flag) = (((operand1 & AFmask) + (operand2 & AFmask) + Ccopy) & (AFmask + 1)) != 0; - $(PV_flag) = scarry( operand1, operand2 ); + $(PV_flag) = scarry(operand1, operand2); $(N_flag) = 0; - $(C_flag) = carry( operand1, operand2 ); + $(C_flag) = carry(operand1, operand2); local tempResult = operand1 + operand2; - $(C_flag) = $(C_flag) || carry( tempResult, Ccopy ); - $(PV_flag) = $(PV_flag) ^^ scarry( tempResult, Ccopy ); + $(C_flag) = $(C_flag) || carry(tempResult, Ccopy); + $(PV_flag) = $(PV_flag) ^^ scarry(tempResult, Ccopy); result = tempResult + Ccopy; } -macro subtractionFlags( operand1, operand2 ) { +macro subtractionFlags(operand1, operand2) { local AFmask = -1 >> 4; $(H_flag) = (((operand1 & AFmask) - (operand2 & AFmask)) & (AFmask + 1)) != 0; - $(PV_flag) = sborrow( operand1, operand2 ); + $(PV_flag) = sborrow(operand1, operand2); $(N_flag) = 1; $(C_flag) = operand1 < operand2; } -macro subtractionFlagsNoC( operand1, operand2 ) { +macro subtractionFlagsNoC(operand1, operand2) { local AFmask = -1 >> 4; $(H_flag) = (((operand1 & AFmask) - (operand2 & AFmask)) & (AFmask + 1)) != 0; - $(PV_flag) = sborrow( operand1, operand2 ); + $(PV_flag) = sborrow(operand1, operand2); $(N_flag) = 1; # $(C_flag) is not affected } -macro subtractionWithCarry( operand1, operand2, result ) { - local Ccopy = zext( $(C_flag) ); +macro subtractionWithCarry(operand1, operand2, result) { + local Ccopy = zext($(C_flag)); local AFmask = -1 >> 4; $(H_flag) = (((operand1 & AFmask) - (operand2 & AFmask) - Ccopy) & (AFmask + 1)) != 0; - $(PV_flag) = sborrow( operand1, operand2 ); + $(PV_flag) = sborrow(operand1, operand2); $(N_flag) = 1; $(C_flag) = operand1 < operand2; local tempResult = operand1 - operand2; $(C_flag) = $(C_flag) || (tempResult < Ccopy); - $(PV_flag) = $(PV_flag) ^^ sborrow( tempResult, Ccopy ); + $(PV_flag) = $(PV_flag) ^^ sborrow(tempResult, Ccopy); result = tempResult - Ccopy; } @@ -172,15 +168,11 @@ macro setSubtractFlags(op1,op2) { # places the parity bit of the given byte in out_parity_bit # the upper 7 bits of out_parity_bit are cleared macro setParity(in_byte) { - $(PV_flag) = - (((in_byte >> 7) & 1) ^ - ((in_byte >> 6) & 1) ^ - ((in_byte >> 5) & 1) ^ - ((in_byte >> 4) & 1) ^ - ((in_byte >> 3) & 1) ^ - ((in_byte >> 2) & 1) ^ - ((in_byte >> 1) & 1) ^ - (in_byte & 1)) == 0; + local tmp = in_byte ^ (in_byte >> 1); + tmp = tmp ^ (tmp >> 2); + tmp = (tmp ^ (tmp >> 4)) & 1; + $(PV_flag) = (tmp == 0); + # $(PV_flag) = hasEvenParity(in_byte); } @@ -530,9 +522,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } SP = IY; } -:PUSH qRegPair4_2 is op6_2=0x3 & qRegPair4_2 & qRegPair4_2a & qRegPair4_2b & bits0_4=0x5 { -# push8(qRegPair4_2b); -# push8(qRegPair4_2a); +:PUSH qRegPair4_2 is op6_2=0x3 & qRegPair4_2 & bits0_4=0x5 { push16(qRegPair4_2); } @@ -544,9 +534,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } push16(IY); } -:POP qRegPair4_2 is op6_2=0x3 & qRegPair4_2 & qRegPair4_2a & qRegPair4_2b & bits0_4=0x1 { -# pop8(qRegPair4_2a); -# pop8(qRegPair4_2b); +:POP qRegPair4_2 is op6_2=0x3 & qRegPair4_2 & bits0_4=0x1 { pop16(qRegPair4_2); } @@ -652,7 +640,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } BC = BC - 1; carries:1 = (~A & val) | (val & cmp) | (cmp & ~A); - $(H_flag) = ( carries & 0b00001000 ) != 0; + $(H_flag) = (carries & 0b00001000) != 0; $(PV_flag) = (BC != 0); $(N_flag) = 1; } @@ -668,7 +656,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } if (cmp == 0 || BC != 0) goto inst_start; carries:1 = (~A & val) | (val & cmp) | (cmp & ~A); - $(H_flag) = ( carries & 0b00001000 ) != 0; + $(H_flag) = (carries & 0b00001000) != 0; $(PV_flag) = (BC != 0); $(N_flag) = 1; } @@ -682,7 +670,7 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } BC = BC - 1; carries:1 = (~A & val) | (val & cmp) | (cmp & ~A); - $(H_flag) = ( carries & 0b00001000 ) != 0; + $(H_flag) = (carries & 0b00001000) != 0; $(PV_flag) = (BC != 0); $(N_flag) = 1; } @@ -698,25 +686,26 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } if (cmp == 0 || BC != 0) goto inst_start; carries:1 = (~A & val) | (val & cmp) | (cmp & ~A); - $(H_flag) = ( carries & 0b00001000 ) != 0; + $(H_flag) = (carries & 0b00001000) != 0; $(PV_flag) = (BC != 0); $(N_flag) = 1; } :ADD A, reg0_3 is op6_2=0x2 & bits3_3=0x0 & reg0_3 & A { local A_temp = A; + local reg_temp = reg0_3; A = A + reg0_3; - setResultFlags( A ); - additionFlags( A_temp, reg0_3 ); + setResultFlags(A); + additionFlags(A_temp, reg_temp); } :ADD A, imm8 is op0_8=0xc6; imm8 & A { local A_temp = A; A = A + imm8; - setResultFlags( A ); - additionFlags( A_temp, imm8 ); + setResultFlags(A); + additionFlags(A_temp, imm8); } :ADD A, (HL) is op0_8=0x86 & HL & A { @@ -725,8 +714,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } local A_temp = A; A = A + val; - setResultFlags( A ); - additionFlags( A_temp, val ); + setResultFlags(A); + additionFlags(A_temp, val); } :ADD A, ixMem8 is op0_8=0xdd; op0_8=0x86; ixMem8 & A { @@ -734,8 +723,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } local A_temp = A; A = A + val; - setResultFlags( A ); - additionFlags( A_temp, val ); + setResultFlags(A); + additionFlags(A_temp, val); } :ADD A, iyMem8 is op0_8=0xfd; op0_8=0x86; iyMem8 & A { @@ -743,52 +732,52 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } local A_temp = A; A = A + val; - setResultFlags( A ); - additionFlags( A_temp, val ); + setResultFlags(A); + additionFlags(A_temp, val); } :ADC A, reg0_3 is op6_2=0x2 & bits3_3=0x1 & reg0_3 & A { - additionWithCarry( A, reg0_3, A ); - setResultFlags( A ); + additionWithCarry(A, reg0_3, A); + setResultFlags(A); } :ADC A, imm8 is op0_8=0xce; imm8 & A { - additionWithCarry( A, imm8, A ); - setResultFlags( A ); + additionWithCarry(A, imm8, A); + setResultFlags(A); } :ADC A, (HL) is op0_8=0x8e & HL & A { val:1 = 0; MemRead(val,HL); - additionWithCarry( A, val, A ); - setResultFlags( A ); + additionWithCarry(A, val, A); + setResultFlags(A); } :ADC A, ixMem8 is op0_8=0xdd; op0_8=0x8e; ixMem8 & A{ val:1 = ixMem8; - additionWithCarry( A, val, A ); + additionWithCarry(A, val, A); } :ADC A, iyMem8 is op0_8=0xfd; op0_8=0x8e; iyMem8 & A { val:1 = iyMem8; - additionWithCarry( A, val, A ); - setResultFlags( A ); + additionWithCarry(A, val, A); + setResultFlags(A); } :SUB reg0_3 is op6_2=0x2 & bits3_3=0x2 & reg0_3 { local A_temp = A; A = A - reg0_3; - subtractionFlags( A_temp, reg0_3 ); - setResultFlags( A ); + subtractionFlags(A_temp, reg0_3); + setResultFlags(A); } :SUB imm8 is op0_8=0xd6; imm8 { local A_temp = A; A = A - imm8; - subtractionFlags( A_temp, imm8 ); - setResultFlags( A ); + subtractionFlags(A_temp, imm8); + setResultFlags(A); } :SUB (HL) is op0_8=0x96 & HL { @@ -797,8 +786,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } local A_temp = A; A = A - val; - subtractionFlags( A_temp, val ); - setResultFlags( A ); + subtractionFlags(A_temp, val); + setResultFlags(A); } :SUB ixMem8 is op0_8=0xdd; op0_8=0x96; ixMem8 { @@ -806,8 +795,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } local A_temp = A; A = A - val; - subtractionFlags( A_temp, val ); - setResultFlags( A ); + subtractionFlags(A_temp, val); + setResultFlags(A); } :SUB iyMem8 is op0_8=0xfd; op0_8=0x96; iyMem8 { @@ -815,37 +804,37 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } local A_temp = A; A = A - val; - subtractionFlags( A_temp, val ); - setResultFlags( A ); + subtractionFlags(A_temp, val); + setResultFlags(A); } :SBC A, reg0_3 is op6_2=0x2 & bits3_3=0x3 & reg0_3 & A { - subtractionWithCarry( A, reg0_3, A ); - setResultFlags( A ); + subtractionWithCarry(A, reg0_3, A); + setResultFlags(A); } :SBC A, imm8 is op0_8=0xde; imm8 & A { - subtractionWithCarry( A, imm8, A ); - setResultFlags( A ); + subtractionWithCarry(A, imm8, A); + setResultFlags(A); } :SBC A, (HL) is op0_8=0x9e & HL & A { val:1 = 0; MemRead(val,HL); - subtractionWithCarry( A, val, A ); - setResultFlags( A ); + subtractionWithCarry(A, val, A); + setResultFlags(A); } :SBC A, ixMem8 is op0_8=0xdd; op0_8=0x9e; ixMem8 & A { val:1 = ixMem8; - subtractionWithCarry( A, val, A ); - setResultFlags( A ); + subtractionWithCarry(A, val, A); + setResultFlags(A); } :SBC A, iyMem8 is op0_8=0xfd; op0_8=0x9e; iyMem8 & A { val:1 = iyMem8; - subtractionWithCarry( A, val, A ); - setResultFlags( A ); + subtractionWithCarry(A, val, A); + setResultFlags(A); } :AND reg0_3 is op6_2=0x2 & bits3_3=0x4 & reg0_3 { @@ -991,14 +980,14 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } :CP reg0_3 is op6_2=0x2 & bits3_3=0x7 & reg0_3 { cmp:1 = A - reg0_3; - subtractionFlags( A, reg0_3 ); - setResultFlags( cmp ); + subtractionFlags(A, reg0_3); + setResultFlags(cmp); } :CP imm8 is op0_8=0xfe; imm8 { cmp:1 = A - imm8; - subtractionFlags( A, imm8 ); - setResultFlags( cmp ); + subtractionFlags(A, imm8); + setResultFlags(cmp); } :CP (HL) is op0_8=0xbe & HL { @@ -1006,32 +995,32 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } MemRead(val,HL); cmp:1 = A - val; - subtractionFlags( A, val ); - setResultFlags( cmp ); + subtractionFlags(A, val); + setResultFlags(cmp); } :CP ixMem8 is op0_8=0xdd; op0_8=0xbe; ixMem8 { val:1 = ixMem8; cmp:1 = A - val; - subtractionFlags( A, val ); - setResultFlags( cmp ); + subtractionFlags(A, val); + setResultFlags(cmp); } :CP iyMem8 is op0_8=0xfd; op0_8=0xbe; iyMem8 { val:1 = iyMem8; cmp:1 = A - val; - subtractionFlags( A, val ); - setResultFlags( cmp ); + subtractionFlags(A, val); + setResultFlags(cmp); } :INC reg3_3 is op6_2=0x0 & reg3_3 & bits0_3=0x4 { local r_temp = reg3_3; reg3_3 = reg3_3 + 1; - setResultFlags( reg3_3 ); - additionFlags( r_temp, 1 ); + setResultFlags(reg3_3); + additionFlags(r_temp, 1); } :INC (HL) is op0_8=0x34 & HL { @@ -1041,8 +1030,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } val = val + 1; MemStore(HL,val); - setResultFlags( val ); - additionFlags( val_temp, 1 ); + setResultFlags(val); + additionFlags(val_temp, 1); } :INC ixMem8 is op0_8=0xdd; op0_8=0x34; ixMem8 { @@ -1051,8 +1040,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } val = val + 1; ixMem8 = val; - setResultFlags( val ); - additionFlags( val_temp, 1 ); + setResultFlags(val); + additionFlags(val_temp, 1); } :INC iyMem8 is op0_8=0xfd; op0_8=0x34; iyMem8 { @@ -1061,16 +1050,16 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } val = val + 1; iyMem8 = val; - setResultFlags( val ); - additionFlags( val_temp, 1 ); + setResultFlags(val); + additionFlags(val_temp, 1); } :DEC reg3_3 is op6_2=0x0 & reg3_3 & bits0_3=0x5 { local r_temp = reg3_3; reg3_3 = reg3_3 - 1; - subtractionFlagsNoC( r_temp, 1 ); - setResultFlags( reg3_3 ); + subtractionFlagsNoC(r_temp, 1); + setResultFlags(reg3_3); } :DEC (HL) is op0_8=0x35 & HL { @@ -1080,8 +1069,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } val = val - 1; MemStore(HL,val); - subtractionFlagsNoC( val_temp, 1 ); - setResultFlags( val ); + subtractionFlagsNoC(val_temp, 1); + setResultFlags(val); } :DEC ixMem8 is op0_8=0xdd; op0_8=0x35; ixMem8 { @@ -1090,8 +1079,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } val = val - 1; ixMem8 = val; - subtractionFlagsNoC( val_temp, 1 ); - setResultFlags( val ); + subtractionFlagsNoC(val_temp, 1); + setResultFlags(val); } :DEC iyMem8 is op0_8=0xfd; op0_8=0x35; iyMem8 { @@ -1100,8 +1089,8 @@ cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } val = val - 1; iyMem8 = val; - subtractionFlagsNoC( val_temp, 1 ); - setResultFlags( val ); + subtractionFlagsNoC(val_temp, 1); + setResultFlags(val); } :DAA is op0_8=0x27 { @@ -1113,19 +1102,19 @@ if (DECOMPILE_MODE) goto ; # If (C and H are both 0, and both nibbles are in range[0,9] no # adjustment is needed. # - if ( ($(C_flag) == 0) & ($(H_flag) == 0) & (HN <= 0x9) & (LN <= 0x9) ) goto ; + if (($(C_flag) == 0) & ($(H_flag) == 0) & (HN <= 0x9) & (LN <= 0x9)) goto ; - if ( $(N_flag) == 1 ) goto ; + if ($(N_flag) == 1) goto ; #, in effect - if ( $(C_flag) == 0 & $(H_flag) == 0 & HN <= 0x8 & LN >= 0xA & LN <= 0xF ) goto ; - if ( $(C_flag) == 0 & $(H_flag) == 1 & HN <= 0x9 & LN <= 0x3 ) goto ; - if ( $(C_flag) == 0 & $(H_flag) == 0 & HN >= 0xA & HN <= 0xF & LN <= 0x9 ) goto ; - if ( $(C_flag) == 0 & $(H_flag) == 0 & HN >= 0x9 & HN <= 0xF & LN >= 0xA & LN <= 0xF ) goto ; - if ( $(C_flag) == 0 & $(H_flag) == 1 & HN >= 0xA & HN <= 0xF & LN <= 0x3 ) goto ; - if ( $(C_flag) == 1 & $(H_flag) == 0 & HN <= 0x2 & LN <= 0x9 ) goto ; - if ( $(C_flag) == 1 & $(H_flag) == 0 & HN <= 0x2 & LN >= 0xA & LN <= 0xF ) goto ; - if ( $(C_flag) == 1 & $(H_flag) == 1 & HN <= 0x3 & LN <= 0x3 ) goto ; + if ($(C_flag) == 0 & $(H_flag) == 0 & HN <= 0x8 & LN >= 0xA & LN <= 0xF) goto ; + if ($(C_flag) == 0 & $(H_flag) == 1 & HN <= 0x9 & LN <= 0x3) goto ; + if ($(C_flag) == 0 & $(H_flag) == 0 & HN >= 0xA & HN <= 0xF & LN <= 0x9) goto ; + if ($(C_flag) == 0 & $(H_flag) == 0 & HN >= 0x9 & HN <= 0xF & LN >= 0xA & LN <= 0xF) goto ; + if ($(C_flag) == 0 & $(H_flag) == 1 & HN >= 0xA & HN <= 0xF & LN <= 0x3) goto ; + if ($(C_flag) == 1 & $(H_flag) == 0 & HN <= 0x2 & LN <= 0x9) goto ; + if ($(C_flag) == 1 & $(H_flag) == 0 & HN <= 0x2 & LN >= 0xA & LN <= 0xF) goto ; + if ($(C_flag) == 1 & $(H_flag) == 1 & HN <= 0x3 & LN <= 0x3) goto ; goto ; # Cases for addition @@ -1161,10 +1150,10 @@ if (DECOMPILE_MODE) goto ; # Cases for subtraction - #if ( $(C_flag) == 0 & $(H_flag) == 0 & HN >= 0x0 & HN <= 0x9 & LN >= 0x0 & LN <= 0x9 ) goto ; - if ( $(C_flag) == 0 & $(H_flag) == 1 & HN <= 0x8 & LN >= 0x6 & LN <= 0xF ) goto ; - if ( $(C_flag) == 1 & $(H_flag) == 0 & HN >= 0x7 & HN <= 0xF & LN <= 0x9 ) goto ; - if ( $(C_flag) == 1 & $(H_flag) == 1 & HN >= 0x6 & HN <= 0xF & LN >= 0x6 & LN <= 0xF ) goto ; + #if ($(C_flag) == 0 & $(H_flag) == 0 & HN >= 0x0 & HN <= 0x9 & LN >= 0x0 & LN <= 0x9) goto ; + if ($(C_flag) == 0 & $(H_flag) == 1 & HN <= 0x8 & LN >= 0x6 & LN <= 0xF) goto ; + if ($(C_flag) == 1 & $(H_flag) == 0 & HN >= 0x7 & HN <= 0xF & LN <= 0x9) goto ; + if ($(C_flag) == 1 & $(H_flag) == 1 & HN >= 0x6 & HN <= 0xF & LN >= 0x6 & LN <= 0xF) goto ; goto ; # @@ -1189,8 +1178,8 @@ if (DECOMPILE_MODE) goto ; A_temp:1 = A; - A = BCDadjust( A_temp, $(C_flag), $(H_flag) ); - $(C_flag) = BCDadjustCarry( A_temp, $(C_flag), $(H_flag) ); + A = BCDadjust(A_temp, $(C_flag), $(H_flag)); + $(C_flag) = BCDadjustCarry(A_temp, $(C_flag), $(H_flag)); setResultFlags(A); $(PV_flag) = hasEvenParity(A); @@ -1208,8 +1197,8 @@ if (DECOMPILE_MODE) goto ; A_temp:1 = A; A = -A; - subtractionFlags( 0, A_temp ); - setResultFlags( A ); + subtractionFlags(0, A_temp); + setResultFlags(A); } :CCF is op0_8=0x3f { @@ -1256,36 +1245,40 @@ if (DECOMPILE_MODE) goto ; :ADD HL,sRegPair4_2 is op6_2=0x0 & sRegPair4_2 & bits0_4=0x9 & HL { local HL_temp = HL; + local Reg_temp = sRegPair4_2; HL = HL + sRegPair4_2; - additionFlagsNoPV( HL_temp, sRegPair4_2 ); + additionFlagsNoPV(HL_temp, Reg_temp); } :ADC HL,sRegPair4_2 is op0_8=0xed & HL; op6_2=0x1 & sRegPair4_2 & bits0_4=0xa { local HL_temp = HL; + local Reg_temp = sRegPair4_2; HL = HL + sRegPair4_2 + zext($(C_flag)); - setResultFlags( HL ); - additionFlags( HL_temp, sRegPair4_2 ); + setResultFlags(HL); + additionFlagsNoPV(HL_temp, Reg_temp); } :SBC HL,sRegPair4_2 is op0_8=0xed & HL; op6_2=0x1 & sRegPair4_2 & bits0_4=0x2 { - subtractionWithCarry( HL, sRegPair4_2, HL ); - setResultFlags( HL ); + subtractionWithCarry(HL, sRegPair4_2, HL); + setResultFlags(HL); } :ADD IX,pRegPair4_2 is op0_8=0xdd & IX; op6_2=0x0 & pRegPair4_2 & bits0_4=0x9 { local IX_temp = IX; + local Reg_temp = pRegPair4_2; IX = IX + pRegPair4_2; - additionFlagsNoPV( IX_temp, pRegPair4_2 ); + additionFlagsNoPV(IX_temp, Reg_temp); } :ADD IY,pRegPair4_2 is op0_8=0xfd & IY; op6_2=0x0 & pRegPair4_2 & bits0_4=0x9 { local IY_temp = IY; + local Reg_temp = pRegPair4_2; IY = IY + pRegPair4_2; - additionFlagsNoPV( IY_temp, pRegPair4_2 ); + additionFlagsNoPV(IY_temp, Reg_temp); } :INC sRegPair4_2 is op6_2=0x0 & sRegPair4_2 & bits0_4=0x3 {