Thread: Bits set
View Single Post
Old 30 April 2021, 09:54   #3
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
For your first example, you can just have these two bits in same byte.
And instead of having to check if these are both set, compare them with 0 by reversing their meaning :
Code:
 tst.b obj_state(ax)
 bne .exit
Generally, it's easier to check for 0 than check for 1 so reverse them where you can.

If you only have 2 bits and not all possible combinations need to be checked, you can use the following method (use sign bit and any other like b0, keeping all other bits =0) :
Code:
 tst.b obj_state(ax)
 bne .xx         ; $01, $80, $81
 beq .xx         ; $00
 bpl .xx         ; $00, $01
 bmi .xx         ; $80, $81
 bgt .xx         ; $01
 ble .xx         ; $00, $80

Quote:
Originally Posted by Auscoder View Post
I need all 32 bits and the code is a little bit generic so using longs.
That may be a big part of the problem...
meynaf is offline  
 
Page generated in 0.05825 seconds with 11 queries