Are you a speed freak? Are you aware of, or have you written some blinding fast and clever routine?
Here's some examples:
Calculate 8 bit Julia iteration (involving complex numbers) in just *14 cycles*. Set by Chris Jam, of C64 "finely-sliced demo PAL" fame. Then he beat his own record by 2 cycles, by rederiving the formula, without cheating (such as removing a 2 cycle CLC).
The 40 cycle 8 bit unsigned multiply which any self respecting hardcoder has reinvented. But have you made the 44 cycle worst case version, as fast as 12 cycles, and an average in the 30's? Hint: use a jmp table...
How about the 190 cycle 16 bit unsigned multiply? Hint: just like the 8 bit, but done in optimal arrangement.
Finally, how about a 105 cycle 16/8 unsigned divide? Divide is proven to be slightly harder than multiply. Can you beat it in full (err...) accuracy?
See the routine below. Of course, using log tables you can make this quite fast, and same with log, exp, sqr, sin and other functions...
8 bit unsigned divide
ldx #8
lda dividend
div cmp divisor
bcs s
sbc divisor
s rol quotient
rol
dex
bne div
timing in cycles:
overhead 5
"0" bit 20
"1" bit 18
range 148 to 164
average 156
unrolled, with dividend in A register, and last iteration optimized: 105
average of 14 cycles per bit.
dividend, quotient, and divisor are 8 bit values stored in zero page.
The remainder is left in A.
note: dividend/divisor must be < 2. So this is not a fully general
routine. To handle the full range, you must do a prefix of the dividend
to reduce it to the right range, then fix the quotient after. This is
true of any shift and subtract divide. True divides are much slower.
There are two faster routines I have written, but this is the fastest
algorithmic version. A faster version uses decision tree optimization and
requires over 256 bytes of code (about 56 cycles). The fastest version requires tables
which I cannot calculate without a computer.
I mean, I cannot even easily specify how to find them, since it is not a
formula.
_________________ c128,2xc64/64cycle/65cycleVIC,2x1541/8k,1571,1581
|