comparison lwasm/cycle.c @ 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 4c8925f97eb5
children b9917c4dc6cf
comparison
equal deleted inserted replaced
407:c501b3ce39c8 408:0af33282b518
303 { 0xad, 7, 6, CYCLE_ADJ }, 303 { 0xad, 7, 6, CYCLE_ADJ },
304 { 0xbd, 8, 7, 0 }, 304 { 0xbd, 8, 7, 0 },
305 305
306 { 0x16, 5, 4, 0 }, // LBRA 306 { 0x16, 5, 4, 0 }, // LBRA
307 { 0x17, 9, 7, 0 }, // LBSR 307 { 0x17, 9, 7, 0 }, // LBSR
308 { 0x1022, 5, 5, 0 }, // LBRN 308 { 0x1021, 5, 5, 0 }, // LBRN
309 { 0x1023, 5, 6, 0 }, // remaining long branches are estimated on 6809 only: 309 { 0x1022, 5, 5, 0 }, // remaining long branches are estimated on 6809 only:
310 { 0x1024, 5, 6, 0 }, // 6809: 5 cycles, +1 cycle if the branch is taken 310 { 0x1023, 5, 5, 0 }, //
311 { 0x1025, 5, 6, 0 }, // 6309 native: always 5 cycles 311 { 0x1024, 5, 5, 0 }, // 6809: 5 cycles, +1 cycle if the branch is taken
312 { 0x1026, 5, 6, 0 }, 312 { 0x1025, 5, 5, 0 }, // 6309 native: always 5 cycles
313 { 0x1027, 5, 6, 0 }, 313 { 0x1026, 5, 5, 0 }, //
314 { 0x1028, 5, 6, 0 }, 314 { 0x1027, 5, 5, 0 }, // this is handled as a special case elsewhere
315 { 0x1029, 5, 6, 0 }, 315 { 0x1028, 5, 5, 0 },
316 { 0x102a, 5, 6, 0 }, 316 { 0x1029, 5, 5, 0 },
317 { 0x102b, 5, 6, 0 }, 317 { 0x102a, 5, 5, 0 },
318 { 0x102c, 5, 6, 0 }, 318 { 0x102b, 5, 5, 0 },
319 { 0x102d, 5, 6, 0 }, 319 { 0x102c, 5, 5, 0 },
320 { 0x102e, 5, 6, 0 }, 320 { 0x102d, 5, 5, 0 },
321 { 0x102f, 5, 6, 0 }, 321 { 0x102e, 5, 5, 0 },
322 { 0x102f, 5, 5, 0 },
322 323
323 { 0x86, 2, 2, 0 }, // LDA 324 { 0x86, 2, 2, 0 }, // LDA
324 { 0x96, 4, 3, 0 }, 325 { 0x96, 4, 3, 0 },
325 { 0xa6, 4, 4, CYCLE_ADJ }, 326 { 0xa6, 4, 4, CYCLE_ADJ },
326 { 0xb6, 5, 4, 0 }, 327 { 0xb6, 5, 4, 0 },