sim65 is part of the cc65 suite that can simulate a 6502 (or 65C02). It can also print the number of cycles executed before a jmp exit.
Contrary to the documentation (at least with version 2.16-2), it seems to require no header other than a single $00 byte and loads to and begins execution from $0200 automatically.
ca65 --cpu 6502 main.S -o main.o cl65 --target sim6502 -Ln /tmp/sim65asm.lbl -o /tmp/sim65asm.bin main.o sim65 -c /tmp/sim65asm.bin 2 cycles
main.S in this example was:
.autoimport ; The STARTUP segment MUST be defined .segment "STARTUP" .code main: lda #0 jmp exit .export main
There may be mistakes and misinformation below.
A (lo) and X (hi) for the last parameter$00 (lo) and $01 (hi)$FFE8 then pushax leaves it at $FFE6 with AX written to $FFE6 (lo) and $FFE7 (hi)pvwrite (uint16_t fd, uint8_t *buf, uint16_t nbytes) accessed as jsr fff5