correct branch cycle counting

This commit is contained in:
Aaron Culliney 2014-02-22 14:00:56 -08:00
parent 07740bbb66
commit d481d59851

View File

@ -146,11 +146,13 @@
incb DebugCycleCount; /* +1 branch taken */ \ incb DebugCycleCount; /* +1 branch taken */ \
pushl %ebx; \ pushl %ebx; \
movw PC_Reg, %bx; \ movw PC_Reg, %bx; \
addb %al, %bl; \ cbw; \
jnc 9f; \ addw %bx, %ax; \
incb DebugCycleCount; /* +1 branch across pg boundary */ \ movw %ax, PC_Reg; \
9: addw %ax, PC_Reg; \ cmpb %ah, %bh; \
popl %ebx; je 9f; \
incb DebugCycleCount; /* +1 branch new page */ \
9: popl %ebx;
#define FlagC lahf; \ #define FlagC lahf; \
andb $C_Flag, %ah; \ andb $C_Flag, %ah; \
@ -747,7 +749,6 @@ op_BCC:
GetFromPC_B GetFromPC_B
testb $C_Flag, F_Reg testb $C_Flag, F_Reg
jnz op_BCC_not // branch not taken jnz op_BCC_not // branch not taken
cbw
BranchXCycles BranchXCycles
op_BCC_not: op_BCC_not:
Continue Continue
@ -761,7 +762,6 @@ op_BCS:
GetFromPC_B GetFromPC_B
testb $C_Flag, F_Reg testb $C_Flag, F_Reg
jz op_BCS_not // branch not taken jz op_BCS_not // branch not taken
cbw
BranchXCycles BranchXCycles
op_BCS_not: op_BCS_not:
Continue Continue
@ -775,7 +775,6 @@ op_BEQ:
GetFromPC_B GetFromPC_B
testb $Z_Flag, F_Reg testb $Z_Flag, F_Reg
jz op_BEQ_not // branch not taken jz op_BEQ_not // branch not taken
cbw
BranchXCycles BranchXCycles
op_BEQ_not: op_BEQ_not:
Continue Continue
@ -828,7 +827,6 @@ op_BMI:
testb F_Reg, F_Reg /* optimized check of N flag, testb F_Reg, F_Reg /* optimized check of N flag,
* which happens to be sign bit */ * which happens to be sign bit */
jns op_BMI_not jns op_BMI_not
cbw
BranchXCycles BranchXCycles
op_BMI_not: op_BMI_not:
Continue Continue
@ -842,7 +840,6 @@ op_BNE:
GetFromPC_B GetFromPC_B
testb $Z_Flag, F_Reg testb $Z_Flag, F_Reg
jnz op_BNE_not jnz op_BNE_not
cbw
BranchXCycles BranchXCycles
op_BNE_not: op_BNE_not:
Continue Continue
@ -857,7 +854,6 @@ op_BPL:
testb F_Reg, F_Reg /* optimized check of N flag, testb F_Reg, F_Reg /* optimized check of N flag,
* which happens to be sign bit */ * which happens to be sign bit */
js op_BPL_not js op_BPL_not
cbw
BranchXCycles BranchXCycles
op_BPL_not: op_BPL_not:
Continue Continue
@ -870,7 +866,6 @@ op_BPL_not:
// 65c02 : 0x80 // 65c02 : 0x80
op_BRA: op_BRA:
GetFromPC_B GetFromPC_B
cbw
BranchXCycles BranchXCycles
Continue Continue
@ -904,7 +899,6 @@ op_BVC:
GetFromPC_B GetFromPC_B
testb $V_Flag, F_Reg testb $V_Flag, F_Reg
jnz op_BVC_not jnz op_BVC_not
cbw
BranchXCycles BranchXCycles
op_BVC_not: op_BVC_not:
Continue Continue
@ -918,7 +912,6 @@ op_BVS:
GetFromPC_B GetFromPC_B
testb $V_Flag, F_Reg testb $V_Flag, F_Reg
jz op_BVS_not jz op_BVS_not
cbw
BranchXCycles BranchXCycles
op_BVS_not: op_BVS_not:
Continue Continue