[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: killing time in 6502 assembly
On Sun, 07 Feb 1999 16:44:11 +0500, joker21@earthlink.net wrote:
> I'd never thought I'd say this, but the Nes is too fast!
> I'm trying to kill about 3/4 of a second. I've come up with this:
> [long string of nops]
> This just loops about 255*3 then comes back. Is there an opcode better
> that nop? Or a whole better why to do it?
Um, there is a better way. The following will take about 750000 cycles.
Fine-tuning the initial values of X and Y is left as an exercice for the
reader.
LDY #$AC
LDX #0
.1 JSR .2
DEX
BNE .1
DEY
BNE .1
.2 RTS
Challenge: can you come up with a shorter routine that waits for about
3/4 of a second?
It could be interesting to try to come up with 6502 "busy beavers".
A busy beaver is a program that eventually terminates (in other words,
it doesn't enter an infinite loop). The idea is to come up with the
program of length N that works for the longest time before terminating.
To preserve the theoretical flavor of the problem, assume 64k of RAM
and no ROM routines to call.
[Crossposted to comp.sys.apple2 and comp.sys.cbm, where 6502 coders live.]
Paul Guertin
pg@sff.net