nurpax / c64jasm

C64 6502 assembler in TypeScript
51 stars 14 forks source link

[improvement] Support cycle count estimation in disassembly #72

Closed shazz closed 3 years ago

shazz commented 4 years ago

It would be great if in the disassembly, an estimation of the cycles consumed could be added.

A little like in the Stella disassembly:

image

Some existing js 6502 simulator source code:

I'll try to test them to see how good they are

shazz commented 4 years ago

I did a little prototype using https://github.com/afeique/MOS6502.js Easy to integrate, there is only 2 callbacks to add to the disassembler:

// This function should return the byte at the specified memory address.
mem_read(address);

// This function should write the specified byte to the specified address.
mem_write(address, value);

then calling run_instruction() on the simulator will execute on instruction and give the number of cycles consumed.

But I had some issue to map the address read by the simulator and the disassembler byte buffer (this.buf).

So finally I only used timing per opcode table.

nurpax commented 3 years ago

This could be closed -- @shazz's code is merged. But thinking about this: perhaps disasm should show conditional cycles like in the above screenshot for the bne instructions (2 if branch not taken, 3 if taken)?

shazz commented 3 years ago

Maybe just add 2/3 is enough

nurpax commented 3 years ago

Yeah, that's what I intended.

I'll do this.

nurpax commented 3 years ago

done in ebde48104a73421e7b65a83b4795a842938e22d3

it's possible to be slightly more precise with the cycle counts. it's possible to check for page crossing when disassembling branches -- I'm going to fix this too at some point. Not today though.

nurpax commented 3 years ago

all done here 478e07bec06e2f2525cd252d6203f1b5bb8d4864