You ve got is right. You have to use a loop. What you can do to make it take longer is to add NOP
operations.
652年的时间安排非常具体。 假设你没有超速的现代版本,你可以非常准确。 预计这些指示将确切使用其指定时间。 例如,<代码>DEX + BNE 休息时间为6个周期,最后步骤为5个(如果不进行,分行时间为1个较宽的周期),而分行时间为1个多周期,目的地为单独的一页,常设仲裁法院高分位数则增减。
So now you need to find a document with the CPU instructions and the number of cycles each take.
如果你有24小时,你可以读一下你的锁,并利用这一价值知道你何时做。 否则,6502年就没有违约。 它必须是某种类型的I/O。
Cycles
LDA #60
STA $0000
Loop:
DEC $0000 6
BEQ TimerDone 2 (3 when $0000=0)
DelayLoop:
LDX #$00 2
InnerLoop:
LDY #$00 2
InnerInnerLoop:
DEY 2
BNE InnerInnerLoop 3 (2 when Y=0)
DEX 2
BNE InnerLoop 3 (2 when X=0)
JMP Loop 3
TimerDone:
So, the InnerInnerLoop
takes (2 + 3) × 255 + 2 + 2 (last time branch is not taken so 1 less cycle) = 1,284 cycles
As a result the InnerLoop
does (2 + 1,284 + 2 + 3) × 255 + (2 + 1,284 + 2 + 2) = 330,495 cycles.
最后,<代码>Loop (6 + 2 + 330,495 + 3) × 601 + 1 = 19,830,361的周期。
If you have a 6502 that runs at 1MHz, then that loop would take about 19.8 seconds. If it runs at 5Mhz, then it will take 19.8 ÷ 5 ≈ 3.97 seconds.
页: 1 如Nick Westgate在一份评论中所说,如果书面文件将产生59个频率。 相反,你可以(1) 移动<条码>。 <代码>JMP以JMP
替换为BNE
;或(2)使用LDA #61
,以获得60个版本。
Note: a while back, I created an Apple II simulator that runs on x86/amd64 computers. My main problem was the clock. I did not work on that part. So it goes dead fast compared to the good old Apple II. So hopefully you run your code on real hardware. Otherwise, your pause will work only if the emulator properly emulates the duration of a cycle.