|
Subject: [stella] flogging a dead horse? From: "Andrew Davie" <adavie@xxxxxxxxxxxxxxxxx> Date: Fri, 8 May 1998 16:47:02 +1000 |
I dunno if this has been beaten to death already (ie: am I flogging a dead
horse?), but further tips for budding 6502 programmers... When adding a
byte to a word, rather than this...
clc
lda lowbyte
adc value
sta lowbyte
lda highbyte
adc #0
sta highbyte
(the above takes 13 bytes and 19 cycles) it is better to do something like
this...
clc
lda lowbyte
adc value
sta lowbyte
bcc nocarry
inc highbyte
nocarry
The above takes 11 bytes and either 14 cycles when there's no overflow of
the first addition, and 16 cycles when there is a carry. Futhermore, when
doing a series of the above, place a clc just before the nocarry label and
you have your carry guaranteed clear already, for the next addition, saving
a further two cycles on the next one (in the case of no branch).
Should I bother with these tips from the past, or... should I let ol' noggin
rest in peace?
Cheers
A
Oh, and cycle counts may vary with age. I'm doing all this from memory - I
think a branch not taken is 2 cycles, but I may be wrong. Its a good idea,
too, to ensure that code with branches does not cross page boundaries -
that's another cycle penalty.
--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/stella.html
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [stella] Paddle support for my , kurt.woloch | Thread | Re: [stella] flogging a dead horse?, Eckhard Stolberg |
| [stella] Supercharger internals..., bwmott | Date | Re: [stella] Supercharger internals, kurt.woloch |
| Month |