changeset 482:9c24336fa76c

Correct cycle counts for W relative indexing modes Actually handle the 6309 specific W relative indexing modes (,W; n,W; ,W++; ,--W) in the cycle count calculation code. These work differently than the regular indexing modes so it's necessary to handle their bit patterns specially. (The bits that would normally select the base register are used instead to select the operation on W.)
author William Astle <lost@l-w.ca>
date Thu, 24 Jan 2019 18:24:03 -0700
parents 62720ac9e28d
children 40c32a0af8c8
files lwasm/cycle.c
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/cycle.c	Wed Dec 12 21:18:20 2018 -0700
+++ b/lwasm/cycle.c	Thu Jan 24 18:24:03 2019 -0700
@@ -624,6 +624,28 @@
 	if ((pb & 0x80) == 0) /* 5 bit offset */
 		return 1;
 
+	// These need special handling because the *register* bits determine the specific operation (and, thus, cycle counts)
+	if (!CURPRAGMA(cl, PRAGMA_6809))
+	{
+		switch (pb)
+		{
+		case 0x8f:  // ,W
+			return 0;
+		case 0xaf:  // n,W (16 bit)
+			return 2;
+		case 0xcf:  // ,W++
+		case 0xef:  // ,--W
+			return 1;
+		case 0x90:  // [,W]
+			return 3;
+		case 0xb0: // [n,W] (16 bit)
+			return 5;
+		case 0xd0: // [,W++]
+		case 0xf0: // [,--W]
+			return 4;
+		}
+	}
+
 	if (pb & 0x10) /* indirect */
 		return CURPRAGMA(cl, PRAGMA_6809) ? indtab[pb & 0xf].cycles_6809_indirect : indtab[pb & 0xf].cycles_6309_indirect;
 	else