Subject: Re: [stella] BIT and... AND From: Eckhard_Stolberg@xxxxxxxxxxxxxxxxxxxxx (Eckhard Stolberg) Date: Tue, 22 Jul 1997 15:07:37 +0200 |
>I remember that it can be used to test bit 7 and 6 without touching the >accumulator content (this can be useful), and that it sets the zero flag >according to the result of the logical AND between the accumulator and the >memory. >This last thing is less clear to me, I mean are these things the same...: > > LDA #mask > BIT memory > BEQ ... (BNE ...) > >or > > LDA memory > AND #mask > BEQ ... (BNE ...) > >How should I choose between the two solutions? The BIT command is basicly the same as the AND command. There are only two differences. First the BIT command doesn't change the content of the accu. And second the BIT command only supports absolute and zeropage addressing, while AND supports all addressing modes. The flags are set the same with both commands. Both of the above examples are identical in memory and processor usage, so whitch to choose depends on the context. If you have the value already in the accu, because you just calculated it or if you need the ANDed value after the branch, you should use the AND version. If you have to check several memory locations in a row for the same bit to be set, than the BIT version is faster, because you have the mask already loaded. This could be usefull in collision detection, for example. Also you could store the masks in memory (or zeropage RAM if possible), load the value in the accu and BIT it with the masks. This is usefull for joystick checking, because you don't have to reload SWCHA for every direction you want to check. Ciao, Eckhard Stolberg -- Archives updated once/day at http://www.biglist.com/lists/stella/archives/ Unsubscribing and other info at http://www.biglist.com/lists/stella/stella.html
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[stella] BIT and... AND, Piero Cavina | Thread | [stella] Missle/War Graphics, ScottMSO |
[stella] BIT and... AND, Piero Cavina | Date | [stella] Missle/War Graphics, ScottMSO |
Month |