Hi, Brian:
In assembler, you sonetimes need the bit-number and you sometimes need a bit-mask. So I always define both. Here is an example from one of my source files:
;
; Definitions of Host-Bus Control and Status registers in the FPGA.
;
;
ELMO: equ $8 ;Control and Status register for Motor Amplifier and DSP
;
;
; The ELMO and DSP status register bit definitions:
;
DSPtio: equ 7 ;ELMO status: DSP Timer TIO status bit
DSPlock: equ 6 ;ELMO status: DSP PLL LOCK status bit
DSPhack: equ 5 ;ELMO status: DSP Host Acknowledge (~HACK)
DSPhreq: equ 4 ;ELMO status: DSP Host Request (~HREQ)
ElmoAOK: equ 3 ;ELMO status: amplifier status bit AOK
ElmoSO1: equ 2 ;ELMO status: amplifier status bit SO1
ElmoSO2: equ 1 ;ELMO status: amplifier status bit SO2
ElmoSO3: equ 0 ;ELMO status: amplifier status bit SO3
;
;
DSPtio_m: equ %10000000 ;ELMO status: DSP Timer TIO status mask
DSPlock_m: equ %01000000 ;ELMO status: DSP PLL LOCK status mask
DSPhack_m: equ %00100000 ;ELMO status: DSP Host Acknowledge (~HACK) mask
DSPhreq_m: equ %00010000 ;ELMO status: DSP Host Request (~HREQ) mask
;
AmpOK_m: equ $07 ;Elmo code for "Amplifier OK"
;
;
The bit numbers (0 through 7) are used in BSET, BCLR, BRSET and BRCLR instructions, and the masks are used in the arithmetic and logical instructions, like AND, EOR, BIT and ORA.
An example of clearing a bit would be:
bclr DSPtio,ELMO ;clear the timer flag
I always use a "_m" on the mask, so that I can have macros append it automatically, and just use the name without the "_m" in the macro call.