Subject: Re: [stella] Newbie: Efficiency in Code, Joystick Routine as Example From: "Andrew Davie" <adavie@xxxxxxxxxxx> Date: Mon, 15 Jul 2002 08:36:09 +1000 |
> Not necessary, everything looks fine! :-) The statement that "has to compare a whole byte for each possibility, while the second routine compares 1 bit. That's 8 times more efficient (I think). " is in error. Comparing a byte against comparing a bit is not 8 times less efficient. In fact, it really depends how you do things, and what you want to do. Sometimes comparing a bit is less efficient. Depends which bit, and if you can modify A, for example. Or if the byte is in memory or a register. For example, if I wanted to check to see if bit 4 was set in A, without destroying A...... how do I do that? I can't... directly. There's no BIT # instruction. So I have to save the value somewhere, bit it, and restore it sta temp ; save A lda #16 ; the bit we want to check bit temp ; check the bit lda temp ; restore That's ugly. We could shift... asl asl asl bmi itsset that's ugly too. Besides, we've destroyed A - against spec - so we'd need to save/restore it The point being, it's not always easier to check a bit than to check a byte. Checking a byte is typically... cmp #value beq thesame > BTW: You can save one more byte (the first ASL) if you use BPL > instead of BCC. If up dropped the first ASL, then ALL of the BCC lines should then be changed to BPL (just clarifying the above). Cheers A ---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Newbie: Efficiency in , Thomas Jentzsch | Thread | Re: [stella] Newbie: Efficiency in , Bill Heineman |
Re: [stella] Newbie: Efficiency in , Thomas Jentzsch | Date | Re: [stella] Newbie: Efficiency in , Erik Mooney |
Month |