sim65

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

Writing to stdout

There may be mistakes and misinformation below.