With the M2 series I notice the absence of setbit, clearbit and togglebit, can't find testbit, maybe that's - bitx ?
I cannot understand this because it seems a basic requirement. I am playing with some SFR's and the following code works, but it seems quite inefficient. So my question, is there a better way to set, clear and test bits in the SFR (and other locations, variables etc for that matter)
I cannot understand this because it seems a basic requirement. I am playing with some SFR's and the following code works, but it seems quite inefficient. So my question, is there a better way to set, clear and test bits in the SFR (and other locations, variables etc for that matter)
Code:
; just playing with OSCTUNE variable which has a hypothetical bit 3 called TXEN
symbol OSCTUNE = $9b ' declare the SFR address
symbol OSCTUNE.TXEN = $08 ' declare the SFR bit name at position bit3
pokesfr OSCTUNE,$08 ' preset bit 3
peeksfr OSCTUNE,b0 : b0=bit3 ' this to test bit 3's status
pokesfr OSCTUNE,$FF ' preset to all 1's
peeksfr OSCTUNE,b0 : b0=b0 AndNot OSCTUNE.TXEN : pokesfr OSCTUNE,b0 ' this to clear the SFR's bit 3
pokesfr OSCTUNE,$00 ' preset to all 0's
peeksfr OSCTUNE,b0 : b0=b0 Or OSCTUNE.TXEN : pokesfr OSCTUNE,b0 ' this to set the SFR's bit 3
Last edited: