# HG changeset patch # User William Astle # Date 1548379443 25200 # Node ID 9c24336fa76c1211f8938c313f33f22defe1a761 # Parent 62720ac9e28db362d3a23ed85e58f2fa955bca6c 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.) diff -r 62720ac9e28d -r 9c24336fa76c lwasm/cycle.c --- 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