OK, that make sense, with those defines. :-) And yes, since the bits-names are unique, the tools (MPASM) could/should be able to find out what register they are in. Or the builtin INC files could include those reg/bit combined defines. Otoh, in most programs/applications there isn't *that* much handling of the FSR. Most are setup in the init routine, and the some of them (timer regs, USART tx/rx regs and so on) are used. But yes, your defines seems to be a good thing. Jan-Erik. Dwayne Reid wrote 2012-04-26 00:11: > At 12:50 PM 4/25/2012, Jan-Erik Soderholm wrote: >>> >>> setbsrbit MACRO target, bnum ;bit >>> movlb (target>>7) ;get bank bits >>> CURRBANK set ((target>>7)<<7) ; >>> endm >>> >> >> OK. I'm lost... :-) >> >> What does the bnum parameter do ? > > Its a throw-away parameter. > > My include files are all in the form of: > > ; INTCON Register Bits rb 0 > #define _IOCIF INTCON,0 ; InterruptOnChange flag rst= in sw > #define _INTF INTCON,1 ; RB0 INT interrupt flag rst= in sw > #define _T0IF INTCON,2 ; TMR0 overflow int flag rst= in sw > #define _IOCIE INTCON,3 ; InterruptOnChange Enable act= ive hi > #define _INTE INTCON,4 ; INTF interrupt enable act= ive hi > #define _T0IE INTCON,5 ; TMR0 interrupt enable act= ive hi > #define _PEIE INTCON,6 ; Peripheral Interrupt Enable act= ive hi > #define _GIE INTCON,7 ; global interrupt enable act= ive hi > > INT_INIT EQU b'11000000' ;GIE, PEI enabled > INT_SLEEP EQU b'00011000' ;wake up from i/p& pin change (no GIE) > > This allows me to manipulate bits without ever knowing or caring in > which register the bit belongs to. > > For example: > bsf _GIE > ;next line of code > > > Another example, this time using the above macro: > > ;EECON1 rb 3 > #define _RD EECON1,0 ; Read: 1=3D initiate read > #define _WR EECON1,1 ; Write: 1=3D initiate write > #define _WREN EECON1,2 ; Erase/Write enable: 1=3Denable > #define _WRER EECON1,3 ; Erase/Write error: 1=3Derror > #define _FREE EECON1,4 ; Erase/Write select: 1=3DErase, 0=3DWr= ite > #define _LWLO EECON1,5 ; Ld Wr Latches Only =3D1; 0=3D Write a= ll data > #define _CFGS EECON1,6 ; Config Select =3D1; 0=3D access Progr= am memory > #define _EEPGD EECON1,7 ; > > movlw MAGIC_VALUE_ADDRESS > setbsr EEADRL > movwf RB(EEADRL) > clrf RB(EEADRH) > > ;somewhere later in the code, now I want to read that value. I have > no idea of what value BSR contains, so I need to set up the BSR > register. Because I'm lazy, I don't want to go and find out what > register the "_RD" bit belongs to. So I use the macro: > > setbsrbit (_RD) > bsf BB(_RD) > > Note how "_RD" expands to EECON1,0 - this means that the macro has > two parameters passed to it. Since all I want is the bank in which > the register belongs to, I simply throw away the second > parameter. But the macro has to be written to accept that second > parameter, else the assembler gets mad at you and throws a fatal error. > > [RANT ON] > > Why doesn't everyone write code using #define statements like I've > shown above. It seems, to me, to be completely ridiculous that > people have to string register names and bit names together to do a > simple bit manipulation. This is the new millennium, for gosh sakes! > > One of the smartest people I've ever had the pleasure to learn from > (Andrew Warren) showed me the above technique and I've been using it > ever since. That's back to the late '80s, early '90s. > > [RANT OFF] > > dwayne > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .