changeset 408:0af33282b518

Fix cycle counting for relative branches. The original creator of the cycle counting code appears to have mangled two different approaches to counting the cycles for relative branches into the final product which led to counting too many cycles for the branch instructions. The comments in the cycle table were correct but the code was doing some incorrect things. Also add the missing LBRN entry to the cycle table. The one labelled LBRN was not, in fact, LBRN, but one of the actual useful branch instructions.
author William Astle <lost@l-w.ca>
date Thu, 03 Mar 2016 21:38:21 -0700
parents c501b3ce39c8
children c8ae69cdb5a9
files lwasm/cycle.c lwasm/insn_rel.c
diffstat 2 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/cycle.c	Thu Mar 03 21:17:48 2016 -0700
+++ b/lwasm/cycle.c	Thu Mar 03 21:38:21 2016 -0700
@@ -305,20 +305,21 @@
 
 	{ 0x16, 5, 4, 0 },					// LBRA
 	{ 0x17, 9, 7, 0 },					// LBSR
-	{ 0x1022, 5, 5, 0 },				// LBRN
-	{ 0x1023, 5, 6, 0 },				// remaining long branches are estimated on 6809 only:
-	{ 0x1024, 5, 6, 0 },				// 6809: 5 cycles, +1 cycle if the branch is taken
-	{ 0x1025, 5, 6, 0 },				// 6309 native: always 5 cycles
-	{ 0x1026, 5, 6, 0 },		
-	{ 0x1027, 5, 6, 0 },
-	{ 0x1028, 5, 6, 0 },		
-	{ 0x1029, 5, 6, 0 },		
-	{ 0x102a, 5, 6, 0 },
-	{ 0x102b, 5, 6, 0 },
-	{ 0x102c, 5, 6, 0 },
-	{ 0x102d, 5, 6, 0 },
-	{ 0x102e, 5, 6, 0 },
-	{ 0x102f, 5, 6, 0 },
+	{ 0x1021, 5, 5, 0 },				// LBRN
+	{ 0x1022, 5, 5, 0 },				// remaining long branches are estimated on 6809 only:
+	{ 0x1023, 5, 5, 0 },				//
+	{ 0x1024, 5, 5, 0 },				// 6809: 5 cycles, +1 cycle if the branch is taken
+	{ 0x1025, 5, 5, 0 },				// 6309 native: always 5 cycles
+	{ 0x1026, 5, 5, 0 },				//
+	{ 0x1027, 5, 5, 0 },				// this is handled as a special case elsewhere
+	{ 0x1028, 5, 5, 0 },		
+	{ 0x1029, 5, 5, 0 },		
+	{ 0x102a, 5, 5, 0 },
+	{ 0x102b, 5, 5, 0 },
+	{ 0x102c, 5, 5, 0 },
+	{ 0x102d, 5, 5, 0 },
+	{ 0x102e, 5, 5, 0 },
+	{ 0x102f, 5, 5, 0 },
 
 	{ 0x86, 2, 2, 0 },					// LDA
 	{ 0x96, 4, 3, 0 },
--- a/lwasm/insn_rel.c	Thu Mar 03 21:17:48 2016 -0700
+++ b/lwasm/insn_rel.c	Thu Mar 03 21:38:21 2016 -0700
@@ -308,7 +308,6 @@
 		{
 			lwasm_emitop(l, instab[l->insn].ops[2]);
 			lwasm_emit(l, offs);
-			l->cycle_adj = 2;
 		}
 	}
 	else
@@ -316,6 +315,5 @@
 		lwasm_emitop(l, instab[l -> insn].ops[3]);
 		lwasm_emitexpr(l, e, 2);
 
-		l->cycle_adj = 4;
 	}
 }